diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc | 4 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc | 1 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_char.Hooks.inc | 27 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc | 4 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc | 1 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_login.Hooks.inc | 27 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 20 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 5 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 211 | ||||
-rw-r--r-- | src/plugins/Makefile.in | 4 | ||||
-rw-r--r-- | src/plugins/constdb2doc.c | 197 | ||||
-rw-r--r-- | src/plugins/db2sql.c | 557 |
12 files changed, 923 insertions, 135 deletions
diff --git a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc index dd6b3d5d6..9d8a2750d 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc @@ -1356,6 +1356,8 @@ struct { struct HPMHookPoint *HP_sysinfo_compiler_post; struct HPMHookPoint *HP_sysinfo_cflags_pre; struct HPMHookPoint *HP_sysinfo_cflags_post; + struct HPMHookPoint *HP_sysinfo_time_pre; + struct HPMHookPoint *HP_sysinfo_time_post; struct HPMHookPoint *HP_sysinfo_vcstype_pre; struct HPMHookPoint *HP_sysinfo_vcstype_post; struct HPMHookPoint *HP_sysinfo_vcstypeid_pre; @@ -2733,6 +2735,8 @@ struct { int HP_sysinfo_compiler_post; int HP_sysinfo_cflags_pre; int HP_sysinfo_cflags_post; + int HP_sysinfo_time_pre; + int HP_sysinfo_time_post; int HP_sysinfo_vcstype_pre; int HP_sysinfo_vcstype_post; int HP_sysinfo_vcstypeid_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc index 34a9e4005..fe3e806b1 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc @@ -721,6 +721,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is64bit, HP_sysinfo_is64bit) }, { HP_POP(sysinfo->compiler, HP_sysinfo_compiler) }, { HP_POP(sysinfo->cflags, HP_sysinfo_cflags) }, + { HP_POP(sysinfo->time, HP_sysinfo_time) }, { HP_POP(sysinfo->vcstype, HP_sysinfo_vcstype) }, { HP_POP(sysinfo->vcstypeid, HP_sysinfo_vcstypeid) }, { HP_POP(sysinfo->vcsrevision_src, HP_sysinfo_vcsrevision_src) }, diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc index b1554aefd..e6100ffdd 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc @@ -17857,6 +17857,33 @@ const char* HP_sysinfo_cflags(void) { } return retVal___; } +const char* HP_sysinfo_time(void) { + int hIndex = 0; + const char* retVal___ = NULL; + if( HPMHooks.count.HP_sysinfo_time_pre ) { + const char* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_sysinfo_time_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_sysinfo_time_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.sysinfo.time(); + } + if( HPMHooks.count.HP_sysinfo_time_post ) { + const char* (*postHookFunc) (const char* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_sysinfo_time_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_sysinfo_time_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} const char* HP_sysinfo_vcstype(void) { int hIndex = 0; const char* retVal___ = NULL; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc index ce78fdd7e..a9abae542 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc @@ -556,6 +556,8 @@ struct { struct HPMHookPoint *HP_sysinfo_compiler_post; struct HPMHookPoint *HP_sysinfo_cflags_pre; struct HPMHookPoint *HP_sysinfo_cflags_post; + struct HPMHookPoint *HP_sysinfo_time_pre; + struct HPMHookPoint *HP_sysinfo_time_post; struct HPMHookPoint *HP_sysinfo_vcstype_pre; struct HPMHookPoint *HP_sysinfo_vcstype_post; struct HPMHookPoint *HP_sysinfo_vcstypeid_pre; @@ -1133,6 +1135,8 @@ struct { int HP_sysinfo_compiler_post; int HP_sysinfo_cflags_pre; int HP_sysinfo_cflags_post; + int HP_sysinfo_time_pre; + int HP_sysinfo_time_post; int HP_sysinfo_vcstype_pre; int HP_sysinfo_vcstype_post; int HP_sysinfo_vcstypeid_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index 5be52d51e..5e501c62c 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -305,6 +305,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is64bit, HP_sysinfo_is64bit) }, { HP_POP(sysinfo->compiler, HP_sysinfo_compiler) }, { HP_POP(sysinfo->cflags, HP_sysinfo_cflags) }, + { HP_POP(sysinfo->time, HP_sysinfo_time) }, { HP_POP(sysinfo->vcstype, HP_sysinfo_vcstype) }, { HP_POP(sysinfo->vcstypeid, HP_sysinfo_vcstypeid) }, { HP_POP(sysinfo->vcsrevision_src, HP_sysinfo_vcsrevision_src) }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index 670083e94..bf0610688 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -7183,6 +7183,33 @@ const char* HP_sysinfo_cflags(void) { } return retVal___; } +const char* HP_sysinfo_time(void) { + int hIndex = 0; + const char* retVal___ = NULL; + if( HPMHooks.count.HP_sysinfo_time_pre ) { + const char* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_sysinfo_time_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_sysinfo_time_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.sysinfo.time(); + } + if( HPMHooks.count.HP_sysinfo_time_post ) { + const char* (*postHookFunc) (const char* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_sysinfo_time_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_sysinfo_time_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} const char* HP_sysinfo_vcstype(void) { int hIndex = 0; const char* retVal___ = NULL; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index e0c5a4df3..911e84586 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -1848,6 +1848,8 @@ struct { struct HPMHookPoint *HP_clif_pHotkeyRowShift_post; struct HPMHookPoint *HP_clif_dressroom_open_pre; struct HPMHookPoint *HP_clif_dressroom_open_post; + struct HPMHookPoint *HP_clif_pOneClick_ItemIdentify_pre; + struct HPMHookPoint *HP_clif_pOneClick_ItemIdentify_post; struct HPMHookPoint *HP_clif_selectcart_pre; struct HPMHookPoint *HP_clif_selectcart_post; struct HPMHookPoint *HP_clif_pSelectCart_pre; @@ -3478,6 +3480,8 @@ struct { struct HPMHookPoint *HP_mob_lookup_const_post; struct HPMHookPoint *HP_mob_get_const_pre; struct HPMHookPoint *HP_mob_get_const_post; + struct HPMHookPoint *HP_mob_db_validate_entry_pre; + struct HPMHookPoint *HP_mob_db_validate_entry_post; struct HPMHookPoint *HP_mob_read_libconfig_pre; struct HPMHookPoint *HP_mob_read_libconfig_post; struct HPMHookPoint *HP_mob_read_db_additional_fields_pre; @@ -4322,6 +4326,8 @@ struct { struct HPMHookPoint *HP_pc_check_job_name_post; struct HPMHookPoint *HP_pc_update_idle_time_pre; struct HPMHookPoint *HP_pc_update_idle_time_post; + struct HPMHookPoint *HP_pc_have_magnifier_pre; + struct HPMHookPoint *HP_pc_have_magnifier_post; struct HPMHookPoint *HP_libpcre_compile_pre; struct HPMHookPoint *HP_libpcre_compile_post; struct HPMHookPoint *HP_libpcre_study_pre; @@ -4624,6 +4630,8 @@ struct { struct HPMHookPoint *HP_script_parse_line_post; struct HPMHookPoint *HP_script_read_constdb_pre; struct HPMHookPoint *HP_script_read_constdb_post; + struct HPMHookPoint *HP_script_constdb_comment_pre; + struct HPMHookPoint *HP_script_constdb_comment_post; struct HPMHookPoint *HP_script_print_line_pre; struct HPMHookPoint *HP_script_print_line_post; struct HPMHookPoint *HP_script_errorwarning_sub_pre; @@ -5690,6 +5698,8 @@ struct { struct HPMHookPoint *HP_sysinfo_compiler_post; struct HPMHookPoint *HP_sysinfo_cflags_pre; struct HPMHookPoint *HP_sysinfo_cflags_post; + struct HPMHookPoint *HP_sysinfo_time_pre; + struct HPMHookPoint *HP_sysinfo_time_post; struct HPMHookPoint *HP_sysinfo_vcstype_pre; struct HPMHookPoint *HP_sysinfo_vcstype_post; struct HPMHookPoint *HP_sysinfo_vcstypeid_pre; @@ -7689,6 +7699,8 @@ struct { int HP_clif_pHotkeyRowShift_post; int HP_clif_dressroom_open_pre; int HP_clif_dressroom_open_post; + int HP_clif_pOneClick_ItemIdentify_pre; + int HP_clif_pOneClick_ItemIdentify_post; int HP_clif_selectcart_pre; int HP_clif_selectcart_post; int HP_clif_pSelectCart_pre; @@ -9319,6 +9331,8 @@ struct { int HP_mob_lookup_const_post; int HP_mob_get_const_pre; int HP_mob_get_const_post; + int HP_mob_db_validate_entry_pre; + int HP_mob_db_validate_entry_post; int HP_mob_read_libconfig_pre; int HP_mob_read_libconfig_post; int HP_mob_read_db_additional_fields_pre; @@ -10163,6 +10177,8 @@ struct { int HP_pc_check_job_name_post; int HP_pc_update_idle_time_pre; int HP_pc_update_idle_time_post; + int HP_pc_have_magnifier_pre; + int HP_pc_have_magnifier_post; int HP_libpcre_compile_pre; int HP_libpcre_compile_post; int HP_libpcre_study_pre; @@ -10465,6 +10481,8 @@ struct { int HP_script_parse_line_post; int HP_script_read_constdb_pre; int HP_script_read_constdb_post; + int HP_script_constdb_comment_pre; + int HP_script_constdb_comment_post; int HP_script_print_line_pre; int HP_script_print_line_post; int HP_script_errorwarning_sub_pre; @@ -11531,6 +11549,8 @@ struct { int HP_sysinfo_compiler_post; int HP_sysinfo_cflags_pre; int HP_sysinfo_cflags_post; + int HP_sysinfo_time_pre; + int HP_sysinfo_time_post; int HP_sysinfo_vcstype_pre; int HP_sysinfo_vcstype_post; int HP_sysinfo_vcstypeid_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 5bbad878a..303f5ed7e 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -944,6 +944,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->add_random_options, HP_clif_add_random_options) }, { HP_POP(clif->pHotkeyRowShift, HP_clif_pHotkeyRowShift) }, { HP_POP(clif->dressroom_open, HP_clif_dressroom_open) }, + { HP_POP(clif->pOneClick_ItemIdentify, HP_clif_pOneClick_ItemIdentify) }, { HP_POP(clif->selectcart, HP_clif_selectcart) }, { HP_POP(clif->pSelectCart, HP_clif_pSelectCart) }, /* cmdline */ @@ -1782,6 +1783,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mob->readdb, HP_mob_readdb) }, { HP_POP(mob->lookup_const, HP_mob_lookup_const) }, { HP_POP(mob->get_const, HP_mob_get_const) }, + { HP_POP(mob->db_validate_entry, HP_mob_db_validate_entry) }, { HP_POP(mob->read_libconfig, HP_mob_read_libconfig) }, { HP_POP(mob->read_db_additional_fields, HP_mob_read_db_additional_fields) }, { HP_POP(mob->read_db_sub, HP_mob_read_db_sub) }, @@ -2211,6 +2213,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pc->autotrade_final, HP_pc_autotrade_final) }, { HP_POP(pc->check_job_name, HP_pc_check_job_name) }, { HP_POP(pc->update_idle_time, HP_pc_update_idle_time) }, + { HP_POP(pc->have_magnifier, HP_pc_have_magnifier) }, /* libpcre */ { HP_POP(libpcre->compile, HP_libpcre_compile) }, { HP_POP(libpcre->study, HP_libpcre_study) }, @@ -2366,6 +2369,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(script->parse_expr, HP_script_parse_expr) }, { HP_POP(script->parse_line, HP_script_parse_line) }, { HP_POP(script->read_constdb, HP_script_read_constdb) }, + { HP_POP(script->constdb_comment, HP_script_constdb_comment) }, { HP_POP(script->print_line, HP_script_print_line) }, { HP_POP(script->errorwarning_sub, HP_script_errorwarning_sub) }, { HP_POP(script->set_reg, HP_script_set_reg) }, @@ -2910,6 +2914,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is64bit, HP_sysinfo_is64bit) }, { HP_POP(sysinfo->compiler, HP_sysinfo_compiler) }, { HP_POP(sysinfo->cflags, HP_sysinfo_cflags) }, + { HP_POP(sysinfo->time, HP_sysinfo_time) }, { HP_POP(sysinfo->vcstype, HP_sysinfo_vcstype) }, { HP_POP(sysinfo->vcstypeid, HP_sysinfo_vcstypeid) }, { HP_POP(sysinfo->vcsrevision_src, HP_sysinfo_vcsrevision_src) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 87d85cc6c..ee07b99cb 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -24067,6 +24067,32 @@ void HP_clif_dressroom_open(struct map_session_data *sd, int view) { } return; } +void HP_clif_pOneClick_ItemIdentify(int fd, struct map_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_clif_pOneClick_ItemIdentify_pre ) { + void (*preHookFunc) (int *fd, struct map_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pOneClick_ItemIdentify_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_clif_pOneClick_ItemIdentify_pre[hIndex].func; + preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.pOneClick_ItemIdentify(fd, sd); + } + if( HPMHooks.count.HP_clif_pOneClick_ItemIdentify_post ) { + void (*postHookFunc) (int *fd, struct map_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pOneClick_ItemIdentify_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_clif_pOneClick_ItemIdentify_post[hIndex].func; + postHookFunc(&fd, sd); + } + } + return; +} void HP_clif_selectcart(struct map_session_data *sd) { int hIndex = 0; if( HPMHooks.count.HP_clif_selectcart_pre ) { @@ -46205,6 +46231,33 @@ bool HP_mob_get_const(const config_setting_t *it, int *value) { } return retVal___; } +int HP_mob_db_validate_entry(struct mob_db *entry, int n, const char *source) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_mob_db_validate_entry_pre ) { + int (*preHookFunc) (struct mob_db *entry, int *n, const char *source); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_db_validate_entry_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_mob_db_validate_entry_pre[hIndex].func; + retVal___ = preHookFunc(entry, &n, source); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.mob.db_validate_entry(entry, n, source); + } + if( HPMHooks.count.HP_mob_db_validate_entry_post ) { + int (*postHookFunc) (int retVal___, struct mob_db *entry, int *n, const char *source); + for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_db_validate_entry_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_mob_db_validate_entry_post[hIndex].func; + retVal___ = postHookFunc(retVal___, entry, &n, source); + } + } + return retVal___; +} int HP_mob_read_libconfig(const char *filename, bool ignore_missing) { int hIndex = 0; int retVal___ = 0; @@ -46232,14 +46285,14 @@ int HP_mob_read_libconfig(const char *filename, bool ignore_missing) { } return retVal___; } -void HP_mob_read_db_additional_fields(struct mob_db *entry, int class_, config_setting_t *it, int n, const char *source) { +void HP_mob_read_db_additional_fields(struct mob_db *entry, config_setting_t *it, int n, const char *source) { int hIndex = 0; if( HPMHooks.count.HP_mob_read_db_additional_fields_pre ) { - void (*preHookFunc) (struct mob_db *entry, int *class_, config_setting_t *it, int *n, const char *source); + void (*preHookFunc) (struct mob_db *entry, config_setting_t *it, int *n, const char *source); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_additional_fields_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_mob_read_db_additional_fields_pre[hIndex].func; - preHookFunc(entry, &class_, it, &n, source); + preHookFunc(entry, it, &n, source); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -46247,22 +46300,22 @@ void HP_mob_read_db_additional_fields(struct mob_db *entry, int class_, config_s } } { - HPMHooks.source.mob.read_db_additional_fields(entry, class_, it, n, source); + HPMHooks.source.mob.read_db_additional_fields(entry, it, n, source); } if( HPMHooks.count.HP_mob_read_db_additional_fields_post ) { - void (*postHookFunc) (struct mob_db *entry, int *class_, config_setting_t *it, int *n, const char *source); + void (*postHookFunc) (struct mob_db *entry, config_setting_t *it, int *n, const char *source); for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_additional_fields_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_mob_read_db_additional_fields_post[hIndex].func; - postHookFunc(entry, &class_, it, &n, source); + postHookFunc(entry, it, &n, source); } } return; } -bool HP_mob_read_db_sub(config_setting_t *mobt, int id, const char *source) { +int HP_mob_read_db_sub(config_setting_t *mobt, int id, const char *source) { int hIndex = 0; - bool retVal___ = false; + int retVal___ = 0; if( HPMHooks.count.HP_mob_read_db_sub_pre ) { - bool (*preHookFunc) (config_setting_t *mobt, int *id, const char *source); + int (*preHookFunc) (config_setting_t *mobt, int *id, const char *source); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_sub_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_mob_read_db_sub_pre[hIndex].func; @@ -46277,7 +46330,7 @@ bool HP_mob_read_db_sub(config_setting_t *mobt, int id, const char *source) { retVal___ = HPMHooks.source.mob.read_db_sub(mobt, id, source); } if( HPMHooks.count.HP_mob_read_db_sub_post ) { - bool (*postHookFunc) (bool retVal___, config_setting_t *mobt, int *id, const char *source); + int (*postHookFunc) (int retVal___, config_setting_t *mobt, int *id, const char *source); for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_sub_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_mob_read_db_sub_post[hIndex].func; retVal___ = postHookFunc(retVal___, mobt, &id, source); @@ -46285,14 +46338,14 @@ bool HP_mob_read_db_sub(config_setting_t *mobt, int id, const char *source) { } return retVal___; } -void HP_mob_read_db_drops_sub(struct mob_db *entry, struct status_data *mstatus, int class_, config_setting_t *t) { +void HP_mob_read_db_drops_sub(struct mob_db *entry, config_setting_t *t) { int hIndex = 0; if( HPMHooks.count.HP_mob_read_db_drops_sub_pre ) { - void (*preHookFunc) (struct mob_db *entry, struct status_data *mstatus, int *class_, config_setting_t *t); + void (*preHookFunc) (struct mob_db *entry, config_setting_t *t); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_drops_sub_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_mob_read_db_drops_sub_pre[hIndex].func; - preHookFunc(entry, mstatus, &class_, t); + preHookFunc(entry, t); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -46300,25 +46353,25 @@ void HP_mob_read_db_drops_sub(struct mob_db *entry, struct status_data *mstatus, } } { - HPMHooks.source.mob.read_db_drops_sub(entry, mstatus, class_, t); + HPMHooks.source.mob.read_db_drops_sub(entry, t); } if( HPMHooks.count.HP_mob_read_db_drops_sub_post ) { - void (*postHookFunc) (struct mob_db *entry, struct status_data *mstatus, int *class_, config_setting_t *t); + void (*postHookFunc) (struct mob_db *entry, config_setting_t *t); for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_drops_sub_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_mob_read_db_drops_sub_post[hIndex].func; - postHookFunc(entry, mstatus, &class_, t); + postHookFunc(entry, t); } } return; } -void HP_mob_read_db_mvpdrops_sub(struct mob_db *entry, struct status_data *mstatus, int class_, config_setting_t *t) { +void HP_mob_read_db_mvpdrops_sub(struct mob_db *entry, config_setting_t *t) { int hIndex = 0; if( HPMHooks.count.HP_mob_read_db_mvpdrops_sub_pre ) { - void (*preHookFunc) (struct mob_db *entry, struct status_data *mstatus, int *class_, config_setting_t *t); + void (*preHookFunc) (struct mob_db *entry, config_setting_t *t); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_mvpdrops_sub_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_mob_read_db_mvpdrops_sub_pre[hIndex].func; - preHookFunc(entry, mstatus, &class_, t); + preHookFunc(entry, t); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -46326,26 +46379,26 @@ void HP_mob_read_db_mvpdrops_sub(struct mob_db *entry, struct status_data *mstat } } { - HPMHooks.source.mob.read_db_mvpdrops_sub(entry, mstatus, class_, t); + HPMHooks.source.mob.read_db_mvpdrops_sub(entry, t); } if( HPMHooks.count.HP_mob_read_db_mvpdrops_sub_post ) { - void (*postHookFunc) (struct mob_db *entry, struct status_data *mstatus, int *class_, config_setting_t *t); + void (*postHookFunc) (struct mob_db *entry, config_setting_t *t); for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_mvpdrops_sub_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_mob_read_db_mvpdrops_sub_post[hIndex].func; - postHookFunc(entry, mstatus, &class_, t); + postHookFunc(entry, t); } } return; } -int HP_mob_read_db_mode_sub(struct mob_db *entry, struct status_data *mstatus, int class_, config_setting_t *t) { +int HP_mob_read_db_mode_sub(struct mob_db *entry, config_setting_t *t) { int hIndex = 0; int retVal___ = 0; if( HPMHooks.count.HP_mob_read_db_mode_sub_pre ) { - int (*preHookFunc) (struct mob_db *entry, struct status_data *mstatus, int *class_, config_setting_t *t); + int (*preHookFunc) (struct mob_db *entry, config_setting_t *t); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_mode_sub_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_mob_read_db_mode_sub_pre[hIndex].func; - retVal___ = preHookFunc(entry, mstatus, &class_, t); + retVal___ = preHookFunc(entry, t); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -46353,25 +46406,25 @@ int HP_mob_read_db_mode_sub(struct mob_db *entry, struct status_data *mstatus, i } } { - retVal___ = HPMHooks.source.mob.read_db_mode_sub(entry, mstatus, class_, t); + retVal___ = HPMHooks.source.mob.read_db_mode_sub(entry, t); } if( HPMHooks.count.HP_mob_read_db_mode_sub_post ) { - int (*postHookFunc) (int retVal___, struct mob_db *entry, struct status_data *mstatus, int *class_, config_setting_t *t); + int (*postHookFunc) (int retVal___, struct mob_db *entry, config_setting_t *t); for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_mode_sub_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_mob_read_db_mode_sub_post[hIndex].func; - retVal___ = postHookFunc(retVal___, entry, mstatus, &class_, t); + retVal___ = postHookFunc(retVal___, entry, t); } } return retVal___; } -void HP_mob_read_db_stats_sub(struct mob_db *entry, struct status_data *mstatus, int class_, config_setting_t *t) { +void HP_mob_read_db_stats_sub(struct mob_db *entry, config_setting_t *t) { int hIndex = 0; if( HPMHooks.count.HP_mob_read_db_stats_sub_pre ) { - void (*preHookFunc) (struct mob_db *entry, struct status_data *mstatus, int *class_, config_setting_t *t); + void (*preHookFunc) (struct mob_db *entry, config_setting_t *t); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_stats_sub_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_mob_read_db_stats_sub_pre[hIndex].func; - preHookFunc(entry, mstatus, &class_, t); + preHookFunc(entry, t); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -46379,13 +46432,13 @@ void HP_mob_read_db_stats_sub(struct mob_db *entry, struct status_data *mstatus, } } { - HPMHooks.source.mob.read_db_stats_sub(entry, mstatus, class_, t); + HPMHooks.source.mob.read_db_stats_sub(entry, t); } if( HPMHooks.count.HP_mob_read_db_stats_sub_post ) { - void (*postHookFunc) (struct mob_db *entry, struct status_data *mstatus, int *class_, config_setting_t *t); + void (*postHookFunc) (struct mob_db *entry, config_setting_t *t); for(hIndex = 0; hIndex < HPMHooks.count.HP_mob_read_db_stats_sub_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_mob_read_db_stats_sub_post[hIndex].func; - postHookFunc(entry, mstatus, &class_, t); + postHookFunc(entry, t); } } return; @@ -57623,6 +57676,33 @@ void HP_pc_update_idle_time(struct map_session_data *sd, enum e_battle_config_id } return; } +int HP_pc_have_magnifier(struct map_session_data *sd) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_pc_have_magnifier_pre ) { + int (*preHookFunc) (struct map_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_have_magnifier_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_pc_have_magnifier_pre[hIndex].func; + retVal___ = preHookFunc(sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.pc.have_magnifier(sd); + } + if( HPMHooks.count.HP_pc_have_magnifier_post ) { + int (*postHookFunc) (int retVal___, struct map_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_have_magnifier_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_pc_have_magnifier_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd); + } + } + return retVal___; +} /* libpcre */ pcre* HP_libpcre_compile(const char *pattern, int options, const char **errptr, int *erroffset, const unsigned char *tableptr) { int hIndex = 0; @@ -57678,15 +57758,15 @@ pcre_extra* HP_libpcre_study(const pcre *code, int options, const char **errptr) } return retVal___; } -int HP_libpcre_exec(const pcre *code, const pcre_extra *extra, const char *subject, int length, int startoffset, int options, int *ovector, int ovecsize) { +int HP_libpcre_exec(const pcre *code, const pcre_extra *extra, PCRE_SPTR subject, int length, int startoffset, int options, int *ovector, int ovecsize) { int hIndex = 0; int retVal___ = 0; if( HPMHooks.count.HP_libpcre_exec_pre ) { - int (*preHookFunc) (const pcre *code, const pcre_extra *extra, const char *subject, int *length, int *startoffset, int *options, int *ovector, int *ovecsize); + int (*preHookFunc) (const pcre *code, const pcre_extra *extra, PCRE_SPTR *subject, int *length, int *startoffset, int *options, int *ovector, int *ovecsize); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_libpcre_exec_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_libpcre_exec_pre[hIndex].func; - retVal___ = preHookFunc(code, extra, subject, &length, &startoffset, &options, ovector, &ovecsize); + retVal___ = preHookFunc(code, extra, &subject, &length, &startoffset, &options, ovector, &ovecsize); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -57697,10 +57777,10 @@ int HP_libpcre_exec(const pcre *code, const pcre_extra *extra, const char *subje retVal___ = HPMHooks.source.libpcre.exec(code, extra, subject, length, startoffset, options, ovector, ovecsize); } if( HPMHooks.count.HP_libpcre_exec_post ) { - int (*postHookFunc) (int retVal___, const pcre *code, const pcre_extra *extra, const char *subject, int *length, int *startoffset, int *options, int *ovector, int *ovecsize); + int (*postHookFunc) (int retVal___, const pcre *code, const pcre_extra *extra, PCRE_SPTR *subject, int *length, int *startoffset, int *options, int *ovector, int *ovecsize); for(hIndex = 0; hIndex < HPMHooks.count.HP_libpcre_exec_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_libpcre_exec_post[hIndex].func; - retVal___ = postHookFunc(retVal___, code, extra, subject, &length, &startoffset, &options, ovector, &ovecsize); + retVal___ = postHookFunc(retVal___, code, extra, &subject, &length, &startoffset, &options, ovector, &ovecsize); } } return retVal___; @@ -61678,6 +61758,32 @@ void HP_script_read_constdb(void) { } return; } +void HP_script_constdb_comment(const char *comment) { + int hIndex = 0; + if( HPMHooks.count.HP_script_constdb_comment_pre ) { + void (*preHookFunc) (const char *comment); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_constdb_comment_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_script_constdb_comment_pre[hIndex].func; + preHookFunc(comment); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.script.constdb_comment(comment); + } + if( HPMHooks.count.HP_script_constdb_comment_post ) { + void (*postHookFunc) (const char *comment); + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_constdb_comment_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_script_constdb_comment_post[hIndex].func; + postHookFunc(comment); + } + } + return; +} const char* HP_script_print_line(StringBuf *buf, const char *p, const char *mark, int line) { int hIndex = 0; const char* retVal___ = NULL; @@ -76297,6 +76403,33 @@ const char* HP_sysinfo_cflags(void) { } return retVal___; } +const char* HP_sysinfo_time(void) { + int hIndex = 0; + const char* retVal___ = NULL; + if( HPMHooks.count.HP_sysinfo_time_pre ) { + const char* (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_sysinfo_time_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_sysinfo_time_pre[hIndex].func; + retVal___ = preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.sysinfo.time(); + } + if( HPMHooks.count.HP_sysinfo_time_post ) { + const char* (*postHookFunc) (const char* retVal___); + for(hIndex = 0; hIndex < HPMHooks.count.HP_sysinfo_time_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_sysinfo_time_post[hIndex].func; + retVal___ = postHookFunc(retVal___); + } + } + return retVal___; +} const char* HP_sysinfo_vcstype(void) { int hIndex = 0; const char* retVal___ = NULL; diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in index 6e8e3bfac..3fe38b6bc 100644 --- a/src/plugins/Makefile.in +++ b/src/plugins/Makefile.in @@ -102,7 +102,7 @@ Makefile: Makefile.in ../../plugins/%@DLLEXT@: %.c $(ALL_H) $$(shell ls %/* 2>/dev/null) @echo " CC $<" - @$(CC) $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @PCRE_CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o $@ $< + @$(CC) $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o $@ $< ../../plugins/HPMHooking_login@DLLEXT@: HPMHOOKINGTYPE = LOGIN ../../plugins/HPMHooking_char@DLLEXT@: HPMHOOKINGTYPE = CHAR @@ -110,4 +110,4 @@ Makefile: Makefile.in ../../plugins/HPMHooking_%@DLLEXT@: HPMHooking.c $(ALL_H) $$(shell ls HPMHooking/*_%* HPMHooking/*_common* 2>/dev/null) @echo " CC $< ($(HPMHOOKINGTYPE))" - @$(CC) -DHPMHOOKING_$(HPMHOOKINGTYPE) $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @PCRE_CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o $@ $< + @$(CC) -DHPMHOOKING_$(HPMHOOKINGTYPE) $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o $@ $< diff --git a/src/plugins/constdb2doc.c b/src/plugins/constdb2doc.c new file mode 100644 index 000000000..1d5f37ad5 --- /dev/null +++ b/src/plugins/constdb2doc.c @@ -0,0 +1,197 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2016 Hercules Dev Team + * Copyright (C) 2016 Haru <haru@dotalux.com> + * + * Hercules is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/// db/constants.conf -> doc/constants.md generator plugin + +#include "common/hercules.h" +//#include "common/memmgr.h" +#include "common/nullpo.h" +#include "common/strlib.h" +#include "map/itemdb.h" +#include "map/mob.h" +#include "map/script.h" +#include "map/skill.h" + +#include "common/HPMDataCheck.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <sys/stat.h> + +#define OUTPUTFILENAME "doc" PATHSEP_STR "constants.md" + +HPExport struct hplugin_info pinfo = { + "constdb2doc", // Plugin name + SERVER_TYPE_MAP, // Which server types this plugin works with? + "0.1", // Plugin version + HPM_VERSION, // HPM Version (don't change, macro is automatically updated) +}; + +FILE *out_fp; +bool torun = false; + +/// To override script_constdb_comment +void constdb2doc_constdb_comment(const char *comment) +{ + nullpo_retv(out_fp); + if (comment == NULL) + fprintf(out_fp, "\n"); + else + fprintf(out_fp, "\n### %s\n\n", comment); +} + +/// To override script_set_constant, called by script_read_constdb +void constdb2doc_script_set_constant(const char *name, int value, bool is_parameter, bool is_deprecated) +{ + nullpo_retv(out_fp); + + if (is_parameter) + fprintf(out_fp, "- `%s`: [param]%s\n", name, is_deprecated ? " **(DEPRECATED)**" : ""); + else + fprintf(out_fp, "- `%s`: %d%s\n", name, value, is_deprecated ? " **(DEPRECATED)**" : ""); +} + +void constdb2doc_constdb(void) +{ + void (*script_set_constant) (const char* name, int value, bool is_parameter, bool is_deprecated) = NULL; + void (*script_constdb_comment) (const char *comment) = NULL; + + nullpo_retv(out_fp); + + /* Link */ + script_set_constant = script->set_constant; + script->set_constant = constdb2doc_script_set_constant; + script_constdb_comment = script->constdb_comment; + script->constdb_comment = constdb2doc_constdb_comment; + + /* Run */ + fprintf(out_fp, "## Constants (db/constants.conf)\n\n"); + script->read_constdb(); + fprintf(out_fp, "\n"); + + fprintf(out_fp, "## Hardcoded Constants (source)\n\n"); + script->hardcoded_constants(); + fprintf(out_fp, "\n"); + + /* Unlink */ + script->set_constant = script_set_constant; + script->constdb_comment = script_constdb_comment; +} + +void constdb2doc_skilldb(void) +{ + int i; + + nullpo_retv(out_fp); + + fprintf(out_fp, "## Skills (db/"DBPATH"skill_db.txt)\n\n"); + for (i = 1; i < MAX_SKILL_DB; i++) { + if (skill->dbs->db[i].name[0] != '\0') + fprintf(out_fp, "- `%s`: %d\n", skill->dbs->db[i].name, skill->dbs->db[i].nameid); + } + fprintf(out_fp, "\n"); +} + +void constdb2doc_mobdb(void) +{ + int i; + + nullpo_retv(out_fp); + + fprintf(out_fp, "## Mobs (db/"DBPATH"mob_db.txt)\n\n"); + for (i = 0; i < MAX_MOB_DB; i++) { + struct mob_db *md = mob->db(i); + if (md == mob->dummy || md->sprite[0] == '\0') + continue; + fprintf(out_fp, "- `%s`: %d\n", md->sprite, i); + } + fprintf(out_fp, "\n"); +} + +/// Cloned from itemdb_search +struct item_data *constdb2doc_itemdb_search(int nameid) +{ + if (nameid >= 0 && nameid < ARRAYLENGTH(itemdb->array)) + return itemdb->array[nameid]; + + return idb_get(itemdb->other, nameid); +} + +void constdb2doc_itemdb(void) +{ + int i; + + nullpo_retv(out_fp); + + fprintf(out_fp, "## Items (db/"DBPATH"item_db.conf)\n"); + for (i = 0; i < ARRAYLENGTH(itemdb->array); i++) { + struct item_data *id = constdb2doc_itemdb_search(i); + if (id == NULL || id->name[0] == '\0') + continue; + fprintf(out_fp, "- `%s`: %d\n", id->name, id->nameid); + } + fprintf(out_fp, "\n"); +} + +void do_constdb2doc(void) +{ + /* File Type Detector */ + if ((out_fp = fopen(OUTPUTFILENAME, "wt+")) == NULL) { + ShowError("do_constdb2doc: Unable to open output file.\n"); + return; + } + + fprintf(out_fp, + "# Constants\n\n" + "> This document contains all the constants available to the script engine.\n\n"); + + constdb2doc_constdb(); + + constdb2doc_skilldb(); + + constdb2doc_mobdb(); + + constdb2doc_itemdb(); + + fprintf(out_fp, "> End of list\n"); + + fclose(out_fp); +} +CPCMD(constdb2doc) { + do_constdb2doc(); +} +CMDLINEARG(constdb2doc) +{ + map->minimal = torun = true; + return true; +} +HPExport void server_preinit(void) { + addArg("--constdb2doc", false, constdb2doc, NULL); +} +HPExport void plugin_init(void) { + addCPCommand("server:tools:constdb2doc", constdb2doc); +} +HPExport void server_online(void) { + if (torun) + do_constdb2doc(); +} diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index 5b5d79bac..44e2bac3c 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -24,12 +24,12 @@ #include "common/conf.h" #include "common/memmgr.h" #include "common/mmo.h" +#include "common/nullpo.h" #include "common/strlib.h" -#include "common/timer.h" -#include "map/clif.h" +#include "map/battle.h" #include "map/itemdb.h" +#include "map/mob.h" #include "map/map.h" -#include "map/pc.h" #include "common/HPMDataCheck.h" @@ -43,38 +43,102 @@ HPExport struct hplugin_info pinfo = { HPM_VERSION, // HPM Version (don't change, macro is automatically updated) }; +#ifdef RENEWAL +#define DBSUFFIX "_re" +#else // not RENEWAL +#define DBSUFFIX "" +#endif + +/// Conversion state tracking. struct { - FILE *fp; + FILE *fp; ///< Currently open file pointer struct { - char *p; - size_t len; - } buf[4]; - char *db_name; + char *p; ///< Buffer pointer + size_t len; ///< Buffer length + } buf[4]; ///< Output buffer + const char *db_name; ///< Database table name } tosql; -bool torun = false; +/// Whether the item_db converter will automatically run. +bool itemdb2sql_torun = false; +/// Whether the mob_db converter will automatically run. +bool mobdb2sql_torun = false; + +/// Backup of the original item_db parser function pointer. int (*itemdb_readdb_libconfig_sub) (config_setting_t *it, int n, const char *source); +/// Backup of the original mob_db parser function pointer. +int (*mob_read_db_sub) (config_setting_t *it, int n, const char *source); -void hstr(const char *str) { - if( strlen(str) > tosql.buf[3].len ) { +/** + * Normalizes and appends a string to the output buffer. + * + * @param str The string to append. + */ +void hstr(const char *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); } safestrncpy(tosql.buf[3].p,str,strlen(str)); normalize_name(tosql.buf[3].p,"\t\n "); } -int db2sql(config_setting_t *entry, int n, const char *source) { + +/** + * Prints a SQL file header for the current item_db file. + */ +void db2sql_fileheader(void) +{ + time_t t = time(NULL); + struct tm *lt = localtime(&t); + int year = lt->tm_year+1900; + + fprintf(tosql.fp, + "-- This file is part of Hercules.\n" + "-- http://herc.ws - http://github.com/HerculesWS/Hercules\n" + "--\n" + "-- Copyright (C) 2013-%d Hercules Dev Team\n" + "--\n" + "-- Hercules is free software: you can redistribute it and/or modify\n" + "-- it under the terms of the GNU General Public License as published by\n" + "-- the Free Software Foundation, either version 3 of the License, or\n" + "-- (at your option) any later version.\n" + "--\n" + "-- This program is distributed in the hope that it will be useful,\n" + "-- but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "-- GNU General Public License for more details.\n" + "--\n" + "-- You should have received a copy of the GNU General Public License\n" + "-- along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n" + + "-- NOTE: This file was auto-generated and should never be manually edited,\n" + "-- as it will get overwritten. If you need to modify this file,\n" + "-- please consider modifying the corresponding .conf file inside\n" + "-- the db folder, and then re-run the db2sql plugin.\n" + "\n", year); +} + +/** + * Converts an Item DB entry to SQL. + * + * @see itemdb_readdb_libconfig_sub. + */ +int itemdb2sql_sub(config_setting_t *entry, int n, const char *source) +{ struct item_data *it = NULL; - if( (it = itemdb->exists(itemdb_readdb_libconfig_sub(entry,n,source))) ) { + if ((it = itemdb->exists(itemdb_readdb_libconfig_sub(entry,n,source)))) { char e_name[ITEM_NAME_LENGTH*2+1]; const char *bonus = NULL; char *str; int i32; - unsigned int ui32; + uint32 ui32; config_setting_t *t = NULL; StringBuf buf; + nullpo_ret(entry); + StrBuf->Init(&buf); // id @@ -92,10 +156,10 @@ int db2sql(config_setting_t *entry, int n, const char *source) { StrBuf->Printf(&buf, "'%u',", it->flag.delay_consume?IT_DELAYCONSUME:it->type); // price_buy - StrBuf->Printf(&buf, "'%u',", it->value_buy); + StrBuf->Printf(&buf, "'%d',", it->value_buy); // price_sell - StrBuf->Printf(&buf, "'%u',", it->value_sell); + StrBuf->Printf(&buf, "'%d',", it->value_sell); // weight StrBuf->Printf(&buf, "'%u',", it->weight); @@ -116,15 +180,15 @@ int db2sql(config_setting_t *entry, int n, const char *source) { StrBuf->Printf(&buf, "'%u',", it->slot); // equip_jobs - if( libconfig->setting_lookup_int(entry, "Job", &i32) ) // This is an unsigned value, do not check for >= 0 - ui32 = (unsigned int)i32; + if (libconfig->setting_lookup_int(entry, "Job", &i32)) // This is an unsigned value, do not check for >= 0 + ui32 = (uint32)i32; else ui32 = UINT_MAX; StrBuf->Printf(&buf, "'%u',", ui32); // equip_upper - if( libconfig->setting_lookup_int(entry, "Upper", &i32) && i32 >= 0 ) - ui32 = (unsigned int)i32; + if (libconfig->setting_lookup_int(entry, "Upper", &i32) && i32 >= 0) + ui32 = (uint32)i32; else ui32 = ITEMUPPER_ALL; StrBuf->Printf(&buf, "'%u',", ui32); @@ -142,7 +206,7 @@ int db2sql(config_setting_t *entry, int n, const char *source) { StrBuf->Printf(&buf, "'%u',", it->elv); // equip_level_max - if( (t = libconfig->setting_get_member(entry, "EquipLv")) && config_setting_is_aggregate(t) && libconfig->setting_length(t) >= 2 ) + if ((t = libconfig->setting_get_member(entry, "EquipLv")) && config_setting_is_aggregate(t) && libconfig->setting_length(t) >= 2) StrBuf->Printf(&buf, "'%u',", it->elvmax); else StrBuf->AppendStr(&buf, "NULL,"); @@ -253,36 +317,15 @@ int db2sql(config_setting_t *entry, int n, const char *source) { return it?it->nameid:0; } -void totable(void) { - time_t t; - struct tm *lt; - t = time(NULL); - lt = localtime(&t); - int year = lt->tm_year+1900; - fprintf(tosql.fp, - "-- This file is part of Hercules.\n" - "-- http://herc.ws - http://github.com/HerculesWS/Hercules\n" - "--\n" - "-- Copyright (C) 2013-%d Hercules Dev Team\n" - "--\n" - "-- Hercules is free software: you can redistribute it and/or modify\n" - "-- it under the terms of the GNU General Public License as published by\n" - "-- the Free Software Foundation, either version 3 of the License, or\n" - "-- (at your option) any later version.\n" - "--\n" - "-- This program is distributed in the hope that it will be useful,\n" - "-- but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "-- GNU General Public License for more details.\n" - "--\n" - "-- You should have received a copy of the GNU General Public License\n" - "-- along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n" - "-- NOTE: This file was auto-generated and should never be manually edited,\n" - "-- as it will get overwritten. If you need to modify this file,\n" - "-- please consider modifying the corresponding .conf file inside\n" - "-- the db folder, and then re-run the db2sql plugin.\n" - "\n" +/** + * Prints a SQL table header for the current item_db table. + */ +void itemdb2sql_tableheader(void) +{ + db2sql_fileheader(); + + fprintf(tosql.fp, "--\n" "-- Table structure for table `%s`\n" "--\n" @@ -326,79 +369,405 @@ void totable(void) { " `unequip_script` text,\n" " PRIMARY KEY (`id`)\n" ") ENGINE=MyISAM;\n" - "\n", year, tosql.db_name,tosql.db_name,tosql.db_name); + "\n", tosql.db_name,tosql.db_name,tosql.db_name); } -void do_db2sql(void) { + +/** + * Item DB Conversion. + * + * Converts Item DB and Item DB2 to SQL scripts. + */ +void do_itemdb2sql(void) +{ + int i; + struct convert_db_files { + const char *name; + const char *source; + const char *destination; + } files[] = { + {"item_db", DBPATH"item_db.conf", "sql-files/item_db" DBSUFFIX ".sql"}, + {"item_db2", "item_db2.conf", "sql-files/item_db2.sql"}, + }; + /* link */ itemdb_readdb_libconfig_sub = itemdb->readdb_libconfig_sub; - itemdb->readdb_libconfig_sub = db2sql; - /* */ + itemdb->readdb_libconfig_sub = itemdb2sql_sub; + + memset(&tosql.buf, 0, sizeof(tosql.buf)); + itemdb->clear(false); + + for (i = 0; i < ARRAYLENGTH(files); i++) { + if ((tosql.fp = fopen(files[i].destination, "wt+")) == NULL) { + ShowError("itemdb_tosql: File not found \"%s\".\n", files[i].destination); + return; + } + + tosql.db_name = files[i].name; + itemdb2sql_tableheader(); + + itemdb->readdb_libconfig(files[i].source); - if ((tosql.fp = fopen("sql-files/item_db_re.sql", "wt+")) == NULL) { - ShowError("itemdb_tosql: File not found \"%s\".\n", "sql-files/item_db_re.sql"); - return; + fclose(tosql.fp); } - tosql.db_name = "item_db"; - totable(); + /* unlink */ + itemdb->readdb_libconfig_sub = itemdb_readdb_libconfig_sub; - memset(&tosql.buf, 0, sizeof(tosql.buf) ); + for (i = 0; i < ARRAYLENGTH(tosql.buf); i++) { + if (tosql.buf[i].p) + aFree(tosql.buf[i].p); + } +} - itemdb->clear(false); - itemdb->readdb_libconfig("re/item_db.conf"); +/** + * Converts a Mob DB entry to SQL. + * + * @see mobdb_readdb_libconfig_sub. + */ +int mobdb2sql_sub(config_setting_t *mobt, int n, const char *source) +{ + struct mob_db *md = NULL; + nullpo_ret(mobt); + + if ((md = mob->db(mob_read_db_sub(mobt, n, source))) != mob->dummy) { + char e_name[NAME_LENGTH*2+1]; + StringBuf buf; + int card_idx = 9, i; + + StrBuf->Init(&buf); + + // id + StrBuf->Printf(&buf, "%u,", md->mob_id); - fclose(tosql.fp); + // Sprite + SQL->EscapeString(NULL, e_name, md->sprite); + StrBuf->Printf(&buf, "'%s',", e_name); + + // kName + SQL->EscapeString(NULL, e_name, md->name); + StrBuf->Printf(&buf, "'%s',", e_name); - if ((tosql.fp = fopen("sql-files/item_db.sql", "wt+")) == NULL) { - ShowError("itemdb_tosql: File not found \"%s\".\n", "sql-files/item_db.sql"); - return; + // iName + SQL->EscapeString(NULL, e_name, md->jname); + StrBuf->Printf(&buf, "'%s',", e_name); + + // LV + StrBuf->Printf(&buf, "%u,", md->lv); + + // HP + StrBuf->Printf(&buf, "%u,", md->status.max_hp); + + // SP + StrBuf->Printf(&buf, "%u,", md->status.max_sp); + + // EXP + StrBuf->Printf(&buf, "%u,", md->base_exp); + + // JEXP + StrBuf->Printf(&buf, "%u,", md->job_exp); + + // Range1 + StrBuf->Printf(&buf, "%u,", md->status.rhw.range); + + // ATK1 + StrBuf->Printf(&buf, "%u,", md->status.rhw.atk); + + // ATK2 + StrBuf->Printf(&buf, "%u,", md->status.rhw.atk2); + + // DEF + StrBuf->Printf(&buf, "%u,", md->status.def); + + // MDEF + StrBuf->Printf(&buf, "%u,", md->status.mdef); + + // STR + StrBuf->Printf(&buf, "%u,", md->status.str); + + // AGI + StrBuf->Printf(&buf, "%u,", md->status.agi); + + // VIT + StrBuf->Printf(&buf, "%u,", md->status.vit); + + // INT + StrBuf->Printf(&buf, "%u,", md->status.int_); + + // DEX + StrBuf->Printf(&buf, "%u,", md->status.dex); + + // LUK + StrBuf->Printf(&buf, "%u,", md->status.luk); + + // Range2 + StrBuf->Printf(&buf, "%u,", md->range2); + + // Range3 + StrBuf->Printf(&buf, "%u,", md->range3); + + // Scale + StrBuf->Printf(&buf, "%u,", md->status.size); + + // Race + StrBuf->Printf(&buf, "%u,", md->status.race); + + // Element + StrBuf->Printf(&buf, "%u,", md->status.def_ele + 20 * md->status.ele_lv); + + // Mode + StrBuf->Printf(&buf, "0x%X,", md->status.mode); + + // Speed + StrBuf->Printf(&buf, "%u,", md->status.speed); + + // aDelay + StrBuf->Printf(&buf, "%u,", md->status.adelay); + + // aMotion + StrBuf->Printf(&buf, "%u,", md->status.amotion); + + // dMotion + StrBuf->Printf(&buf, "%u,", md->status.dmotion); + + // MEXP + StrBuf->Printf(&buf, "%u,", md->mexp); + + for (i = 0; i < 3; i++) { + // MVP{i}id + StrBuf->Printf(&buf, "%u,", md->mvpitem[i].nameid); + // MVP{i}per + StrBuf->Printf(&buf, "%u,", md->mvpitem[i].p); + } + + // Scan for cards + for (i = 0; i < 10; i++) { + struct item_data *it = NULL; + if (md->dropitem[i].nameid != 0 && (it = itemdb->exists(md->dropitem[i].nameid)) != NULL && it->type == IT_CARD) + card_idx = i; + } + + for (i = 0; i < 10; i++) { + if (card_idx == i) + continue; + // Drop{i}id + StrBuf->Printf(&buf, "%u,", md->dropitem[i].nameid); + // Drop{i}per + StrBuf->Printf(&buf, "%u,", md->dropitem[i].p); + } + + // DropCardid + StrBuf->Printf(&buf, "%u,", md->dropitem[card_idx].nameid); + // DropCardper + StrBuf->Printf(&buf, "%u", md->dropitem[card_idx].p); + + fprintf(tosql.fp, "REPLACE INTO `%s` VALUES (%s);\n", tosql.db_name, StrBuf->Value(&buf)); + + StrBuf->Destroy(&buf); } - tosql.db_name = "item_db"; - totable(); + return md ? md->mob_id : 0; +} - itemdb->clear(false); - itemdb->readdb_libconfig("pre-re/item_db.conf"); +/** + * Prints a SQL table header for the current mob_db table. + */ +void mobdb2sql_tableheader(void) +{ + db2sql_fileheader(); + + fprintf(tosql.fp, + "--\n" + "-- Table structure for table `%s`\n" + "--\n" + "\n" + "DROP TABLE IF EXISTS `%s`;\n" + "CREATE TABLE `%s` (\n" + " `ID` MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Sprite` TEXT NOT NULL,\n" + " `kName` TEXT NOT NULL,\n" + " `iName` TEXT NOT NULL,\n" + " `LV` TINYINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `HP` INT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `SP` MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `EXP` MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `JEXP` MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Range1` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',\n" + " `ATK1` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `ATK2` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `DEF` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `MDEF` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `STR` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `AGI` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `VIT` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `INT` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `DEX` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `LUK` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Range2` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Range3` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Scale` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Race` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Element` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Mode` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Speed` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `aDelay` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `aMotion` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `dMotion` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\n" + " `MEXP` MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `MVP1id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `MVP1per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `MVP2id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `MVP2per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `MVP3id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `MVP3per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop1id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop1per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop2id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop2per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop3id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop3per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop4id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop4per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop5id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop5per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop6id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop6per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop7id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop7per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop8id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop8per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop9id` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `Drop9per` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `DropCardid` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " `DropCardper` SMALLINT(9) UNSIGNED NOT NULL DEFAULT '0',\n" + " PRIMARY KEY (`ID`)\n" + ") ENGINE=MyISAM;\n" + "\n", tosql.db_name, tosql.db_name, tosql.db_name); +} - fclose(tosql.fp); +/** + * Mob DB Conversion. + * + * Converts Mob DB and Mob DB2 to SQL scripts. + */ +void do_mobdb2sql(void) +{ + int i; + struct convert_db_files { + const char *name; + const char *source; + const char *destination; + } files[] = { + {"mob_db", DBPATH"mob_db.conf", "sql-files/mob_db" DBSUFFIX ".sql"}, + {"mob_db2", "mob_db2.conf", "sql-files/mob_db2.sql"}, + }; + + /* link */ + mob_read_db_sub = mob->read_db_sub; + mob->read_db_sub = mobdb2sql_sub; - if ((tosql.fp = fopen("sql-files/item_db2.sql", "wt+")) == NULL) { - ShowError("itemdb_tosql: File not found \"%s\".\n", "sql-files/item_db2.sql"); - return; + if (map->minimal) { + // Set up modifiers + battle->config_set_defaults(); } - tosql.db_name = "item_db2"; - totable(); + memset(&tosql.buf, 0, sizeof(tosql.buf)); + for (i = 0; i < ARRAYLENGTH(files); i++) { + if ((tosql.fp = fopen(files[i].destination, "wt+")) == NULL) { + ShowError("mobdb_tosql: File not found \"%s\".\n", files[i].destination); + return; + } - itemdb->clear(false); - itemdb->readdb_libconfig("item_db2.conf"); + tosql.db_name = files[i].name; + mobdb2sql_tableheader(); - fclose(tosql.fp); + mob->read_libconfig(files[i].source, false); + + fclose(tosql.fp); + } /* unlink */ - itemdb->readdb_libconfig_sub = itemdb_readdb_libconfig_sub; + mob->read_db_sub = mob_read_db_sub; + + for (i = 0; i < ARRAYLENGTH(tosql.buf); i++) { + if (tosql.buf[i].p) + aFree(tosql.buf[i].p); + } +} + +/** + * Console command db2sql. + */ +CPCMD(db2sql) +{ + do_itemdb2sql(); + do_mobdb2sql(); +} - if( tosql.buf[0].p ) aFree(tosql.buf[0].p); - if( tosql.buf[1].p ) aFree(tosql.buf[1].p); - if( tosql.buf[2].p ) aFree(tosql.buf[2].p); - if( tosql.buf[3].p ) aFree(tosql.buf[3].p); +/** + * Console command itemdb2sql. + */ +CPCMD(itemdb2sql) +{ + do_itemdb2sql(); } -CPCMD(db2sql) { - do_db2sql(); + +/** + * Console command mobdb2sql. + */ +CPCMD(mobdb2sql) +{ + do_mobdb2sql(); } + +/** + * Command line argument handler for --db2sql + */ CMDLINEARG(db2sql) { - map->minimal = torun = true; + map->minimal = true; + itemdb2sql_torun = true; + mobdb2sql_torun = true; return true; } -HPExport void server_preinit(void) { - addArg("--db2sql",false,db2sql,NULL); +/** + * Command line argument handler for --itemdb2sql + */ +CMDLINEARG(itemdb2sql) +{ + map->minimal = true; + itemdb2sql_torun = true; + return true; } -HPExport void plugin_init(void) { - addCPCommand("server:tools:db2sql",db2sql); + +/** + * Command line argument handler for --mobdb2sql + */ +CMDLINEARG(mobdb2sql) +{ + map->minimal = true; + mobdb2sql_torun = true; + return true; +} + +HPExport void server_preinit(void) +{ + addArg("--db2sql", false, db2sql, NULL); + addArg("--itemdb2sql", false, itemdb2sql, NULL); + addArg("--mobdb2sql", false, mobdb2sql, NULL); +} + +HPExport void plugin_init(void) +{ + addCPCommand("server:tools:db2sql", db2sql); + addCPCommand("server:tools:itemdb2sql", itemdb2sql); + addCPCommand("server:tools:mobdb2sql", mobdb2sql); } -HPExport void server_online(void) { - if( torun ) - do_db2sql(); + +HPExport void server_online(void) +{ + if (itemdb2sql_torun) + do_itemdb2sql(); + if (mobdb2sql_torun) + do_mobdb2sql(); } |