Skip to content

Commit

Permalink
Fixed equip_level_max handling in the sql db converter
Browse files Browse the repository at this point in the history
The field is now NULL when the value is not provided, instead of MAX_LEVEL.
Special Thanks to Mvmbles for bringing the issue to our attention.

Signed-off-by: shennetsind <ind@henn.et>
  • Loading branch information
shennetsind committed Nov 25, 2013
1 parent a724476 commit 1064d8c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/common/HPM.c
Expand Up @@ -644,6 +644,8 @@ void hplugins_share_defaults(void) {
/* libconfig (temp) */
HPM->share(config_setting_lookup_string,"config_setting_lookup_string");
HPM->share(config_setting_lookup_int,"config_setting_lookup_int");
HPM->share(config_setting_get_member,"config_setting_get_member");
HPM->share(config_setting_length,"config_setting_length");
}

void hpm_init(void) {
Expand Down
16 changes: 13 additions & 3 deletions src/plugins/db2sql.c
Expand Up @@ -36,6 +36,8 @@ bool torun = false;
int (*itemdb_readdb_libconfig_sub) (config_setting_t *it, int n, const char *source);
int (*h_config_setting_lookup_string) (const config_setting_t *setting, const char *name, const char **value);
int (*h_config_setting_lookup_int) (const config_setting_t *setting, const char *name, int *value);
config_setting_t *(*h_config_setting_get_member) (const config_setting_t *setting, const char *name);
int (*h_config_setting_length) (const config_setting_t *setting);

void hstr(const char *str) {
if( strlen(str) > tosql.buf[3].len ) {
Expand All @@ -54,7 +56,8 @@ int db2sql(config_setting_t *entry, int n, const char *source) {
char *str;
int i32;
unsigned int ui32, job = 0, upper = 0;

config_setting_t *t = NULL;

SQL->EscapeString(NULL, e_name, it->name);
SQL->EscapeString(NULL, e_jname, it->jname);
if( it->script ) { h_config_setting_lookup_string(entry, "Script", &script); hstr(script); str = tosql.buf[3].p; if ( strlen(str) > tosql.buf[0].len ) { tosql.buf[0].len = tosql.buf[0].len + strlen(str) + 1000; RECREATE(tosql.buf[0].p,char,tosql.buf[0].len); } SQL->EscapeString(NULL, tosql.buf[0].p, str); }
Expand All @@ -75,8 +78,13 @@ int db2sql(config_setting_t *entry, int n, const char *source) {

upper = ui32;

fprintf(tosql.fp,"REPLACE INTO `%s` VALUES ('%u','%s','%s','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%s','%s','%s');\n",
tosql.db_name,it->nameid,e_name,e_jname,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->matk,it->def,it->range,it->slot,job,upper,it->sex,it->equip,it->wlv,it->elv,it->elvmax,it->flag.no_refine?0:1,it->look,it->flag.bindonequip?1:0,it->script?tosql.buf[0].p:"",it->equip_script?tosql.buf[1].p:"",it->unequip_script?tosql.buf[2].p:"");
/* check if we have the equip_level_max, if so we send it -- otherwise we send NULL */
if( (t = h_config_setting_get_member(entry, "EquipLv")) && config_setting_is_aggregate(t) && h_config_setting_length(t) >= 2 )
fprintf(tosql.fp,"REPLACE INTO `%s` VALUES ('%u','%s','%s','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%s','%s','%s');\n",
tosql.db_name,it->nameid,e_name,e_jname,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->matk,it->def,it->range,it->slot,job,upper,it->sex,it->equip,it->wlv,it->elv,it->elvmax,it->flag.no_refine?0:1,it->look,it->flag.bindonequip?1:0,it->script?tosql.buf[0].p:"",it->equip_script?tosql.buf[1].p:"",it->unequip_script?tosql.buf[2].p:"");
else
fprintf(tosql.fp,"REPLACE INTO `%s` VALUES ('%u','%s','%s','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',NULL,'%u','%u','%u','%s','%s','%s');\n",
tosql.db_name,it->nameid,e_name,e_jname,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->matk,it->def,it->range,it->slot,job,upper,it->sex,it->equip,it->wlv,it->elv,it->flag.no_refine?0:1,it->look,it->flag.bindonequip?1:0,it->script?tosql.buf[0].p:"",it->equip_script?tosql.buf[1].p:"",it->unequip_script?tosql.buf[2].p:"");
}

return it?it->nameid:0;
Expand Down Expand Up @@ -186,6 +194,8 @@ void db2sql_arg(char *param) {
HPExport void server_preinit (void) {
h_config_setting_lookup_string = GET_SYMBOL("config_setting_lookup_string");
h_config_setting_lookup_int = GET_SYMBOL("config_setting_lookup_int");
h_config_setting_get_member = GET_SYMBOL("config_setting_get_member");
h_config_setting_length = GET_SYMBOL("config_setting_length");

SQL = GET_SYMBOL("SQL");
itemdb = GET_SYMBOL("itemdb");
Expand Down

0 comments on commit 1064d8c

Please sign in to comment.