This commit is contained in:
twinaphex 2017-07-30 10:11:41 +02:00
parent a3b1b9f690
commit 50b838d8ed
2 changed files with 16 additions and 15 deletions

View File

@ -142,18 +142,18 @@ static int iso_get_serial(database_state_handle_t *db_state,
{ {
const char* system_name = NULL; const char* system_name = NULL;
// Check if the system was not auto-detected. /* Check if the system was not auto-detected. */
if (detect_system(name, &system_name) < 0) if (detect_system(name, &system_name) < 0)
{ {
// Attempt to read an ASCII serial, like Wii. /* Attempt to read an ASCII serial, like Wii. */
if (detect_serial_ascii_game(name, serial)) if (detect_serial_ascii_game(name, serial))
{ {
// ASCII serial (Wii) was detected. /* ASCII serial (Wii) was detected. */
RARCH_LOG("%s '%s'\n", msg_hash_to_str(MSG_FOUND_DISK_LABEL), serial); RARCH_LOG("%s '%s'\n", msg_hash_to_str(MSG_FOUND_DISK_LABEL), serial);
return 0; return 0;
} }
// Any other non-system specific detection methods? /* Any other non-system specific detection methods? */
return 0; return 0;
} }

View File

@ -338,7 +338,7 @@ int detect_serial_ascii_game(const char *track_path, char *game_id)
bool rv = false; bool rv = false;
RFILE *fd = filestream_open(track_path, RFILE_MODE_READ, -1); RFILE *fd = filestream_open(track_path, RFILE_MODE_READ, -1);
// Attempt to load the file. /* Attempt to load the file. */
if (!fd) if (!fd)
{ {
RARCH_LOG("%s: %s\n", RARCH_LOG("%s: %s\n",
@ -352,23 +352,24 @@ int detect_serial_ascii_game(const char *track_path, char *game_id)
filestream_seek(fd, pos, SEEK_SET); filestream_seek(fd, pos, SEEK_SET);
if (filestream_read(fd, game_id, 10000) > 0) if (filestream_read(fd, game_id, 10000) > 0)
{ {
unsigned i;
game_id[15] = '\0'; game_id[15] = '\0';
numberOfAscii = 0; numberOfAscii = 0;
// Loop through until we run out of ASCII characters. /* Loop through until we run out of ASCII characters. */
for (int i = 0; i < 15; i++) { for (i = 0; i < 15; i++)
// Is the given character ASCII? A-Z, 0-9, - {
if (game_id[i] == 45 || (game_id[i] >= 48 && game_id[i] <= 57) || (game_id[i] >= 65 && game_id[i] <= 90)) { /* Is the given character ASCII? A-Z, 0-9, - */
if (game_id[i] == 45 || (game_id[i] >= 48 && game_id[i] <= 57) || (game_id[i] >= 65 && game_id[i] <= 90))
numberOfAscii++; numberOfAscii++;
} else
else {
break; break;
}
} }
// If the length of the text is between 3 and 9 characters, it could be a serial. /* If the length of the text is between 3 and 9 characters, it could be a serial. */
if (numberOfAscii > 3 && numberOfAscii < 9) { if (numberOfAscii > 3 && numberOfAscii < 9)
// Cut the string off, and return it as a valid serial. {
/* Cut the string off, and return it as a valid serial. */
game_id[numberOfAscii] = '\0'; game_id[numberOfAscii] = '\0';
rv = true; rv = true;
break; break;