diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index afdd3a7295..1667d55161 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -247,53 +247,69 @@ int detect_psp_game(intfstream_t *fd, char *game_id) if (intfstream_read(fd, game_id, 5) > 0) { + bool found = false; game_id[5] = '\0'; - if ( - (string_is_equal(game_id, "ULES-")) - || (string_is_equal(game_id, "ULUS-")) - || (string_is_equal(game_id, "ULJS-")) - - || (string_is_equal(game_id, "ULEM-")) - || (string_is_equal(game_id, "ULUM-")) - || (string_is_equal(game_id, "ULJM-")) - - || (string_is_equal(game_id, "UCES-")) - || (string_is_equal(game_id, "UCUS-")) - || (string_is_equal(game_id, "UCJS-")) - || (string_is_equal(game_id, "UCAS-")) - || (string_is_equal(game_id, "UCKS-")) - - || (string_is_equal(game_id, "ULKS-")) - || (string_is_equal(game_id, "ULAS-")) - - || (string_is_equal(game_id, "NPEH-")) - || (string_is_equal(game_id, "NPUH-")) - || (string_is_equal(game_id, "NPJH-")) - - || (string_is_equal(game_id, "NPEG-")) - || (string_is_equal(game_id, "NPUG-")) - || (string_is_equal(game_id, "NPJG-")) - || (string_is_equal(game_id, "NPHG-")) - - || (string_is_equal(game_id, "NPEZ-")) - || (string_is_equal(game_id, "NPUZ-")) - || (string_is_equal(game_id, "NPJZ-")) + if (string_starts_with(game_id, "UL")) + { + if ( + (string_is_equal(game_id, "ULES-")) + || (string_is_equal(game_id, "ULJS-")) + || (string_is_equal(game_id, "ULEM-")) + || (string_is_equal(game_id, "ULUM-")) + || (string_is_equal(game_id, "ULJM-")) + || (string_is_equal(game_id, "ULKS-")) + || (string_is_equal(game_id, "ULAS-")) ) - { - intfstream_seek(fd, pos, SEEK_SET); - if (intfstream_read(fd, game_id, 10) > 0) - { + found = true; + } + if (!found && string_starts_with(game_id, "UC")) + { + if ( + (string_is_equal(game_id, "UCES-")) + || (string_is_equal(game_id, "UCUS-")) + || (string_is_equal(game_id, "UCUS-")) + || (string_is_equal(game_id, "UCJS-")) + || (string_is_equal(game_id, "UCAS-")) + || (string_is_equal(game_id, "UCKS-")) + ) + found = true; + } + + if (!found && string_starts_with(game_id, "NP")) + { + if ( + (string_is_equal(game_id, "NPEH-")) + || (string_is_equal(game_id, "NPUH-")) + || (string_is_equal(game_id, "NPJH-")) + + || (string_is_equal(game_id, "NPEG-")) + || (string_is_equal(game_id, "NPUG-")) + || (string_is_equal(game_id, "NPJG-")) + || (string_is_equal(game_id, "NPHG-")) + + || (string_is_equal(game_id, "NPEZ-")) + || (string_is_equal(game_id, "NPUZ-")) + || (string_is_equal(game_id, "NPJZ-")) + ) + found = true; + } + + if (found) + { + intfstream_seek(fd, pos, SEEK_SET); + if (intfstream_read(fd, game_id, 10) > 0) + { #if 0 - game_id[4] = '-'; - game_id[8] = game_id[9]; - game_id[9] = game_id[10]; + game_id[4] = '-'; + game_id[8] = game_id[9]; + game_id[9] = game_id[10]; #endif - game_id[10] = '\0'; - rv = true; - } - break; - } + game_id[10] = '\0'; + rv = true; + } + break; + } } else break;