summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-11-25 11:19:28 -0200
committershennetsind <ind@henn.et>2013-11-25 11:19:28 -0200
commit1064d8c073580fcb6a73c29a1c3c0ceb8a5df587 (patch)
tree5cc589344a3a8b6603179a15d7ec13c158e222f2
parenta724476174cd691704a51f60e540513bae743432 (diff)
downloadhercules-1064d8c073580fcb6a73c29a1c3c0ceb8a5df587.tar.gz
hercules-1064d8c073580fcb6a73c29a1c3c0ceb8a5df587.tar.bz2
hercules-1064d8c073580fcb6a73c29a1c3c0ceb8a5df587.tar.xz
hercules-1064d8c073580fcb6a73c29a1c3c0ceb8a5df587.zip
Fixed equip_level_max handling in the sql db converter
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>
-rw-r--r--src/common/HPM.c2
-rw-r--r--src/plugins/db2sql.c16
2 files changed, 15 insertions, 3 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c
index 641ffe2e6..005bc2ddc 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -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) {
diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c
index 9161e0263..1bf3f6c01 100644
--- a/src/plugins/db2sql.c
+++ b/src/plugins/db2sql.c
@@ -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 ) {
@@ -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); }
@@ -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;
@@ -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");