diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -29,6 +29,8 @@ struct db_game { char *id; + int best_name_match; + int best_desc_match; char *name; char *desc; enum { @@ -215,7 +217,6 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr) XML_Parser p; struct db_game *game; char *lang; - char *lc_messages; db_dbg(" <%s> (game child)", name); @@ -228,10 +229,8 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr) if (lang == NULL) { return; } - lc_messages = strdup(db_lc_messages_get()); - db_dbg(" lang=\"%s\" (looking for \"%s\")", - lang, lc_messages); - if (strcasecmp(lang, lc_messages) == 0) { + db_dbg(" lang=\"%s\"", lang); + if (db_locale_match(lang) > game->best_name_match) { goto name_ok; } db_xml_node_push(p, game, _db_game_xml_invalid_start, @@ -245,17 +244,14 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr) _db_game_xml_cdata); name_err: free(lang); - free(lc_messages); } else if (db_xml_check_tag(name, "description")) { lang = NULL; db_xml_get_string_attr(p, attr, "lang", &lang, 1); if (lang == NULL) { return; } - lc_messages = strdup(db_lc_messages_get()); - db_dbg(" lang=\"%s\" (looking for \"%s\")", - lang, lc_messages); - if (strcasecmp(lang, lc_messages) == 0) { + db_dbg(" lang=\"%s\"", lang); + if (db_locale_match(lang) > game->best_desc_match) { goto desc_ok; } db_xml_node_push(p, game, _db_game_xml_invalid_start, @@ -269,7 +265,6 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr) _db_game_xml_cdata); desc_err: free(lang); - free(lc_messages); } else if (db_xml_check_tag(name, "levels")) { db_xml_node_push(p, game, _db_game_xml_levels_el_start, _db_game_xml_levels_end, NULL); |