database_info.c - get rid of hashes

This commit is contained in:
twinaphex 2018-02-25 17:43:12 +01:00
parent 74309e6e1c
commit 071476174d

View File

@ -30,37 +30,6 @@
#include "msg_hash.h" #include "msg_hash.h"
#include "verbosity.h" #include "verbosity.h"
#define DB_CURSOR_ROM_NAME 0x16bbcf13U
#define DB_CURSOR_NAME 0x7c9b0c46U
#define DB_CURSOR_DESCRIPTION 0x91b0c789U
#define DB_CURSOR_GENRE 0x0f802156U
#define DB_CURSOR_PUBLISHER 0x5e099013U
#define DB_CURSOR_DEVELOPER 0x1783d2abU
#define DB_CURSOR_ORIGIN 0x1315e3edU
#define DB_CURSOR_FRANCHISE 0xc3a526b8U
#define DB_CURSOR_BBFC_RATING 0xede26836U
#define DB_CURSOR_ESRB_RATING 0x4c3fa255U
#define DB_CURSOR_ELSPA_RATING 0xd9cab41eU
#define DB_CURSOR_CERO_RATING 0x084a1772U
#define DB_CURSOR_PEGI_RATING 0x431b736eU
#define DB_CURSOR_CHECKSUM_CRC32 0x0b88671dU
#define DB_CURSOR_CHECKSUM_SHA1 0x7c9de632U
#define DB_CURSOR_CHECKSUM_MD5 0x0b888fabU
#define DB_CURSOR_ENHANCEMENT_HW 0xab612029U
#define DB_CURSOR_EDGE_MAGAZINE_REVIEW 0xd3573eabU
#define DB_CURSOR_EDGE_MAGAZINE_RATING 0xd30dc4feU
#define DB_CURSOR_EDGE_MAGAZINE_ISSUE 0xa0f30d42U
#define DB_CURSOR_FAMITSU_MAGAZINE_RATING 0x0a50ca62U
#define DB_CURSOR_TGDB_RATING 0x8d61458aU
#define DB_CURSOR_MAX_USERS 0x1084ff77U
#define DB_CURSOR_RELEASEDATE_MONTH 0x790ad76cU
#define DB_CURSOR_RELEASEDATE_YEAR 0x7fd06ed7U
#define DB_CURSOR_RUMBLE_SUPPORTED 0x1a4dc3ecU
#define DB_CURSOR_COOP_SUPPORTED 0x7c953ff6U
#define DB_CURSOR_ANALOG_SUPPORTED 0xf220fc17U
#define DB_CURSOR_SIZE 0x7c9dede0U
#define DB_CURSOR_SERIAL 0x1b843ec5U
int database_info_build_query_enum(char *s, size_t len, int database_info_build_query_enum(char *s, size_t len,
enum database_query_type type, enum database_query_type type,
const char *path) const char *path)
@ -201,7 +170,6 @@ static int database_cursor_iterate(libretrodb_cursor_t *cur,
for (i = 0; i < item.val.map.len; i++) for (i = 0; i < item.val.map.len; i++)
{ {
uint32_t value = 0;
struct rmsgpack_dom_value *key = &item.val.map.items[i].key; struct rmsgpack_dom_value *key = &item.val.map.items[i].key;
struct rmsgpack_dom_value *val = &item.val.map.items[i].value; struct rmsgpack_dom_value *val = &item.val.map.items[i].value;
const char *val_string = NULL; const char *val_string = NULL;
@ -209,121 +177,123 @@ static int database_cursor_iterate(libretrodb_cursor_t *cur,
if (!key || !val) if (!key || !val)
continue; continue;
val_string = val->val.string.buff; val_string = val->val.string.buff;
str = key->val.string.buff; str = key->val.string.buff;
value = msg_hash_calculate(str);
switch (value) if (string_is_equal(str, "publisher"))
{ {
case DB_CURSOR_SERIAL: if (!string_is_empty(val_string))
if (!string_is_empty(val_string)) db_info->publisher = strdup(val_string);
db_info->serial = strdup(val_string); }
break; else if (string_is_equal(str, "developer"))
case DB_CURSOR_ROM_NAME: {
if (!string_is_empty(val_string)) if (!string_is_empty(val_string))
db_info->rom_name = strdup(val_string); db_info->developer = string_split(val_string, "|");
break; }
case DB_CURSOR_NAME: else if (string_is_equal(str, "serial"))
if (!string_is_empty(val_string)) {
db_info->name = strdup(val_string); if (!string_is_empty(val_string))
break; db_info->serial = strdup(val_string);
case DB_CURSOR_DESCRIPTION: }
if (!string_is_empty(val_string)) else if (string_is_equal(str, "rom_name"))
db_info->description = strdup(val_string); {
break; if (!string_is_empty(val_string))
case DB_CURSOR_GENRE: db_info->rom_name = strdup(val_string);
if (!string_is_empty(val_string)) }
db_info->genre = strdup(val_string); else if (string_is_equal(str, "name"))
break; {
case DB_CURSOR_PUBLISHER: if (!string_is_empty(val_string))
if (!string_is_empty(val_string)) db_info->name = strdup(val_string);
db_info->publisher = strdup(val_string); }
break; else if (string_is_equal(str, "description"))
case DB_CURSOR_DEVELOPER: {
if (!string_is_empty(val_string)) if (!string_is_empty(val_string))
db_info->developer = string_split(val_string, "|"); db_info->description = strdup(val_string);
break; }
case DB_CURSOR_ORIGIN: else if (string_is_equal(str, "genre"))
if (!string_is_empty(val_string)) {
db_info->origin = strdup(val_string); if (!string_is_empty(val_string))
break; db_info->genre = strdup(val_string);
case DB_CURSOR_FRANCHISE: }
if (!string_is_empty(val_string)) else if (string_is_equal(str, "origin"))
db_info->franchise = strdup(val_string); {
break; if (!string_is_empty(val_string))
case DB_CURSOR_BBFC_RATING: db_info->origin = strdup(val_string);
if (!string_is_empty(val_string)) }
db_info->bbfc_rating = strdup(val_string); else if (string_is_equal(str, "franchise"))
break; {
case DB_CURSOR_ESRB_RATING: if (!string_is_empty(val_string))
if (!string_is_empty(val_string)) db_info->franchise = strdup(val_string);
db_info->esrb_rating = strdup(val_string); }
break; else if (string_is_equal(str, "bbfc_rating"))
case DB_CURSOR_ELSPA_RATING: {
if (!string_is_empty(val_string)) if (!string_is_empty(val_string))
db_info->elspa_rating = strdup(val_string); db_info->bbfc_rating = strdup(val_string);
break; }
case DB_CURSOR_CERO_RATING: else if (string_is_equal(str, "esrb_rating"))
if (!string_is_empty(val_string)) {
db_info->cero_rating = strdup(val_string); if (!string_is_empty(val_string))
break; db_info->esrb_rating = strdup(val_string);
case DB_CURSOR_PEGI_RATING: }
if (!string_is_empty(val_string)) else if (string_is_equal(str, "elspa_rating"))
db_info->pegi_rating = strdup(val_string); {
break; if (!string_is_empty(val_string))
case DB_CURSOR_ENHANCEMENT_HW: db_info->elspa_rating = strdup(val_string);
if (!string_is_empty(val_string)) }
db_info->enhancement_hw = strdup(val_string); else if (string_is_equal(str, "cero_rating"))
break; {
case DB_CURSOR_EDGE_MAGAZINE_REVIEW: if (!string_is_empty(val_string))
if (!string_is_empty(val_string)) db_info->cero_rating = strdup(val_string);
db_info->edge_magazine_review = strdup(val_string); }
break; else if (string_is_equal(str, "pegi_rating"))
case DB_CURSOR_EDGE_MAGAZINE_RATING: {
db_info->edge_magazine_rating = (unsigned)val->val.uint_; if (!string_is_empty(val_string))
break; db_info->pegi_rating = strdup(val_string);
case DB_CURSOR_EDGE_MAGAZINE_ISSUE: }
db_info->edge_magazine_issue = (unsigned)val->val.uint_; else if (string_is_equal(str, "enhancement_hw"))
break; {
case DB_CURSOR_FAMITSU_MAGAZINE_RATING: if (!string_is_empty(val_string))
db_info->famitsu_magazine_rating = (unsigned)val->val.uint_; db_info->enhancement_hw = strdup(val_string);
break; }
case DB_CURSOR_TGDB_RATING: else if (string_is_equal(str, "edge_review"))
db_info->tgdb_rating = (unsigned)val->val.uint_; {
break; if (!string_is_empty(val_string))
case DB_CURSOR_MAX_USERS: db_info->edge_magazine_review = strdup(val_string);
db_info->max_users = (unsigned)val->val.uint_; }
break; else if (string_is_equal(str, "edge_rating"))
case DB_CURSOR_RELEASEDATE_MONTH: db_info->edge_magazine_rating = (unsigned)val->val.uint_;
db_info->releasemonth = (unsigned)val->val.uint_; else if (string_is_equal(str, "edge_issue"))
break; db_info->edge_magazine_issue = (unsigned)val->val.uint_;
case DB_CURSOR_RELEASEDATE_YEAR: else if (string_is_equal(str, "famitsu_rating"))
db_info->releaseyear = (unsigned)val->val.uint_; db_info->famitsu_magazine_rating = (unsigned)val->val.uint_;
break; else if (string_is_equal(str, "tgdb_rating"))
case DB_CURSOR_RUMBLE_SUPPORTED: db_info->tgdb_rating = (unsigned)val->val.uint_;
db_info->rumble_supported = (int)val->val.uint_; else if (string_is_equal(str, "users"))
break; db_info->max_users = (unsigned)val->val.uint_;
case DB_CURSOR_COOP_SUPPORTED: else if (string_is_equal(str, "releasemonth"))
db_info->coop_supported = (int)val->val.uint_; db_info->releasemonth = (unsigned)val->val.uint_;
break; else if (string_is_equal(str, "releaseyear"))
case DB_CURSOR_ANALOG_SUPPORTED: db_info->releaseyear = (unsigned)val->val.uint_;
db_info->analog_supported = (int)val->val.uint_; else if (string_is_equal(str, "rumble"))
break; db_info->rumble_supported = (int)val->val.uint_;
case DB_CURSOR_SIZE: else if (string_is_equal(str, "coop"))
db_info->size = (unsigned)val->val.uint_; db_info->coop_supported = (int)val->val.uint_;
break; else if (string_is_equal(str, "analog"))
case DB_CURSOR_CHECKSUM_CRC32: db_info->analog_supported = (int)val->val.uint_;
db_info->crc32 = swap_if_little32(*(uint32_t*)val->val.binary.buff); else if (string_is_equal(str, "size"))
break; db_info->size = (unsigned)val->val.uint_;
case DB_CURSOR_CHECKSUM_SHA1: else if (string_is_equal(str, "crc"))
db_info->sha1 = bin_to_hex_alloc((uint8_t*)val->val.binary.buff, val->val.binary.len); db_info->crc32 = swap_if_little32(
break; *(uint32_t*)val->val.binary.buff);
case DB_CURSOR_CHECKSUM_MD5: else if (string_is_equal(str, "sha1"))
db_info->md5 = bin_to_hex_alloc((uint8_t*)val->val.binary.buff, val->val.binary.len); db_info->sha1 = bin_to_hex_alloc(
break; (uint8_t*)val->val.binary.buff, val->val.binary.len);
default: else if (string_is_equal(str, "md5"))
RARCH_LOG("Unknown key: %s\n", str); db_info->md5 = bin_to_hex_alloc(
break; (uint8_t*)val->val.binary.buff, val->val.binary.len);
else
{
RARCH_LOG("Unknown key: %s\n", str);
} }
} }