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;
// Check if the system was not auto-detected.
/* Check if the system was not auto-detected. */
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))
{
// ASCII serial (Wii) was detected.
/* ASCII serial (Wii) was detected. */
RARCH_LOG("%s '%s'\n", msg_hash_to_str(MSG_FOUND_DISK_LABEL), serial);
return 0;
}
// Any other non-system specific detection methods?
/* Any other non-system specific detection methods? */
return 0;
}

View File

@ -338,7 +338,7 @@ int detect_serial_ascii_game(const char *track_path, char *game_id)
bool rv = false;
RFILE *fd = filestream_open(track_path, RFILE_MODE_READ, -1);
// Attempt to load the file.
/* Attempt to load the file. */
if (!fd)
{
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);
if (filestream_read(fd, game_id, 10000) > 0)
{
unsigned i;
game_id[15] = '\0';
numberOfAscii = 0;
// Loop through until we run out of ASCII characters.
for (int 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)) {
/* Loop through until we run out of ASCII characters. */
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))
numberOfAscii++;
}
else {
else
break;
}
}
// If the length of the text is between 3 and 9 characters, it could be a serial.
if (numberOfAscii > 3 && numberOfAscii < 9) {
// Cut the string off, and return it as a valid serial.
/* If the length of the text is between 3 and 9 characters, it could be a serial. */
if (numberOfAscii > 3 && numberOfAscii < 9)
{
/* Cut the string off, and return it as a valid serial. */
game_id[numberOfAscii] = '\0';
rv = true;
break;