diff options
Diffstat (limited to 'src/plugins/db2sql.c')
-rw-r--r-- | src/plugins/db2sql.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index 351962e26..3495e4abb 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -78,6 +78,7 @@ int (*mob_read_db_sub) (struct config_setting_t *it, int n, const char *source); */ void hstr(const char *str) { + nullpo_retv(str); if (strlen(str) > tosql.buf[3].len) { tosql.buf[3].len = tosql.buf[3].len + strlen(str) + 1000; RECREATE(tosql.buf[3].p,char,tosql.buf[3].len); @@ -378,8 +379,7 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) } // script - if (it->script) { - libconfig->setting_lookup_string(entry, "Script", &bonus); + if (it->script && libconfig->setting_lookup_string(entry, "Script", &bonus)) { hstr(bonus); str = tosql.buf[3].p; if (strlen(str) > tosql.buf[0].len) { @@ -387,12 +387,13 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) RECREATE(tosql.buf[0].p,char,tosql.buf[0].len); } SQL->EscapeString(NULL, tosql.buf[0].p, str); + StrBuf->Printf(&buf, "'%s',", tosql.buf[0].p); + } else { + StrBuf->AppendStr(&buf, "'',"); } - StrBuf->Printf(&buf, "'%s',", it->script?tosql.buf[0].p:""); // equip_script - if (it->equip_script) { - libconfig->setting_lookup_string(entry, "OnEquipScript", &bonus); + if (it->equip_script && libconfig->setting_lookup_string(entry, "OnEquipScript", &bonus)) { hstr(bonus); str = tosql.buf[3].p; if (strlen(str) > tosql.buf[1].len) { @@ -400,12 +401,13 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) RECREATE(tosql.buf[1].p,char,tosql.buf[1].len); } SQL->EscapeString(NULL, tosql.buf[1].p, str); + StrBuf->Printf(&buf, "'%s',", tosql.buf[1].p); + } else { + StrBuf->AppendStr(&buf, "'',"); } - StrBuf->Printf(&buf, "'%s',", it->equip_script?tosql.buf[1].p:""); // unequip_script - if (it->unequip_script) { - libconfig->setting_lookup_string(entry, "OnUnequipScript", &bonus); + if (it->unequip_script && libconfig->setting_lookup_string(entry, "OnUnequipScript", &bonus)) { hstr(bonus); str = tosql.buf[3].p; if (strlen(str) > tosql.buf[2].len) { @@ -413,8 +415,10 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) RECREATE(tosql.buf[2].p,char,tosql.buf[2].len); } SQL->EscapeString(NULL, tosql.buf[2].p, str); + StrBuf->Printf(&buf, "'%s'", tosql.buf[2].p); + } else { + StrBuf->AppendStr(&buf, "''"); } - StrBuf->Printf(&buf, "'%s'", it->unequip_script?tosql.buf[2].p:""); fprintf(tosql.fp, "REPLACE INTO `%s` VALUES (%s);\n", tosql.db_name, StrBuf->Value(&buf)); |