diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/map.c | 11 | ||||
-rw-r--r-- | src/map/mapreg.h | 2 | ||||
-rw-r--r-- | src/map/mapreg_sql.c | 101 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.Defs.inc | 2 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 4 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 1 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 27 |
7 files changed, 5 insertions, 143 deletions
diff --git a/src/map/map.c b/src/map/map.c index d9be46bfb..63d05c1c0 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -4459,7 +4459,6 @@ static bool inter_config_read_connection(const char *filename, const struct conf static bool inter_config_read_database_names(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; - bool retval = true; nullpo_retr(false, filename); nullpo_retr(false, config); @@ -4477,20 +4476,14 @@ static bool inter_config_read_database_names(const char *filename, const struct libconfig->setting_lookup_mutable_string(setting, "npc_barter_data_db", map->npc_barter_data_db, sizeof(map->npc_barter_data_db)); libconfig->setting_lookup_mutable_string(setting, "npc_expanded_barter_data_db", map->npc_expanded_barter_data_db, sizeof(map->npc_expanded_barter_data_db)); - if (!mapreg->config_read(filename, setting, imported)) - retval = false; - if ((setting = libconfig->lookup(config, "inter_configuration/database_names/registry")) == NULL) { if (imported) - return retval; + return true; ShowError("inter_config_read: inter_configuration/database_names/registry was not found in %s!\n", filename); return false; } - if (!mapreg->config_read_registry(filename, setting, imported)) - retval = false; - - return retval; + return mapreg->config_read_registry(filename, setting, imported); } /*======================================= diff --git a/src/map/mapreg.h b/src/map/mapreg.h index 772a6cb61..f97cd997d 100644 --- a/src/map/mapreg.h +++ b/src/map/mapreg.h @@ -47,7 +47,6 @@ struct mapreg_interface { /* */ struct eri *ers; //[Ind/Hercules] /* */ - char table[32]; char num_db[32]; //!< Name of SQL table which holds permanent global integer variables. char str_db[32]; //!< Name of SQL table which holds permanent global string variables. /* */ @@ -70,7 +69,6 @@ struct mapreg_interface { int (*destroyreg) (union DBKey key, struct DBData *data, va_list ap); void (*reload) (void); bool (*config_read_registry) (const char *filename, const struct config_setting_t *config, bool imported); - bool (*config_read) (const char *filename, const struct config_setting_t *config, bool imported); }; #ifdef HERCULES_CORE diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index 376e582f9..cf509f027 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -101,11 +101,6 @@ static bool mapreg_setreg(int64 uid, int val) m->is_string = false; if (name[1] != '@' && !mapreg->skip_insert) {// write new variable to database - char tmp_str[(SCRIPT_VARNAME_LENGTH+1)*2+1]; - SQL->EscapeStringLen(map->mysql_handle, tmp_str, name, strnlen(name, SCRIPT_VARNAME_LENGTH+1)); - if( SQL_ERROR == SQL->Query(map->mysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%u','%d')", mapreg->table, tmp_str, i, val) ) - Sql_ShowDebug(map->mysql_handle); - struct SqlStmt *stmt = SQL->StmtMalloc(map->mysql_handle); if (stmt == NULL) { @@ -136,9 +131,6 @@ static bool mapreg_setreg(int64 uid, int val) i64db_remove(mapreg->regs.vars, uid); if( name[1] != '@' ) {// Remove from database because it is unused. - if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%u'", mapreg->table, name, i) ) - Sql_ShowDebug(map->mysql_handle); - struct SqlStmt *stmt = SQL->StmtMalloc(map->mysql_handle); if (stmt == NULL) { @@ -182,9 +174,6 @@ static bool mapreg_setregstr(int64 uid, const char *str) if( i ) script->array_update(&mapreg->regs, uid, true); if(name[1] != '@') { - if (SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%u'", mapreg->table, name, i)) - Sql_ShowDebug(map->mysql_handle); - struct SqlStmt *stmt = SQL->StmtMalloc(map->mysql_handle); if (stmt == NULL) { @@ -230,13 +219,6 @@ static bool mapreg_setregstr(int64 uid, const char *str) m->is_string = true; if(name[1] != '@' && !mapreg->skip_insert) { //put returned null, so we must insert. - char tmp_str[(SCRIPT_VARNAME_LENGTH+1)*2+1]; - char tmp_str2[SCRIPT_STRING_VAR_LENGTH * 2 + 1]; - SQL->EscapeStringLen(map->mysql_handle, tmp_str, name, strnlen(name, SCRIPT_VARNAME_LENGTH+1)); - SQL->EscapeStringLen(map->mysql_handle, tmp_str2, str, strnlen(str, SCRIPT_STRING_VAR_LENGTH)); - if( SQL_ERROR == SQL->Query(map->mysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%u','%s')", mapreg->table, tmp_str, i, tmp_str2) ) - Sql_ShowDebug(map->mysql_handle); - struct SqlStmt *stmt = SQL->StmtMalloc(map->mysql_handle); if (stmt == NULL) { @@ -371,55 +353,8 @@ static void mapreg_load_str_db(void) */ static void script_load_mapreg(void) { - /* - 0 1 2 - +-------------------------+ - | varname | index | value | - +-------------------------+ - */ - struct SqlStmt *stmt = SQL->StmtMalloc(map->mysql_handle); - char varname[SCRIPT_VARNAME_LENGTH+1]; - int index; - char value[SCRIPT_STRING_VAR_LENGTH + 1]; - uint32 length; - - if ( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg->table) - || SQL_ERROR == SQL->StmtExecute(stmt) - ) { - SqlStmt_ShowDebug(stmt); - SQL->StmtFree(stmt); - return; - } - - mapreg->skip_insert = true; - - SQL->StmtBindColumn(stmt, 0, SQLDT_STRING, &varname, sizeof varname, &length, NULL); - SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &index, sizeof index, NULL, NULL); - SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &value, sizeof value, NULL, NULL); - - while ( SQL_SUCCESS == SQL->StmtNextRow(stmt) ) { - int s = script->add_variable(varname); - int i = index; - - - if( i64db_exists(mapreg->regs.vars, reference_uid(s, i)) ) { - ShowWarning("load_mapreg: duplicate! '%s' => '%s' skipping...\n",varname,value); - continue; - } - if( varname[length-1] == '$' ) { - mapreg->setregstr(reference_uid(s, i),value); - } else { - mapreg->setreg(reference_uid(s, i),atoi(value)); - } - } - - SQL->StmtFree(stmt); - - mapreg->skip_insert = false; - mapreg->load_num_db(); mapreg->load_str_db(); - mapreg->dirty = false; } @@ -508,19 +443,12 @@ static void script_save_mapreg(void) int i = script_getvaridx(m->uid); const char* name = script->get_str(num); nullpo_retv(name); - if (!m->is_string) { - if( SQL_ERROR == SQL->Query(map->mysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, m->u.i, name, i) ) - Sql_ShowDebug(map->mysql_handle); + if (!m->is_string) mapreg->save_num_db(name, i, m->u.i); - } else { - char tmp_str2[SCRIPT_STRING_VAR_LENGTH * 2 + 1]; - SQL->EscapeStringLen(map->mysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, SCRIPT_STRING_VAR_LENGTH)); - if( SQL_ERROR == SQL->Query(map->mysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, tmp_str2, name, i) ) - Sql_ShowDebug(map->mysql_handle); - + else mapreg->save_str_db(name, i, m->u.str); - } + m->save = false; } } @@ -649,26 +577,6 @@ static void mapreg_init(void) } /** - * Loads the mapreg configuration file. - * - * @param filename Path to configuration file (used in error and warning messages). - * @param config The current config being parsed. - * @param imported Whether the current config is imported from another file. - * - * @retval false in case of error. - */ -static bool mapreg_config_read(const char *filename, const struct config_setting_t *config, bool imported) -{ - nullpo_retr(false, filename); - nullpo_retr(false, config); - - if (libconfig->setting_lookup_mutable_string(config, "mapreg_db", mapreg->table, sizeof(mapreg->table)) != CONFIG_TRUE) - return false; - - return true; -} - -/** * Interface defaults initializer. */ void mapreg_defaults(void) @@ -680,7 +588,6 @@ void mapreg_defaults(void) mapreg->ers = NULL; mapreg->skip_insert = false; - safestrncpy(mapreg->table, "mapreg", sizeof(mapreg->table)); safestrncpy(mapreg->num_db, "map_reg_num_db", sizeof(mapreg->num_db)); safestrncpy(mapreg->str_db, "map_reg_str_db", sizeof(mapreg->str_db)); mapreg->dirty = false; @@ -707,6 +614,4 @@ void mapreg_defaults(void) mapreg->destroyreg = mapreg_destroyreg; mapreg->reload = mapreg_reload; mapreg->config_read_registry = mapreg_config_read_registry; - mapreg->config_read = mapreg_config_read; - } diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index ef71f1967..c8dd6fed3 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -5246,8 +5246,6 @@ typedef int (*HPMHOOK_pre_mapreg_destroyreg) (union DBKey *key, struct DBData ** typedef int (*HPMHOOK_post_mapreg_destroyreg) (int retVal___, union DBKey key, struct DBData *data, va_list ap); typedef void (*HPMHOOK_pre_mapreg_reload) (void); typedef void (*HPMHOOK_post_mapreg_reload) (void); -typedef bool (*HPMHOOK_pre_mapreg_config_read) (const char **filename, const struct config_setting_t **config, bool *imported); -typedef bool (*HPMHOOK_post_mapreg_config_read) (bool retVal___, const char *filename, const struct config_setting_t *config, bool imported); #endif // MAP_MAPREG_H #ifdef COMMON_MD5CALC_H /* md5 */ typedef void (*HPMHOOK_pre_md5_string) (const char **string, char **output); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index e8cb41240..c458ef539 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -3850,8 +3850,6 @@ struct { struct HPMHookPoint *HP_mapreg_destroyreg_post; struct HPMHookPoint *HP_mapreg_reload_pre; struct HPMHookPoint *HP_mapreg_reload_post; - struct HPMHookPoint *HP_mapreg_config_read_pre; - struct HPMHookPoint *HP_mapreg_config_read_post; struct HPMHookPoint *HP_md5_string_pre; struct HPMHookPoint *HP_md5_string_post; struct HPMHookPoint *HP_md5_binary_pre; @@ -10751,8 +10749,6 @@ struct { int HP_mapreg_destroyreg_post; int HP_mapreg_reload_pre; int HP_mapreg_reload_post; - int HP_mapreg_config_read_pre; - int HP_mapreg_config_read_post; int HP_md5_string_pre; int HP_md5_string_post; int HP_md5_binary_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 6b89841ad..bdfcbf931 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -1971,7 +1971,6 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mapreg->save_timer, HP_mapreg_save_timer) }, { HP_POP(mapreg->destroyreg, HP_mapreg_destroyreg) }, { HP_POP(mapreg->reload, HP_mapreg_reload) }, - { HP_POP(mapreg->config_read, HP_mapreg_config_read) }, /* md5_interface */ { HP_POP(md5->string, HP_md5_string) }, { HP_POP(md5->binary, HP_md5_binary) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 02d55228e..b25ca934b 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -50916,33 +50916,6 @@ void HP_mapreg_reload(void) { } return; } -bool HP_mapreg_config_read(const char *filename, const struct config_setting_t *config, bool imported) { - int hIndex = 0; - bool retVal___ = false; - if (HPMHooks.count.HP_mapreg_config_read_pre > 0) { - bool (*preHookFunc) (const char **filename, const struct config_setting_t **config, bool *imported); - *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_mapreg_config_read_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_mapreg_config_read_pre[hIndex].func; - retVal___ = preHookFunc(&filename, &config, &imported); - } - if (*HPMforce_return) { - *HPMforce_return = false; - return retVal___; - } - } - { - retVal___ = HPMHooks.source.mapreg.config_read(filename, config, imported); - } - if (HPMHooks.count.HP_mapreg_config_read_post > 0) { - bool (*postHookFunc) (bool retVal___, const char *filename, const struct config_setting_t *config, bool imported); - for (hIndex = 0; hIndex < HPMHooks.count.HP_mapreg_config_read_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_mapreg_config_read_post[hIndex].func; - retVal___ = postHookFunc(retVal___, filename, config, imported); - } - } - return retVal___; -} /* md5_interface */ void HP_md5_string(const char *string, char *output) { int hIndex = 0; |