diff options
author | Haru <haru@dotalux.com> | 2015-08-11 02:17:37 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2015-08-13 17:16:27 +0200 |
commit | 959c8a772fe4cb775facfe904d243d644e394bf1 (patch) | |
tree | fe0a6fe70527d3cf14c051c7879cad2027617328 | |
parent | 6b6419014b8ba351feaf62452b9e8bb0e983eacd (diff) | |
download | hercules-959c8a772fe4cb775facfe904d243d644e394bf1.tar.gz hercules-959c8a772fe4cb775facfe904d243d644e394bf1.tar.bz2 hercules-959c8a772fe4cb775facfe904d243d644e394bf1.tar.xz hercules-959c8a772fe4cb775facfe904d243d644e394bf1.zip |
Automatic HPM symbol sharing
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r-- | src/char/HPMchar.c | 1 | ||||
-rw-r--r-- | src/char/char.c | 21 | ||||
-rw-r--r-- | src/common/HPM.c | 38 | ||||
-rw-r--r-- | src/common/HPM.h | 2 | ||||
-rw-r--r-- | src/common/HPMi.h | 4 | ||||
-rw-r--r-- | src/login/HPMlogin.c | 1 | ||||
-rw-r--r-- | src/login/login.c | 6 | ||||
-rw-r--r-- | src/map/HPMmap.c | 1 | ||||
-rw-r--r-- | src/map/map.c | 49 | ||||
-rw-r--r-- | tools/HPMHookGen/HPMDataCheckGen.pl | 7 |
10 files changed, 11 insertions, 119 deletions
diff --git a/src/char/HPMchar.c b/src/char/HPMchar.c index 3e8470e9b..a67f017c1 100644 --- a/src/char/HPMchar.c +++ b/src/char/HPMchar.c @@ -62,6 +62,7 @@ void HPM_char_plugin_load_sub(struct hplugin *plugin) { void HPM_char_do_init(void) { HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer); + HPM_shared_symbols(SERVER_TYPE_CHAR); } void HPM_char_do_final(void) { diff --git a/src/char/char.c b/src/char/char.c index 625103b71..576eb9630 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -5806,26 +5806,6 @@ void do_shutdown(void) } } -void char_hp_symbols(void) { - HPM->share(mapindex,"mapindex"); - HPM->share(chr, "chr"); - HPM->share(geoip, "geoip"); - HPM->share(inter_auction, "inter_auction"); - HPM->share(inter_elemental, "inter_elemental"); - HPM->share(inter_guild, "inter_guild"); - HPM->share(inter_homunculus, "inter_homunculus"); - HPM->share(inter_mail, "inter_mail"); - HPM->share(inter_mercenary, "inter_mercenary"); - HPM->share(inter_party, "inter_party"); - HPM->share(inter_pet, "inter_pet"); - HPM->share(inter_quest, "inter_quest"); - HPM->share(inter_storage, "inter_storage"); - HPM->share(inter, "inter"); - HPM->share(loginif, "loginif"); - HPM->share(mapif, "mapif"); - HPM->share(pincode, "pincode"); -} - /** * --char-config handler * @@ -5887,7 +5867,6 @@ int do_init(int argc, char **argv) { chr->server[i].map = NULL; HPM_char_do_init(); - HPM->symbol_defaults_sub = char_hp_symbols; cmdline->exec(argc, argv, CMDLINE_OPT_PREINIT); HPM->config_read(); HPM->event(HPET_PRE_INIT); diff --git a/src/common/HPM.c b/src/common/HPM.c index dcca6ae4c..a78f03daa 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -533,9 +533,6 @@ void hplugins_config_read(void) { if (libconfig->read_file(&plugins_conf, config_filename)) return; - if( HPM->symbol_defaults_sub ) - HPM->symbol_defaults_sub(); - plist = libconfig->lookup(&plugins_conf, "plugins_list"); for (i = 0; i < HPM->cmdline_plugins_count; i++) { config_setting_t *entry = libconfig->setting_add(plist, NULL, CONFIG_TYPE_STRING); @@ -748,37 +745,6 @@ void HPM_datacheck_final(void) { db_destroy(datacheck_db); } -void hplugins_share_defaults(void) { - /* core */ - HPM->share(core,"core"); - HPM->share(HPMiMalloc, "iMalloc"); - HPM->share(cmdline,"cmdline"); - /* console */ - HPM->share(console,"console"); - /* db */ - HPM->share(DB, "DB"); - /* nullpo */ - HPM->share(nullpo,"nullpo"); - /* showmsg */ - HPM->share(showmsg,"showmsg"); - /* socket */ - HPM->share(sockt,"sockt"); - /* strlib */ - HPM->share(strlib,"strlib"); - HPM->share(sv,"sv"); - HPM->share(StrBuf,"StrBuf"); - /* sql */ - HPM->share(SQL,"SQL"); - /* timer */ - HPM->share(timer,"timer"); - /* libconfig */ - HPM->share(libconfig,"libconfig"); - /* sysinfo */ - HPM->share(sysinfo,"sysinfo"); - /* utils */ - HPM->share(HCache,"HCache"); -} - void hpm_init(void) { unsigned int i; datacheck_db = NULL; @@ -810,8 +776,6 @@ void hpm_init(void) { HPM->packetsc[i] = 0; } - HPM->symbol_defaults(); - #ifdef CONSOLE_INPUT console->input->addCommand("plugins",CPCMD_A(plugins)); #endif @@ -906,9 +870,7 @@ void hpm_defaults(void) { HPM->iscompatible = hplugin_iscompatible; HPM->import_symbol = hplugin_import_symbol; HPM->share = hplugin_export_symbol; - HPM->symbol_defaults = hplugins_share_defaults; HPM->config_read = hplugins_config_read; - HPM->symbol_defaults_sub = NULL; HPM->pid2name = hplugins_id2name; HPM->parse_packets = hplugins_parse_packets; HPM->load_sub = NULL; diff --git a/src/common/HPM.h b/src/common/HPM.h index 2d38a2bfa..c13132cfc 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -129,9 +129,7 @@ struct HPM_interface { void (*event) (enum hp_event_types type); void *(*import_symbol) (char *name, unsigned int pID); void (*share) (void *, char *); - void (*symbol_defaults) (void); void (*config_read) (void); - void (*symbol_defaults_sub) (void);//TODO drop char *(*pid2name) (unsigned int pid); unsigned char (*parse_packets) (int fd, enum HPluginPacketHookingPoints point); void (*load_sub) (struct hplugin *plugin); diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 6f97659f9..bd8d8fe64 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -218,7 +218,9 @@ struct HPMi_interface { Sql *sql_handle; }; -#ifndef HERCULES_CORE +#ifdef HERCULES_CORE +#define HPM_SYMBOL(n, s) (HPM->share((s), (n)), true) +#else // ! HERCULES_CORE HPExport struct HPMi_interface HPMi_s; HPExport struct HPMi_interface *HPMi; HPExport void *(*import_symbol) (char *name, unsigned int pID); diff --git a/src/login/HPMlogin.c b/src/login/HPMlogin.c index b1c097a52..895cbad16 100644 --- a/src/login/HPMlogin.c +++ b/src/login/HPMlogin.c @@ -47,6 +47,7 @@ void HPM_login_plugin_load_sub(struct hplugin *plugin) { void HPM_login_do_init(void) { HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer); + HPM_shared_symbols(SERVER_TYPE_LOGIN); } void HPM_login_do_final(void) { diff --git a/src/login/login.c b/src/login/login.c index cf27fe71a..572bd594f 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1918,11 +1918,6 @@ void do_shutdown_login(void) } } -void login_hp_symbols(void) { - HPM->share(account_db_sql_up(accounts),"sql_handle"); - HPM->share(login,"login"); -} - /** * --login-config handler * @@ -1980,7 +1975,6 @@ int do_init(int argc, char** argv) login->NET_CONF_NAME = aStrdup("conf/network.conf"); HPM_login_do_init(); - HPM->symbol_defaults_sub = login_hp_symbols; cmdline->exec(argc, argv, CMDLINE_OPT_PREINIT); HPM->config_read(); HPM->event(HPET_PRE_INIT); diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index a974f60ce..a59fbb6ef 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -186,6 +186,7 @@ void HPM_map_do_init(void) { HPM->load_sub = HPM_map_plugin_load_sub; HPM->grabHPDataSub = HPM_map_grabHPData; HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer); + HPM_shared_symbols(SERVER_TYPE_MAP); } void HPM_map_do_final(void) { diff --git a/src/map/map.c b/src/map/map.c index e05e77f46..a7b171ddf 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5615,54 +5615,6 @@ void map_cp_defaults(void) { console->input->addCommand("gm:use",CPCMD_A(gm_use)); #endif } -/* Hercules Plugin Mananger */ -void map_hp_symbols(void) { - /* full interfaces */ - HPM->share(atcommand,"atcommand"); - HPM->share(battle,"battle"); - HPM->share(bg,"battlegrounds"); - HPM->share(buyingstore,"buyingstore"); - HPM->share(channel,"channel"); - HPM->share(clif,"clif"); - HPM->share(chrif,"chrif"); - HPM->share(guild,"guild"); - HPM->share(gstorage,"gstorage"); - HPM->share(homun,"homun"); - HPM->share(map,"map"); - HPM->share(ircbot,"ircbot"); - HPM->share(itemdb,"itemdb"); - HPM->share(logs,"logs"); - HPM->share(mail,"mail"); - HPM->share(instance,"instance"); - HPM->share(script,"script"); - HPM->share(searchstore,"searchstore"); - HPM->share(skill,"skill"); - HPM->share(vending,"vending"); - HPM->share(pc,"pc"); - HPM->share(pcg,"pc_groups"); - HPM->share(party,"party"); - HPM->share(storage,"storage"); - HPM->share(trade,"trade"); - HPM->share(status,"status"); - HPM->share(chat, "chat"); - HPM->share(duel,"duel"); - HPM->share(elemental,"elemental"); - HPM->share(intif,"intif"); - HPM->share(mercenary,"mercenary"); - HPM->share(mob,"mob"); - HPM->share(unit,"unit"); - HPM->share(npc,"npc"); - HPM->share(mapreg,"mapreg"); - HPM->share(pet,"pet"); - HPM->share(path,"path"); - HPM->share(quest,"quest"); -#ifdef PCRE_SUPPORT - HPM->share(npc_chat,"npc_chat"); - HPM->share(libpcre,"libpcre"); -#endif - HPM->share(mapit,"mapit"); - HPM->share(mapindex,"mapindex"); -} void map_load_defaults(void) { mapindex_defaults(); @@ -5899,7 +5851,6 @@ int do_init(int argc, char *argv[]) map->GRF_PATH_FILENAME = aStrdup("conf/grf-files.txt"); HPM_map_do_init(); - HPM->symbol_defaults_sub = map_hp_symbols; cmdline->exec(argc, argv, CMDLINE_OPT_PREINIT); HPM->config_read(); diff --git a/tools/HPMHookGen/HPMDataCheckGen.pl b/tools/HPMHookGen/HPMDataCheckGen.pl index 48596eef5..66ce7a4f6 100644 --- a/tools/HPMHookGen/HPMDataCheckGen.pl +++ b/tools/HPMHookGen/HPMDataCheckGen.pl @@ -58,13 +58,16 @@ print FH <<"EOF"; #ifndef HPM_DATA_CHECK_H #define HPM_DATA_CHECK_H -#if !defined(HERCULES_CORE) && !defined(HPMHOOKGEN) +#if !defined(HPMHOOKGEN) HPExport const char *HPM_shared_symbols(int server_type) { #include "common/HPMSymbols.inc.h" return NULL; } -#endif // ! HERCULES_CORE && ! HPMHOOKGEN +#endif // ! HPMHOOKGEN +#ifdef HPM_SYMBOL +#undef HPM_SYMBOL +#endif // HPM_SYMBOL HPExport const struct s_HPMDataCheck HPMDataCheck[] = { EOF |