diff options
Diffstat (limited to 'src')
147 files changed, 501 insertions, 439 deletions
diff --git a/src/char/char.c b/src/char/char.c index 3e24ceae0..4741c3115 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -87,6 +87,7 @@ char char_reg_str_db[32] = "char_reg_str_db"; char char_reg_num_db[32] = "char_reg_num_db"; struct char_interface char_s; +struct char_interface *chr; // show loading/saving messages int save_log = 1; diff --git a/src/char/char.h b/src/char/char.h index 1f5df2750..e79cc1898 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -5,7 +5,7 @@ #ifndef CHAR_CHAR_H #define CHAR_CHAR_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/core.h" // CORE_ST_LAST #include "common/db.h" #include "common/mmo.h" @@ -64,57 +64,6 @@ enum { TABLE_GUILD_STORAGE, }; -#ifdef HERCULES_CORE -extern int char_name_option; -extern char char_name_letters[]; -extern bool char_gm_read; -extern int autosave_interval; -extern int save_log; -extern char db_path[]; -extern char char_db[256]; -extern char scdata_db[256]; -extern char cart_db[256]; -extern char inventory_db[256]; -extern char charlog_db[256]; -extern char storage_db[256]; -extern char interlog_db[256]; -extern char skill_db[256]; -extern char memo_db[256]; -extern char guild_db[256]; -extern char guild_alliance_db[256]; -extern char guild_castle_db[256]; -extern char guild_expulsion_db[256]; -extern char guild_member_db[256]; -extern char guild_position_db[256]; -extern char guild_skill_db[256]; -extern char guild_storage_db[256]; -extern char party_db[256]; -extern char pet_db[256]; -extern char mail_db[256]; -extern char auction_db[256]; -extern char quest_db[256]; -extern char homunculus_db[256]; -extern char skill_homunculus_db[256]; -extern char mercenary_db[256]; -extern char mercenary_owner_db[256]; -extern char ragsrvinfo_db[256]; -extern char elemental_db[256]; -extern char acc_reg_num_db[32]; -extern char acc_reg_str_db[32]; -extern char char_reg_str_db[32]; -extern char char_reg_num_db[32]; - -extern int db_use_sql_item_db; -extern int db_use_sql_mob_db; -extern int db_use_sql_mob_skill_db; - -extern int guild_exp_rate; -extern int log_inter; - -void char_load_defaults(); -void char_defaults(); -#endif // HERCULES_CORE - struct char_auth_node { int account_id; int char_id; @@ -310,6 +259,57 @@ struct char_interface { int (*config_read) (const char* cfgName); }; -struct char_interface *chr; +#ifdef HERCULES_CORE +extern int char_name_option; +extern char char_name_letters[]; +extern bool char_gm_read; +extern int autosave_interval; +extern int save_log; +extern char db_path[]; +extern char char_db[256]; +extern char scdata_db[256]; +extern char cart_db[256]; +extern char inventory_db[256]; +extern char charlog_db[256]; +extern char storage_db[256]; +extern char interlog_db[256]; +extern char skill_db[256]; +extern char memo_db[256]; +extern char guild_db[256]; +extern char guild_alliance_db[256]; +extern char guild_castle_db[256]; +extern char guild_expulsion_db[256]; +extern char guild_member_db[256]; +extern char guild_position_db[256]; +extern char guild_skill_db[256]; +extern char guild_storage_db[256]; +extern char party_db[256]; +extern char pet_db[256]; +extern char mail_db[256]; +extern char auction_db[256]; +extern char quest_db[256]; +extern char homunculus_db[256]; +extern char skill_homunculus_db[256]; +extern char mercenary_db[256]; +extern char mercenary_owner_db[256]; +extern char ragsrvinfo_db[256]; +extern char elemental_db[256]; +extern char acc_reg_num_db[32]; +extern char acc_reg_str_db[32]; +extern char char_reg_str_db[32]; +extern char char_reg_num_db[32]; + +extern int db_use_sql_item_db; +extern int db_use_sql_mob_db; +extern int db_use_sql_mob_skill_db; + +extern int guild_exp_rate; +extern int log_inter; + +void char_load_defaults(); +void char_defaults(); +#endif // HERCULES_CORE + +HPShared struct char_interface *chr; #endif /* CHAR_CHAR_H */ diff --git a/src/char/geoip.c b/src/char/geoip.c index 8c415b6bf..65bb2bdd4 100644 --- a/src/char/geoip.c +++ b/src/char/geoip.c @@ -17,6 +17,7 @@ struct s_geoip geoip_data; struct geoip_interface geoip_s; +struct geoip_interface *geoip; /* [Dekamaster/Nightroad] */ #define GEOIP_MAX_COUNTRIES 255 diff --git a/src/char/geoip.h b/src/char/geoip.h index 4d39011aa..5a6abf68a 100644 --- a/src/char/geoip.h +++ b/src/char/geoip.h @@ -5,7 +5,7 @@ #ifndef CHAR_GEOIP_H #define CHAR_GEOIP_H -#include "common/cbasetypes.h" +#include "common/hercules.h" /** * GeoIP information @@ -26,10 +26,10 @@ struct geoip_interface { void (*init) (void); }; -struct geoip_interface *geoip; - #ifdef HERCULES_CORE void geoip_defaults(void); #endif // HERCULES_CORE +HPShared struct geoip_interface *geoip; + #endif /* CHAR_GEOIP_H */ diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 8d51777fb..67c83ca22 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -25,6 +25,7 @@ #include <stdlib.h> struct inter_auction_interface inter_auction_s; +struct inter_auction_interface *inter_auction; static int inter_auction_count(int char_id, bool buy) { diff --git a/src/char/int_auction.h b/src/char/int_auction.h index 610042b9a..37fd48264 100644 --- a/src/char/int_auction.h +++ b/src/char/int_auction.h @@ -4,13 +4,10 @@ #ifndef CHAR_INT_AUCTION_H #define CHAR_INT_AUCTION_H +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" -#ifdef HERCULES_CORE -void inter_auction_defaults(void); -#endif // HERCULES_CORE - /** * inter_auction_interface interface **/ @@ -27,6 +24,10 @@ struct inter_auction_interface { void (*sql_final) (void); }; -struct inter_auction_interface *inter_auction; +#ifdef HERCULES_CORE +void inter_auction_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_auction_interface *inter_auction; #endif /* CHAR_INT_AUCTION_H */ diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index eff84c57d..e7708179a 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -22,6 +22,7 @@ #include <stdlib.h> struct inter_elemental_interface inter_elemental_s; +struct inter_elemental_interface *inter_elemental; bool mapif_elemental_save(struct s_elemental* ele) { bool flag = true; diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index 7385fc496..0fae74cd0 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -4,11 +4,7 @@ #ifndef CHAR_INT_ELEMENTAL_H #define CHAR_INT_ELEMENTAL_H -#include "common/cbasetypes.h" - -#ifdef HERCULES_CORE -void inter_elemental_defaults(void); -#endif // HERCULES_CORE +#include "common/hercules.h" /** * inter_elemental_interface interface @@ -19,6 +15,10 @@ struct inter_elemental_interface { int (*parse_frommap) (int fd); }; -struct inter_elemental_interface *inter_elemental; +#ifdef HERCULES_CORE +void inter_elemental_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_elemental_interface *inter_elemental; #endif /* CHAR_INT_ELEMENTAL_H */ diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 24561fe21..54355161d 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -35,6 +35,7 @@ #define GUILD_ALLIANCE_REMOVE 0x08 struct inter_guild_interface inter_guild_s; +struct inter_guild_interface *inter_guild; static const char dataToHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; diff --git a/src/char/int_guild.h b/src/char/int_guild.h index eb4c930fc..7a5ed3aae 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -23,10 +23,6 @@ enum { GS_REMOVE = 0x8000, }; -#ifdef HERCULES_CORE -void inter_guild_defaults(void); -#endif // HERCULES_CORE - /** * inter_guild interface **/ @@ -59,6 +55,10 @@ struct inter_guild_interface { int (*broken) (int guild_id); }; -struct inter_guild_interface *inter_guild; +#ifdef HERCULES_CORE +void inter_guild_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_guild_interface *inter_guild; #endif /* CHAR_INT_GUILD_H */ diff --git a/src/char/int_homun.c b/src/char/int_homun.c index eda2afe69..be72ecd58 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -22,6 +22,7 @@ #include <stdlib.h> struct inter_homunculus_interface inter_homunculus_s; +struct inter_homunculus_interface *inter_homunculus; int inter_homunculus_sql_init(void) { diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 113c6d340..d5a35283f 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -4,13 +4,7 @@ #ifndef CHAR_INT_HOMUN_H #define CHAR_INT_HOMUN_H -#include "common/cbasetypes.h" - -struct s_homunculus; - -#ifdef HERCULES_CORE -void inter_homunculus_defaults(void); -#endif // HERCULES_CORE +#include "common/hercules.h" /** * inter_homunculus interface @@ -21,6 +15,10 @@ struct inter_homunculus_interface { int (*parse_frommap) (int fd); }; -struct inter_homunculus_interface *inter_homunculus; +#ifdef HERCULES_CORE +void inter_homunculus_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_homunculus_interface *inter_homunculus; #endif /* CHAR_INT_HOMUN_H */ diff --git a/src/char/int_mail.c b/src/char/int_mail.c index d4bfe14e4..854fe31b1 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -22,6 +22,7 @@ #include <stdlib.h> struct inter_mail_interface inter_mail_s; +struct inter_mail_interface *inter_mail; static int inter_mail_fromsql(int char_id, struct mail_data* md) { diff --git a/src/char/int_mail.h b/src/char/int_mail.h index 8e6acf846..d15b264b5 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -4,16 +4,12 @@ #ifndef CHAR_INT_MAIL_H #define CHAR_INT_MAIL_H -#include "common/cbasetypes.h" +#include "common/hercules.h" struct item; struct mail_data; struct mail_message; -#ifdef HERCULES_CORE -void inter_mail_defaults(void); -#endif // HERCULES_CORE - /** * inter_mail interface **/ @@ -28,6 +24,10 @@ struct inter_mail_interface { void (*sendmail) (int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); }; -struct inter_mail_interface *inter_mail; +#ifdef HERCULES_CORE +void inter_mail_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_mail_interface *inter_mail; #endif /* CHAR_INT_MAIL_H */ diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index 02082aa13..dd40a0224 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -23,6 +23,7 @@ #include <stdlib.h> struct inter_mercenary_interface inter_mercenary_s; +struct inter_mercenary_interface *inter_mercenary; bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) { diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index 632a9ab37..0d52b02e1 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -4,14 +4,10 @@ #ifndef CHAR_INT_MERCENARY_H #define CHAR_INT_MERCENARY_H -#include "common/cbasetypes.h" +#include "common/hercules.h" struct mmo_charstatus; -#ifdef HERCULES_CORE -void inter_mercenary_defaults(void); -#endif // HERCULES_CORE - /** * inter_mercenary interface **/ @@ -24,6 +20,10 @@ struct inter_mercenary_interface { int (*parse_frommap) (int fd); }; -struct inter_mercenary_interface *inter_mercenary; +#ifdef HERCULES_CORE +void inter_mercenary_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_mercenary_interface *inter_mercenary; #endif /* CHAR_INT_MERCENARY_H */ diff --git a/src/char/int_party.c b/src/char/int_party.c index 3b857318c..aedcb8535 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -24,6 +24,7 @@ #include <stdlib.h> struct inter_party_interface inter_party_s; +struct inter_party_interface *inter_party; //Updates party's level range and unsets even share if broken. static int inter_party_check_lv(struct party_data *p) { diff --git a/src/char/int_party.h b/src/char/int_party.h index 99ee5b13e..af3877549 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -4,6 +4,7 @@ #ifndef CHAR_INT_PARTY_H #define CHAR_INT_PARTY_H +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" @@ -24,10 +25,6 @@ struct party_data { unsigned char size; //Total size of party. }; -#ifdef HERCULES_CORE -void inter_party_defaults(void); -#endif // HERCULES_CORE - /** * inter_party interface **/ @@ -49,6 +46,10 @@ struct inter_party_interface { int (*CharOffline) (int char_id, int party_id); }; -struct inter_party_interface *inter_party; +#ifdef HERCULES_CORE +void inter_party_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_party_interface *inter_party; #endif /* CHAR_INT_PARTY_H */ diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 22fe2dcc2..97b2fb6a4 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -22,6 +22,7 @@ #include <stdlib.h> struct inter_pet_interface inter_pet_s; +struct inter_pet_interface *inter_pet; //--------------------------------------------------------- int inter_pet_tosql(int pet_id, struct s_pet* p) diff --git a/src/char/int_pet.h b/src/char/int_pet.h index 69e440781..213c377ee 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -4,11 +4,9 @@ #ifndef CHAR_INT_PET_H #define CHAR_INT_PET_H -struct s_pet; +#include "common/hercules.h" -#ifdef HERCULES_CORE -void inter_pet_defaults(void); -#endif // HERCULES_CORE +struct s_pet; /** * inter_pet interface @@ -23,6 +21,10 @@ struct inter_pet_interface { int (*parse_frommap) (int fd); }; -struct inter_pet_interface *inter_pet; +#ifdef HERCULES_CORE +void inter_pet_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_pet_interface *inter_pet; #endif /* CHAR_INT_PET_H */ diff --git a/src/char/int_quest.c b/src/char/int_quest.c index cf9b9c172..fcd56230b 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -22,6 +22,7 @@ #include <stdlib.h> struct inter_quest_interface inter_quest_s; +struct inter_quest_interface *inter_quest; /** * Loads the entire questlog for a character. diff --git a/src/char/int_quest.h b/src/char/int_quest.h index ee04388fc..c2393d103 100644 --- a/src/char/int_quest.h +++ b/src/char/int_quest.h @@ -4,9 +4,7 @@ #ifndef CHAR_INT_QUEST_H #define CHAR_INT_QUEST_H -#ifdef HERCULES_CORE -void inter_quest_defaults(void); -#endif // HERCULES_CORE +#include "common/hercules.h" /** * inter_quest interface @@ -15,7 +13,11 @@ struct inter_quest_interface { int (*parse_frommap) (int fd); }; -struct inter_quest_interface *inter_quest; +#ifdef HERCULES_CORE +void inter_quest_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_quest_interface *inter_quest; #endif /* CHAR_INT_QUEST_H */ diff --git a/src/char/int_storage.c b/src/char/int_storage.c index a12d9fe17..3a8a6a169 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -24,6 +24,7 @@ #define STORAGE_MEMINC 16 struct inter_storage_interface inter_storage_s; +struct inter_storage_interface *inter_storage; /// Save storage data to sql int inter_storage_tosql(int account_id, struct storage_data* p) diff --git a/src/char/int_storage.h b/src/char/int_storage.h index 11a16de83..f02decf49 100644 --- a/src/char/int_storage.h +++ b/src/char/int_storage.h @@ -4,13 +4,11 @@ #ifndef CHAR_INT_STORAGE_H #define CHAR_INT_STORAGE_H +#include "common/hercules.h" + struct storage_data; struct guild_storage; -#ifdef HERCULES_CORE -void inter_storage_defaults(void); -#endif // HERCULES_CORE - /** * inter_storage interface **/ @@ -26,6 +24,10 @@ struct inter_storage_interface { int (*parse_frommap) (int fd); }; -struct inter_storage_interface *inter_storage; +#ifdef HERCULES_CORE +void inter_storage_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_storage_interface *inter_storage; #endif /* CHAR_INT_STORAGE_H */ diff --git a/src/char/inter.c b/src/char/inter.c index eceb649f3..548b24ee8 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -36,6 +36,7 @@ #define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis struct inter_interface inter_s; +struct inter_interface *inter; int char_server_port = 3306; char char_server_ip[32] = "127.0.0.1"; diff --git a/src/char/inter.h b/src/char/inter.h index 2e89a685b..743f7e2f1 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -5,20 +5,12 @@ #ifndef CHAR_INTER_H #define CHAR_INTER_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/sql.h" #include <stdarg.h> -struct accreg; - -#ifdef HERCULES_CORE -extern unsigned int party_share_level; - -void inter_defaults(void); -#endif // HERCULES_CORE - /** * inter interface **/ @@ -44,6 +36,12 @@ struct inter_interface { void (*final) (void); }; -struct inter_interface *inter; +#ifdef HERCULES_CORE +extern unsigned int party_share_level; + +void inter_defaults(void); +#endif // HERCULES_CORE + +HPShared struct inter_interface *inter; #endif /* CHAR_INTER_H */ diff --git a/src/char/loginif.c b/src/char/loginif.c index 4eac78774..d55701aaa 100644 --- a/src/char/loginif.c +++ b/src/char/loginif.c @@ -20,6 +20,7 @@ #include <string.h> struct loginif_interface loginif_s; +struct loginif_interface *loginif; /// Resets all the data. void loginif_reset(void) diff --git a/src/char/loginif.h b/src/char/loginif.h index 548eaff02..44cf1ebf6 100644 --- a/src/char/loginif.h +++ b/src/char/loginif.h @@ -5,7 +5,7 @@ #ifndef CHAR_LOGINIF_H #define CHAR_LOGINIF_H -#include "common/cbasetypes.h" +#include "common/hercules.h" struct char_session_data; @@ -28,10 +28,10 @@ struct loginif_interface { void (*connect_to_server) (void); }; -struct loginif_interface *loginif; - #ifdef HERCULES_CORE void loginif_defaults(void); #endif // HERCULES_CORE +HPShared struct loginif_interface *loginif; + #endif /* CHAR_LOGINIF_H */ diff --git a/src/char/mapif.c b/src/char/mapif.c index 92506cd49..eb5a6690a 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -189,6 +189,7 @@ void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int fla int mapif_parse_NameChangeRequest(int fd); struct mapif_interface mapif_s; +struct mapif_interface *mapif; void mapif_defaults(void) { mapif = &mapif_s; diff --git a/src/char/mapif.h b/src/char/mapif.h index 6b015d155..a986cd46f 100644 --- a/src/char/mapif.h +++ b/src/char/mapif.h @@ -5,7 +5,7 @@ #ifndef CHAR_MAPIF_H #define CHAR_MAPIF_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" struct WisData; @@ -184,10 +184,10 @@ struct mapif_interface { int (*parse_NameChangeRequest) (int fd); }; -struct mapif_interface *mapif; - #ifdef HERCULES_CORE void mapif_defaults(void); #endif // HERCULES_CORE +HPShared struct mapif_interface *mapif; + #endif /* CHAR_MAPIF_H */ diff --git a/src/char/pincode.c b/src/char/pincode.c index 5085349cc..f5992de83 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -19,6 +19,7 @@ #include <stdlib.h> struct pincode_interface pincode_s; +struct pincode_interface *pincode; void pincode_handle (int fd, struct char_session_data* sd) { struct online_char_data* character; diff --git a/src/char/pincode.h b/src/char/pincode.h index 01f6c7bf9..3cda11768 100644 --- a/src/char/pincode.h +++ b/src/char/pincode.h @@ -5,7 +5,7 @@ #ifndef CHAR_PINCODE_H #define CHAR_PINCODE_H -#include "common/cbasetypes.h" +#include "common/hercules.h" struct char_session_data; @@ -42,10 +42,10 @@ struct pincode_interface { bool (*config_read) (char *w1, char *w2); }; -struct pincode_interface *pincode; - #ifdef HERCULES_CORE void pincode_defaults(void); #endif // HERCULES_CORE +HPShared struct pincode_interface *pincode; + #endif /* CHAR_PINCODE_H */ diff --git a/src/common/HPM.c b/src/common/HPM.c index d82faee1f..85f3d9e95 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -34,6 +34,7 @@ struct malloc_interface iMalloc_HPM; struct malloc_interface *HPMiMalloc; struct HPM_interface HPM_s; +struct HPM_interface *HPM; /** * (char*) data name -> (unsigned int) HPMDataCheck[] index @@ -95,28 +96,6 @@ struct hplugin *hplugin_create(void) { HPM->plugins[HPM->plugin_count - 1]->filename = NULL; return HPM->plugins[HPM->plugin_count - 1]; } -#define HPM_POP(x) { #x , x } -bool hplugin_populate(struct hplugin *plugin, const char *filename) { - struct { - const char* name; - void *Ref; - } ToLink[] = { - HPM_POP(showmsg), - }; - int i, length = ARRAYLENGTH(ToLink); - - for(i = 0; i < length; i++) { - void **Link; - if (!( Link = plugin_import(plugin->dll, ToLink[i].name,void **))) { - ShowFatalError("HPM:plugin_load: failed to retrieve '%s' for '"CL_WHITE"%s"CL_RESET"'!\n", ToLink[i].name, filename); - exit(EXIT_FAILURE); - } - *Link = ToLink[i].Ref; - } - - return true; -} -#undef HPM_POP struct hplugin *hplugin_load(const char* filename) { struct hplugin *plugin; struct hplugin_info *info; @@ -127,6 +106,7 @@ struct hplugin *hplugin_load(const char* filename) { int *HPMDataCheckVer; unsigned int *HPMDataCheckLen; struct s_HPMDataCheck *HPMDataCheck; + const char *(*HPMLoadEvent)(int server_type); if( HPM->exists(filename) ) { ShowWarning("HPM:plugin_load: attempting to load duplicate '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename); @@ -204,8 +184,17 @@ struct hplugin *hplugin_load(const char* filename) { exit(EXIT_FAILURE); } - if( !HPM->populate(plugin,filename) ) - return NULL; + if (!(HPMLoadEvent = plugin_import(plugin->dll, "HPM_shared_symbols", const char *(*)(int)))) { + ShowFatalError("HPM:plugin_load: failed to retrieve 'HPM_shared_symbols' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h!\n", filename); + exit(EXIT_FAILURE); + } + { + const char *failure = HPMLoadEvent(SERVER_TYPE); + if (failure) { + ShowFatalError("HPM:plugin_load: failed to import symbol '%s' into '"CL_WHITE"%s"CL_RESET"'.\n", failure, filename); + exit(EXIT_FAILURE); + } + } if( !( HPMDataCheckLen = plugin_import(plugin->dll, "HPMDataCheckLen", unsigned int *) ) ) { ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheckLen' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h!\n", filename); @@ -925,7 +914,6 @@ void hpm_defaults(void) { HPM->share = hplugin_export_symbol; HPM->symbol_defaults = hplugins_share_defaults; HPM->config_read = hplugins_config_read; - HPM->populate = hplugin_populate; HPM->symbol_defaults_sub = NULL; HPM->pid2name = hplugins_id2name; HPM->parse_packets = hplugins_parse_packets; diff --git a/src/common/HPM.h b/src/common/HPM.h index 1358f19dc..2d38a2bfa 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -8,8 +8,8 @@ #error You should never include HPM.h from a plugin. #endif +#include "common/hercules.h" #include "common/HPMi.h" -#include "common/cbasetypes.h" #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN @@ -131,7 +131,6 @@ struct HPM_interface { void (*share) (void *, char *); void (*symbol_defaults) (void); void (*config_read) (void); - bool (*populate) (struct hplugin *plugin,const char *filename); void (*symbol_defaults_sub) (void);//TODO drop char *(*pid2name) (unsigned int pid); unsigned char (*parse_packets) (int fd, enum HPluginPacketHookingPoints point); @@ -150,7 +149,7 @@ struct HPM_interface { CMDLINEARG(loadplugin); -struct HPM_interface *HPM; +extern struct HPM_interface *HPM; void hpm_defaults(void); diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 2054657be..244a9e0ab 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -4,7 +4,7 @@ #ifndef COMMON_HPMI_H #define COMMON_HPMI_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/console.h" #include "common/core.h" #include "common/showmsg.h" @@ -15,13 +15,7 @@ struct AtCommandInfo; struct socket_data; struct map_session_data; -#ifdef WIN32 - #define HPExport __declspec(dllexport) -#else - #define HPExport -#endif - -#define HPM_VERSION "1.0" +#define HPM_VERSION "1.1" #define HPM_ADDCONF_LENGTH 40 struct hplugin_info { @@ -37,11 +31,6 @@ struct s_HPMDataCheck { int type; }; -HPExport void *(*import_symbol) (char *name, unsigned int pID); -HPExport Sql *mysql_handle; - -#define GET_SYMBOL(n) import_symbol((n),HPMi->pid) - #define SERVER_TYPE_ALL (SERVER_TYPE_LOGIN|SERVER_TYPE_CHAR|SERVER_TYPE_MAP) enum hp_event_types { @@ -226,6 +215,10 @@ struct HPMi_interface { #ifndef HERCULES_CORE HPExport struct HPMi_interface HPMi_s; HPExport struct HPMi_interface *HPMi; -#endif +HPExport void *(*import_symbol) (char *name, unsigned int pID); +HPExport Sql *mysql_handle; +#define HPM_SYMBOL(n, s) ((s) = import_symbol((n),HPMi->pid)) +#endif // !HERCULES_CORE + #endif /* COMMON_HPMI_H */ diff --git a/src/common/Makefile.in b/src/common/Makefile.in index f6f993165..208d3b111 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -32,9 +32,9 @@ COMMON_MINI_OBJ = $(addprefix obj_all/, $(COMMON_SHARED_OBJ) \ miniconsole.o minicore.o minimalloc.o minisocket.o) COMMON_C += console.c core.c malloc.c socket.c COMMON_H = atomic.h cbasetypes.h conf.h console.h core.h db.h des.h ers.h \ - grfio.h HPM.h HPMi.h malloc.h mapindex.h md5calc.h mmo.h mutex.h \ - nullpo.h random.h showmsg.h socket.h spinlock.h sql.h strlib.h \ - sysinfo.h thread.h timer.h utils.h winapi.h + grfio.h hercules.h HPM.h HPMi.h malloc.h mapindex.h md5calc.h \ + mmo.h mutex.h nullpo.h random.h showmsg.h socket.h spinlock.h \ + sql.h strlib.h sysinfo.h thread.h timer.h utils.h winapi.h COMMON_SQL_OBJ = obj_sql/sql.o COMMON_SQL_H = sql.h diff --git a/src/common/conf.c b/src/common/conf.c index cb0194c3a..d9367dc9e 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -12,7 +12,7 @@ /* interface source */ struct libconfig_interface libconfig_s; - +struct libconfig_interface *libconfig; int conf_read_file(config_t *config, const char *config_filename) { libconfig->init(config); diff --git a/src/common/conf.h b/src/common/conf.h index 49257835d..ac97a5427 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -5,7 +5,7 @@ #ifndef COMMON_CONF_H #define COMMON_CONF_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <libconfig/libconfig.h> @@ -91,10 +91,10 @@ struct libconfig_interface { int (*setting_copy) (config_setting_t *parent, const config_setting_t *src); }; -struct libconfig_interface *libconfig; - #ifdef HERCULES_CORE void libconfig_defaults(void); #endif // HERCULES_CORE +HPShared struct libconfig_interface *libconfig; + #endif // COMMON_CONF_H diff --git a/src/common/console.c b/src/common/console.c index 3b49204f6..5091d1a6c 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -37,6 +37,7 @@ #endif struct console_interface console_s; +struct console_interface *console; #ifdef CONSOLE_INPUT struct console_input_interface console_input_s; diff --git a/src/common/console.h b/src/common/console.h index 643edc3d9..ffb4a165b 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -4,9 +4,7 @@ #ifndef COMMON_CONSOLE_H #define COMMON_CONSOLE_H -#include "config/core.h" // MAX_CONSOLE_INPUT - -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mutex.h" #include "common/spinlock.h" #include "common/sql.h" @@ -84,10 +82,10 @@ struct console_interface { struct console_input_interface *input; }; -struct console_interface *console; - #ifdef HERCULES_CORE void console_defaults(void); #endif // HERCULES_CORE +HPShared struct console_interface *console; + #endif /* COMMON_CONSOLE_H */ diff --git a/src/common/core.c b/src/common/core.c index e46c9589b..2f89d004e 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -361,6 +361,7 @@ void cmdline_final(void) } struct cmdline_interface cmdline_s; +struct cmdline_interface *cmdline; void cmdline_defaults(void) { diff --git a/src/common/core.h b/src/common/core.h index c2a8d9e58..b0f0449a3 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -5,7 +5,7 @@ #ifndef COMMON_CORE_H #define COMMON_CORE_H -#include "common/cbasetypes.h" +#include "common/hercules.h" /* so that developers with --enable-debug can raise signals from any section of the code they'd like */ #ifdef DEBUG @@ -28,27 +28,6 @@ enum E_CORE_ST { CORE_ST_LAST }; -#ifdef HERCULES_CORE -extern int arg_c; -extern char **arg_v; - -/// @see E_CORE_ST -extern int runflag; -extern char *SERVER_NAME; - -enum server_types SERVER_TYPE; - -extern void cmdline_args_init_local(void); -extern int do_init(int,char**); -extern void set_server_type(void); -extern void do_abort(void); -extern int do_final(void); - -/// Called when a terminate signal is received. (Ctrl+C pressed) -/// If NULL, runflag is set to CORE_ST_STOP instead. -extern void (*shutdown_callback)(void); -#endif // HERCULES_CORE - /// Options for command line argument handlers. enum cmdline_options { CMDLINE_OPT_NORMAL = 0x0, ///< No special options. @@ -78,10 +57,28 @@ struct cmdline_interface { const char *(*arg_source) (struct CmdlineArgData *arg); }; -struct cmdline_interface *cmdline; - #define CMDLINEARG(x) bool cmdline_arg_ ## x (const char *name, const char *params) + #ifdef HERCULES_CORE +extern int arg_c; +extern char **arg_v; + +/// @see E_CORE_ST +extern int runflag; +extern char *SERVER_NAME; + +enum server_types SERVER_TYPE; + +extern void cmdline_args_init_local(void); +extern int do_init(int,char**); +extern void set_server_type(void); +extern void do_abort(void); +extern int do_final(void); + +/// Called when a terminate signal is received. (Ctrl+C pressed) +/// If NULL, runflag is set to CORE_ST_STOP instead. +extern void (*shutdown_callback)(void); + /// Special plugin ID assigned to the Hercules core #define HPM_PID_CORE ((unsigned int)-1) @@ -91,4 +88,6 @@ struct cmdline_interface *cmdline; void cmdline_defaults(void); #endif // HERCULES_CORE +HPShared struct cmdline_interface *cmdline; + #endif /* COMMON_CORE_H */ diff --git a/src/common/db.c b/src/common/db.c index 5063425e6..4df5c08db 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -82,6 +82,7 @@ #include <stdlib.h> struct db_interface DB_s; +struct db_interface *DB; /*****************************************************************************\ * (1) Private typedefs, enums, structures, defines and global variables of * diff --git a/src/common/db.h b/src/common/db.h index f75cbd8dc..9b9cba8f8 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -42,7 +42,7 @@ #ifndef COMMON_DB_H #define COMMON_DB_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <stdarg.h> @@ -916,9 +916,6 @@ void (*init) (void); void (*final) (void); }; -struct db_interface *DB; - -void db_defaults(void); // Link DB System - From jAthena struct linkdb_node { struct linkdb_node *next; @@ -937,8 +934,11 @@ void* linkdb_erase (struct linkdb_node** head, void *key); void linkdb_final (struct linkdb_node** head); void linkdb_vforeach(struct linkdb_node** head, LinkDBFunc func, va_list ap); void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...); + +void db_defaults(void); #endif // HERCULES_CORE +HPShared struct db_interface *DB; /// Finds an entry in an array. diff --git a/src/common/hercules.h b/src/common/hercules.h new file mode 100644 index 000000000..678577690 --- /dev/null +++ b/src/common/hercules.h @@ -0,0 +1,23 @@ +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Base author: Haru <haru@dotalux.com> + +#ifndef COMMON_HERCULES_H +#define COMMON_HERCULES_H + +#include "config/core.h" +#include "common/cbasetypes.h" + +#ifdef WIN32 + #define HPExport __declspec(dllexport) +#else + #define HPExport __attribute__((visibility("default"))) +#endif + +#define HPShared extern + +#ifndef HERCULES_CORE +#include "common/HPMi.h" +#endif // HERCULES_CORE + +#endif // COMMON_HERCULES_H diff --git a/src/common/malloc.c b/src/common/malloc.c index ec0467495..d5a979e77 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -16,6 +16,7 @@ #include <string.h> struct malloc_interface iMalloc_s; +struct malloc_interface *iMalloc; ////////////// Memory Libraries ////////////////// diff --git a/src/common/malloc.h b/src/common/malloc.h index 20260de84..b194c7cf3 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -4,7 +4,7 @@ #ifndef COMMON_MALLOC_H #define COMMON_MALLOC_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #define ALC_MARK __FILE__, __LINE__, __func__ @@ -59,12 +59,6 @@ //////////////////////////////////////////////// -#ifdef HERCULES_CORE -void malloc_defaults(void); - -void memmgr_report(int extra); -#endif // HERCULES_CORE - struct malloc_interface { void (*init) (void); void (*final) (void); @@ -84,5 +78,12 @@ struct malloc_interface { void (*init_messages) (void); }; -struct malloc_interface *iMalloc; +#ifdef HERCULES_CORE +void malloc_defaults(void); + +void memmgr_report(int extra); +#endif // HERCULES_CORE + +HPShared struct malloc_interface *iMalloc; + #endif /* COMMON_MALLOC_H */ diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 3d3ef52f1..aa31d8090 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -17,6 +17,7 @@ /* mapindex.c interface source */ struct mapindex_interface mapindex_s; +struct mapindex_interface *mapindex; /// Retrieves the map name from 'string' (removing .gat extension if present). /// Result gets placed either into 'buf' or in a static local buffer. diff --git a/src/common/mapindex.h b/src/common/mapindex.h index 74eea0aef..ff19630a1 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -5,7 +5,7 @@ #ifndef COMMON_MAPINDEX_H #define COMMON_MAPINDEX_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" @@ -95,10 +95,10 @@ struct mapindex_interface { bool (*check_default) (void); }; -struct mapindex_interface *mapindex; - #ifdef HERCULES_CORE void mapindex_defaults(void); #endif // HERCULES_CORE +HPShared struct mapindex_interface *mapindex; + #endif /* COMMON_MAPINDEX_H */ diff --git a/src/common/nullpo.c b/src/common/nullpo.c index 0db714ae1..829ba4aab 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -17,6 +17,7 @@ #endif // HAVE_EXECINFO struct nullpo_interface nullpo_s; +struct nullpo_interface *nullpo; /** * Reports failed assertions or NULL pointers diff --git a/src/common/nullpo.h b/src/common/nullpo.h index a59c2ac2b..52e9fba39 100644 --- a/src/common/nullpo.h +++ b/src/common/nullpo.h @@ -5,7 +5,7 @@ #ifndef COMMON_NULLPO_H #define COMMON_NULLPO_H -#include "common/cbasetypes.h" +#include "common/hercules.h" // enabled by default on debug builds #if defined(DEBUG) && !defined(NULLPO_CHECK) @@ -127,10 +127,10 @@ struct nullpo_interface { void (*assert_report) (const char *file, int line, const char *func, const char *targetname, const char *title); }; -struct nullpo_interface *nullpo; - #ifdef HERCULES_CORE void nullpo_defaults(void); #endif // HERCULES_CORE +HPShared struct nullpo_interface *nullpo; + #endif /* COMMON_NULLPO_H */ diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 68af31917..27fb0b635 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -31,6 +31,7 @@ #endif struct showmsg_interface showmsg_s; +struct showmsg_interface *showmsg; /////////////////////////////////////////////////////////////////////////////// /// static/dynamic buffer for the messages diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 6b119a1ce..728691ba3 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -5,7 +5,7 @@ #ifndef COMMON_SHOWMSG_H #define COMMON_SHOWMSG_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <libconfig/libconfig.h> @@ -105,10 +105,8 @@ struct showmsg_interface { void (*showConfigWarning) (config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); }; -struct showmsg_interface *showmsg; - /* the purpose of these macros is simply to not make calling them be an annoyance */ -#define ClearScreen() (showMsg->clearScreen()) +#define ClearScreen() (showmsg->clearScreen()) #define vShowMessage(fmt, list) (showmsg->showMessageV((fmt), (list))) #define ShowMessage(fmt, ...) (showmsg->showMessage((fmt), ##__VA_ARGS__)) #define ShowStatus(fmt, ...) (showmsg->showStatus((fmt), ##__VA_ARGS__)) @@ -123,6 +121,8 @@ struct showmsg_interface *showmsg; #ifdef HERCULES_CORE void showmsg_defaults(void); -#endif +#endif // HERCULES_CORE + +HPShared struct showmsg_interface *showmsg; #endif /* COMMON_SHOWMSG_H */ diff --git a/src/common/socket.c b/src/common/socket.c index 098fdf236..c4cc4a329 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -55,6 +55,9 @@ * Socket Interface Source **/ struct socket_interface sockt_s; +struct socket_interface *sockt; + +struct socket_data **session; #ifdef SEND_SHORTLIST // Add a fd to the shortlist so that it'll be recognized as a fd that needs diff --git a/src/common/socket.h b/src/common/socket.h index 18bf25178..a995bffc8 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -5,7 +5,7 @@ #ifndef COMMON_SOCKET_H #define COMMON_SOCKET_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/conf.h" #ifdef WIN32 @@ -193,10 +193,10 @@ struct socket_interface { void (*net_config_read) (const char *filename); }; -struct socket_interface *sockt; - #ifdef HERCULES_CORE void socket_defaults(void); #endif // HERCULES_CORE +HPShared struct socket_interface *sockt; + #endif /* COMMON_SOCKET_H */ diff --git a/src/common/sql.c b/src/common/sql.c index a93092533..0ca51e272 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -24,6 +24,7 @@ int mysql_reconnect_type; unsigned int mysql_reconnect_count; struct sql_interface sql_s; +struct sql_interface *SQL; /// Sql handle struct Sql { diff --git a/src/common/sql.h b/src/common/sql.h index d76b4f9d4..7fb4aabe8 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -5,7 +5,7 @@ #ifndef COMMON_SQL_H #define COMMON_SQL_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <stdarg.h>// va_list @@ -269,8 +269,6 @@ struct sql_interface { }; -struct sql_interface *SQL; - #ifdef HERCULES_CORE void sql_defaults(void); @@ -280,6 +278,8 @@ void Sql_HerculesUpdateCheck(Sql* self); void Sql_HerculesUpdateSkip(Sql* self,const char *filename); #endif // HERCULES_CORE +HPShared struct sql_interface *SQL; + #if defined(SQL_REMOVE_SHOWDEBUG) #define Sql_ShowDebug(self) (void)0 #else diff --git a/src/common/strlib.c b/src/common/strlib.c index abef22d48..024b73e59 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -20,6 +20,10 @@ struct strlib_interface strlib_s; struct stringbuf_interface stringbuf_s; struct sv_interface sv_s; +struct strlib_interface *strlib; +struct stringbuf_interface *StrBuf; +struct sv_interface *sv; + // escapes a string in-place (' -> \' , \ -> \\ , % -> _) char* jstrescape (char* pt) { //copy from here diff --git a/src/common/strlib.h b/src/common/strlib.h index cd7b90b08..cd9e105fb 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -5,7 +5,7 @@ #ifndef COMMON_STRLIB_H #define COMMON_STRLIB_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <stdarg.h> #include <string.h> @@ -112,8 +112,6 @@ struct strlib_interface { bool (*bin2hex_) (char* output, unsigned char* input, size_t count); }; -struct strlib_interface *strlib; - struct stringbuf_interface { StringBuf* (*Malloc) (void); void (*Init) (StringBuf* self); @@ -128,8 +126,6 @@ struct stringbuf_interface { void (*Free) (StringBuf* self); }; -struct stringbuf_interface *StrBuf; - struct sv_interface { /// Parses a single field in a delim-separated string. /// The delimiter after the field is skipped. @@ -172,10 +168,12 @@ struct sv_interface { bool (*readdb) (const char* directory, const char* filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char* fields[], int columns, int current)); }; -struct sv_interface *sv; - #ifdef HERCULES_CORE void strlib_defaults(void); #endif // HERCULES_CORE +HPShared struct strlib_interface *strlib; +HPShared struct stringbuf_interface *StrBuf; +HPShared struct sv_interface *sv; + #endif /* COMMON_STRLIB_H */ diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index 105f300ad..d218e6e99 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -40,6 +40,8 @@ struct sysinfo_private { struct sysinfo_interface sysinfo_s; struct sysinfo_private sysinfo_p; +struct sysinfo_interface *sysinfo; + #define VCSTYPE_UNKNOWN 0 #define VCSTYPE_GIT 1 #define VCSTYPE_SVN 2 diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h index 3c0d01ca1..7d47398a3 100644 --- a/src/common/sysinfo.h +++ b/src/common/sysinfo.h @@ -11,7 +11,7 @@ * cached at compile time) */ -#include "common/cbasetypes.h" +#include "common/hercules.h" struct sysinfo_private; @@ -44,10 +44,10 @@ struct sysinfo_interface { void (*final) (void); }; -struct sysinfo_interface *sysinfo; - #ifdef HERCULES_CORE void sysinfo_defaults(void); #endif // HERCULES_CORE +HPShared struct sysinfo_interface *sysinfo; + #endif /* COMMON_SYSINFO_H */ diff --git a/src/common/timer.c b/src/common/timer.c index 06309642e..793706511 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -24,6 +24,7 @@ #include <string.h> struct timer_interface timer_s; +struct timer_interface *timer; // If the server can't handle processing thousands of monsters // or many connected clients, please increase TIMER_MIN_INTERVAL. diff --git a/src/common/timer.h b/src/common/timer.h index 46a036ec7..c00a4362b 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -5,7 +5,7 @@ #ifndef COMMON_TIMER_H #define COMMON_TIMER_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #define DIFF_TICK(a,b) ((a)-(b)) #define DIFF_TICK32(a,b) ((int32)((a)-(b))) @@ -63,10 +63,10 @@ struct timer_interface { void (*final) (void); }; -struct timer_interface *timer; - #ifdef HERCULES_CORE void timer_defaults(void); #endif // HERCULES_CORE +HPShared struct timer_interface *timer; + #endif /* COMMON_TIMER_H */ diff --git a/src/common/utils.c b/src/common/utils.c index 07e2e9fdf..3606c6755 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -29,6 +29,7 @@ #include <sys/stat.h> // cache purposes [Ind/Hercules] struct HCache_interface HCache_s; +struct HCache_interface *HCache; /// Dumps given buffer into file pointed to by a handle. void WriteDump(FILE* fp, const void* buffer, size_t length) diff --git a/src/common/utils.h b/src/common/utils.h index e2b0dacc9..6296f6235 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -5,7 +5,7 @@ #ifndef COMMON_UTILS_H #define COMMON_UTILS_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <stdio.h> // FILE* @@ -68,10 +68,10 @@ struct HCache_interface { bool enabled; }; -struct HCache_interface *HCache; - #ifdef HERCULES_CORE void HCache_defaults(void); #endif // HERCULES_CORE +HPShared struct HCache_interface *HCache; + #endif /* COMMON_UTILS_H */ diff --git a/src/login/login.c b/src/login/login.c index 2b429bad0..420c8687b 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -29,6 +29,7 @@ #include <stdlib.h> struct login_interface login_s; +struct login_interface *login; struct Login_Config login_config; struct mmo_char_server server[MAX_SERVERS]; // char server data diff --git a/src/login/login.h b/src/login/login.h index 6dc4c875b..40a8237d8 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -5,7 +5,7 @@ #ifndef LOGIN_LOGIN_H #define LOGIN_LOGIN_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/core.h" // CORE_ST_LAST #include "common/db.h" #include "common/mmo.h" // NAME_LENGTH,SEX_* @@ -128,10 +128,6 @@ struct online_login_data { #define sex_str2num(str) ( ((str) == 'F') ? SEX_FEMALE : ((str) == 'M') ? SEX_MALE : SEX_SERVER ) #define MAX_SERVERS 30 -#ifdef HERCULES_CORE -extern struct mmo_char_server server[MAX_SERVERS]; -extern struct Login_Config login_config; -#endif // HERCULES_CORE /** * Login.c Interface @@ -201,10 +197,13 @@ struct login_interface { char *NET_CONF_NAME; ///< Network configuration filename }; -struct login_interface *login; - #ifdef HERCULES_CORE +extern struct mmo_char_server server[MAX_SERVERS]; +extern struct Login_Config login_config; + void login_defaults(void); #endif // HERCULES_CORE +HPShared struct login_interface *login; + #endif /* LOGIN_LOGIN_H */ diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 6c5a6282e..1fec0af5b 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -58,6 +58,7 @@ #include <string.h> struct atcommand_interface atcommand_s; +struct atcommand_interface *atcommand; static char atcmd_output[CHAT_SIZE_MAX]; static char atcmd_player_name[NAME_LENGTH]; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 88ddde8c2..ccc7d3725 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -6,7 +6,7 @@ #define MAP_ATCOMMAND_H #include "map/pc_groups.h" -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/conf.h" #include "common/db.h" @@ -127,12 +127,12 @@ struct atcommand_interface { const char* (*msgsd) (struct map_session_data *sd, int msg_number); }; -struct atcommand_interface *atcommand; - #ifdef HERCULES_CORE void atcommand_defaults(void); #endif // HERCULES_CORE +HPShared struct atcommand_interface *atcommand; + /* stay here */ #define ACMD(x) static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info) diff --git a/src/map/battle.c b/src/map/battle.c index f64fde55f..671d63200 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -43,6 +43,7 @@ struct Battle_Config battle_config; struct battle_interface battle_s; +struct battle_interface *battle; int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last skill in use by this bl. struct unit_data *ud; diff --git a/src/map/battle.h b/src/map/battle.h index 6bc2659b9..b211afff5 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -6,7 +6,7 @@ #define MAP_BATTLE_H #include "map/map.h" //ELE_MAX -#include "common/cbasetypes.h" +#include "common/hercules.h" /** * Declarations @@ -509,10 +509,6 @@ struct Battle_Config { int feature_roulette; }; -#ifdef HERCULES_CORE -extern struct Battle_Config battle_config; -#endif // HERCULES_CORE - /* criteria for battle_config.idletime_critera */ enum e_battle_config_idletime { BCIDLE_WALK = 0x001, @@ -643,10 +639,12 @@ struct battle_interface { void (*calc_misc_attack_unknown) (struct block_list *src, struct block_list *target, uint16 *skill_id, uint16 *skill_lv, int *mflag, struct Damage *md); }; -struct battle_interface *battle; - #ifdef HERCULES_CORE +extern struct Battle_Config battle_config; + void battle_defaults(void); #endif // HERCULES_CORE +HPShared struct battle_interface *battle; + #endif /* MAP_BATTLE_H */ diff --git a/src/map/battleground.c b/src/map/battleground.c index 0fe42110f..915ccc851 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -32,6 +32,7 @@ #include <string.h> struct battleground_interface bg_s; +struct battleground_interface *bg; /// Search a BG Team using bg_id struct battleground_data* bg_team_search(int bg_id) { diff --git a/src/map/battleground.h b/src/map/battleground.h index a67deb722..094037f43 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -6,7 +6,7 @@ #define MAP_BATTLEGROUND_H #include "map/map.h" // EVENT_NAME_LENGTH -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" // struct party @@ -127,10 +127,10 @@ struct battleground_interface { void (*config_read) (void); }; -struct battleground_interface *bg; - #ifdef HERCULES_CORE void battleground_defaults(void); #endif // HERCULES_CORE +HPShared struct battleground_interface *bg; + #endif /* MAP_BATTLEGROUND_H */ diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index d1ce4ba0d..a1b6e9e65 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -19,6 +19,7 @@ #include "common/strlib.h" // safestrncpy struct buyingstore_interface buyingstore_s; +struct buyingstore_interface *buyingstore; /// Returns unique buying store id unsigned int buyingstore_getuid(void) { diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index f23790459..74f61239f 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -5,7 +5,7 @@ #ifndef MAP_BUYINGSTORE_H #define MAP_BUYINGSTORE_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // MAX_SLOTS struct map_session_data; @@ -71,10 +71,10 @@ struct buyingstore_interface { unsigned int (*getuid) (void); }; -struct buyingstore_interface *buyingstore; - #ifdef HERCULES_CORE void buyingstore_defaults (void); #endif // HERCULES_CORE +HPShared struct buyingstore_interface *buyingstore; + #endif // MAP_BUYINGSTORE_H diff --git a/src/map/channel.c b/src/map/channel.c index ab6694345..337d05504 100644 --- a/src/map/channel.c +++ b/src/map/channel.c @@ -28,6 +28,7 @@ #include <string.h> struct channel_interface channel_s; +struct channel_interface *channel; static struct Channel_Config channel_config; diff --git a/src/map/channel.h b/src/map/channel.h index de1779d96..391045c59 100644 --- a/src/map/channel.h +++ b/src/map/channel.h @@ -4,7 +4,7 @@ #ifndef MAP_CHANNEL_H #define MAP_CHANNEL_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" @@ -109,10 +109,10 @@ struct channel_interface { void (*config_read) (void); }; -struct channel_interface *channel; - #ifdef HERCULES_CORE void channel_defaults(void); #endif // HERCULES_CORE +HPShared struct channel_interface *channel; + #endif /* MAP_CHANNEL_H */ diff --git a/src/map/chat.c b/src/map/chat.c index 08c904290..ed9d9c598 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -24,6 +24,7 @@ #include <string.h> struct chat_interface chat_s; +struct chat_interface *chat; /// Initializes a chatroom object (common functionality for both pc and npc chatrooms). /// Returns a chatroom object on success, or NULL on failure. diff --git a/src/map/chat.h b/src/map/chat.h index 31048d5dd..68f9107f3 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -6,7 +6,7 @@ #define MAP_CHAT_H #include "map/map.h" // struct block_list, CHATROOM_TITLE_SIZE -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct chat_data; @@ -55,10 +55,10 @@ struct chat_interface { struct chat_data* (*create) (struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl); }; -struct chat_interface *chat; - #ifdef HERCULES_CORE void chat_defaults(void); #endif // HERCULES_CORE +HPShared struct chat_interface *chat; + #endif /* MAP_CHAT_H */ diff --git a/src/map/chrif.c b/src/map/chrif.c index 62df026da..ac96e1d84 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -38,6 +38,7 @@ #include <sys/types.h> struct chrif_interface chrif_s; +struct chrif_interface *chrif; //Used Packets: //2af8: Outgoing, chrif_connect -> 'connect to charserver / auth @ charserver' diff --git a/src/map/chrif.h b/src/map/chrif.h index cac965f74..25f69a309 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -6,7 +6,7 @@ #define MAP_CHRIF_H #include "map/map.h" //TBL_PC -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct eri; @@ -150,10 +150,10 @@ struct chrif_interface { void (*del_scdata_single) (int account_id, int char_id, short type); }; -struct chrif_interface *chrif; - #ifdef HERCULES_CORE void chrif_defaults(void); #endif // HERCULES_CORE +HPShared struct chrif_interface *chrif; + #endif /* MAP_CHRIF_H */ diff --git a/src/map/clif.c b/src/map/clif.c index 0784326c9..296fd5cb3 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -59,6 +59,9 @@ #include <time.h> struct clif_interface clif_s; +struct clif_interface *clif; + +struct s_packet_db packet_db[MAX_PACKET_DB + 1]; /* re-usable */ static struct packet_itemlist_normal itemlist_normal; diff --git a/src/map/clif.h b/src/map/clif.h index c827406ca..66a749818 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -7,7 +7,7 @@ #include "map/map.h" #include "map/packets_struct.h" -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" #include <stdarg.h> @@ -558,11 +558,6 @@ struct merge_item { }; /** - * Vars - **/ -struct s_packet_db packet_db[MAX_PACKET_DB + 1]; - -/** * Clif.c Interface **/ struct clif_interface { @@ -1322,10 +1317,15 @@ struct clif_interface { void (*pNPCMarketPurchase) (int fd, struct map_session_data *sd); }; -struct clif_interface *clif; - #ifdef HERCULES_CORE +/** + * Vars + **/ +extern struct s_packet_db packet_db[MAX_PACKET_DB + 1]; + void clif_defaults(void); #endif // HERCULES_CORE +HPShared struct clif_interface *clif; + #endif /* MAP_CLIF_H */ diff --git a/src/map/duel.c b/src/map/duel.c index 4cd2e276f..762745b75 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -17,6 +17,7 @@ #include <time.h> struct duel_interface duel_s; +struct duel_interface *duel; /*========================================== * Duel organizing functions [LuzZza] diff --git a/src/map/duel.h b/src/map/duel.h index 0c55c1266..c77f1c351 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -5,7 +5,7 @@ #ifndef MAP_DUEL_H #define MAP_DUEL_H -#include "common/cbasetypes.h" +#include "common/hercules.h" struct map_session_data; @@ -42,10 +42,10 @@ struct duel_interface { void (*final) (void); }; -struct duel_interface *duel; - #ifdef HERCULES_CORE void duel_defaults(void); #endif // HERCULES_CORE +HPShared struct duel_interface *duel; + #endif /* MAP_DUEL_H */ diff --git a/src/map/elemental.c b/src/map/elemental.c index 459ce2a39..d74e7a199 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -42,6 +42,7 @@ #include <string.h> struct elemental_interface elemental_s; +struct elemental_interface *elemental; int elemental_search_index(int class_) { int i; diff --git a/src/map/elemental.h b/src/map/elemental.h index 582e1059c..d040f8337 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -7,7 +7,7 @@ #include "map/status.h" // struct status_data, struct status_change #include "map/unit.h" // struct unit_data -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // NAME_LENGTH #include <stdarg.h> @@ -120,10 +120,10 @@ struct elemental_interface { int (*read_db) (void); }; -struct elemental_interface *elemental; - #ifdef HERCULES_CORE void elemental_defaults(void); #endif // HERCULES_CORE +HPShared struct elemental_interface *elemental; + #endif /* MAP_ELEMENTAL_H */ diff --git a/src/map/guild.c b/src/map/guild.c index 5f6ce83c6..15c65ec98 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -36,6 +36,7 @@ #include <string.h> struct guild_interface guild_s; +struct guild_interface *guild; /*========================================== * Retrieves and validates the sd pointer for this guild member [Skotlex] diff --git a/src/map/guild.h b/src/map/guild.h index 18a25af58..a11585fbc 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -6,7 +6,7 @@ #define MAP_GUILD_H #include "map/map.h" // EVENT_NAME_LENGTH, TBL_PC -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" @@ -163,10 +163,10 @@ struct guild_interface { void (*castle_reconnect_sub) (void *key, void *data, va_list ap); }; -struct guild_interface *guild; - #ifdef HERCULES_CORE void guild_defaults(void); #endif // HERCULES_CORE +HPShared struct guild_interface *guild; + #endif /* MAP_GUILD_H */ diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 305d60f5b..cc736708d 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -45,6 +45,8 @@ struct homunculus_interface homunculus_s; struct homun_dbs homundbs; +struct homunculus_interface *homun; + //Returns the viewdata for homunculus struct view_data* homunculus_get_viewdata(int class_) { if (homdb_checkid(class_)) diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 95b613fff..9d23fbe2c 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -7,6 +7,7 @@ #include "map/status.h" // struct status_data, struct status_change #include "map/unit.h" // struct unit_data +#include "common/hercules.h" #include "common/mmo.h" struct map_session_data; @@ -160,10 +161,10 @@ struct homunculus_interface { int8 (*get_intimacy_grade) (struct homun_data *hd); }; -struct homunculus_interface *homun; - #ifdef HERCULES_CORE void homunculus_defaults(void); #endif // HERCULES_CORE +HPShared struct homunculus_interface *homun; + #endif /* MAP_HOMUNCULUS_H */ diff --git a/src/map/instance.c b/src/map/instance.c index 92acd1bbb..1fc396325 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -32,6 +32,7 @@ #include <time.h> struct instance_interface instance_s; +struct instance_interface *instance; /// Checks whether given instance id is valid or not. bool instance_is_valid(int instance_id) { diff --git a/src/map/instance.h b/src/map/instance.h index e17d6866f..589e1a511 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -6,7 +6,7 @@ #define MAP_INSTANCE_H #include "map/script.h" // struct reg_db -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // struct point struct HPluginData; @@ -85,10 +85,10 @@ struct instance_interface { int (*destroy_timer) (int tid, int64 tick, int id, intptr_t data); }; -struct instance_interface *instance; - #ifdef HERCULES_CORE void instance_defaults(void); #endif // HERCULES_CORE +HPShared struct instance_interface *instance; + #endif /* MAP_INSTANCE_H */ diff --git a/src/map/intif.c b/src/map/intif.c index a2e19f9e9..12f679552 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -37,6 +37,7 @@ #include <sys/types.h> struct intif_interface intif_s; +struct intif_interface *intif; #define inter_fd (chrif->fd) // alias diff --git a/src/map/intif.h b/src/map/intif.h index 3303feb6e..369ac1d9b 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -5,7 +5,7 @@ #ifndef MAP_INTIF_H #define MAP_INTIF_H -#include "common/cbasetypes.h" +#include "common/hercules.h" /** * Declarations @@ -182,10 +182,10 @@ struct intif_interface { void (*pDeleteHomunculusOk) (int fd); }; -struct intif_interface *intif; - #ifdef HERCULES_CORE void intif_defaults(void); #endif // HERCULES_CORE +HPShared struct intif_interface *intif; + #endif /* MAP_INTIF_H */ diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index 34069f74f..86f854ff7 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -24,6 +24,7 @@ //#define IRCBOT_DEBUG struct irc_bot_interface irc_bot_s; +struct irc_bot_interface *ircbot; char send_string[IRC_MESSAGE_LENGTH]; diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index b0bfd72f8..a85fc46e8 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -6,7 +6,7 @@ #ifndef MAP_IRC_BOT_H #define MAP_IRC_BOT_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #define IRC_NICK_LENGTH 40 #define IRC_IDENT_LENGTH 40 @@ -59,10 +59,10 @@ struct irc_bot_interface { void (*usernick) (int fd, char *cmd, char *source, char *target, char *msg); }; -struct irc_bot_interface *ircbot; - #ifdef HERCULES_CORE void ircbot_defaults(void); #endif // HERCULES_CORE +HPShared struct irc_bot_interface *ircbot; + #endif /* MAP_IRC_BOT_H */ diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 644c16a00..7f5c2224c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -26,6 +26,7 @@ #include <string.h> struct itemdb_interface itemdb_s; +struct itemdb_interface *itemdb; /** * Search for item name diff --git a/src/map/itemdb.h b/src/map/itemdb.h index e50ebfd3d..a3edd451e 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -6,7 +6,7 @@ #define MAP_ITEMDB_H /* #include "map/map.h" */ -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/conf.h" #include "common/db.h" #include "common/mmo.h" // ITEM_NAME_LENGTH @@ -618,10 +618,10 @@ struct itemdb_interface { bool (*lookup_const) (const config_setting_t *it, const char *name, int *value); }; -struct itemdb_interface *itemdb; - #ifdef HERCULES_CORE void itemdb_defaults(void); #endif // HERCULES_CORE +HPShared struct itemdb_interface *itemdb; + #endif /* MAP_ITEMDB_H */ diff --git a/src/map/log.c b/src/map/log.c index 0a9b16418..0c5977c05 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -23,6 +23,7 @@ #include <string.h> struct log_interface log_s; +struct log_interface *logs; /// obtain log type character for item/zeny logs char log_picktype2char(e_log_pick_type type) { diff --git a/src/map/log.h b/src/map/log.h index ef654149c..4b2b5d4d6 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -5,7 +5,7 @@ #ifndef MAP_LOG_H #define MAP_LOG_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/sql.h" /** @@ -129,10 +129,10 @@ struct log_interface { bool (*should_log_item) (int nameid, int amount, int refine, struct item_data *id); }; -struct log_interface *logs; - #ifdef HERCULES_CORE void log_defaults(void); #endif // HERCULES_CORE +HPShared struct log_interface *logs; + #endif /* MAP_LOG_H */ diff --git a/src/map/mail.c b/src/map/mail.c index 184e2be8d..0bdad2877 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -19,6 +19,7 @@ #include <string.h> struct mail_interface mail_s; +struct mail_interface *mail; void mail_clear(struct map_session_data *sd) { diff --git a/src/map/mail.h b/src/map/mail.h index 4f325067d..128b1fbaa 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -5,7 +5,7 @@ #ifndef MAP_MAIL_H #define MAP_MAIL_H -#include "common/cbasetypes.h" +#include "common/hercules.h" struct item; struct mail_message; @@ -23,10 +23,10 @@ struct mail_interface { bool (*invalid_operation) (struct map_session_data *sd); }; -struct mail_interface *mail; - #ifdef HERCULES_CORE void mail_defaults(void); #endif // HERCULES_CORE +HPShared struct mail_interface *mail; + #endif /* MAP_MAIL_H */ diff --git a/src/map/map.c b/src/map/map.c index a39c6a03a..5766563c7 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -69,6 +69,9 @@ struct map_interface map_s; struct mapit_interface mapit_s; +struct map_interface *map; +struct mapit_interface *mapit; + /*========================================== * server player count (of all mapservers) *------------------------------------------*/ diff --git a/src/map/map.h b/src/map/map.h index 826548f49..d4ab954be 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -5,10 +5,8 @@ #ifndef MAP_MAP_H #define MAP_MAP_H -#include "config/core.h" - #include "map/atcommand.h" -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/core.h" // CORE_ST_LAST #include "common/db.h" #include "common/mapindex.h" @@ -215,7 +213,13 @@ enum { #define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 ) #define DEFAULT_AUTOSAVE_INTERVAL (5*60*1000) // Specifies maps where players may hit each other -#define map_flag_vs(m) (map->list[m].flag.pvp || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) || map->list[m].flag.battleground) +#define map_flag_vs(m) ( \ + map->list[m].flag.pvp \ + || map->list[m].flag.gvg_dungeon \ + || map->list[m].flag.gvg \ + || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) \ + || map->list[m].flag.battleground \ + ) // Specifies maps that have special GvG/WoE restrictions #define map_flag_gvg(m) (map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle)) // Specifies if the map is tagged as GvG/WoE (regardless of map->agit_flag status) @@ -762,8 +766,6 @@ struct mapit_interface { bool (*exists) (struct s_mapiterator* iter); }; -struct mapit_interface *mapit; - #define mapit_getallusers() (mapit->alloc(MAPIT_NORMAL,BL_PC)) #define mapit_geteachpc() (mapit->alloc(MAPIT_NORMAL,BL_PC)) #define mapit_geteachmob() (mapit->alloc(MAPIT_NORMAL,BL_MOB)) @@ -1085,10 +1087,11 @@ END_ZEROED_BLOCK; void (*zone_clear_single) (struct map_zone_data *zone); }; -struct map_interface *map; - #ifdef HERCULES_CORE void map_defaults(void); #endif // HERCULES_CORE +HPShared struct mapit_interface *mapit; +HPShared struct map_interface *map; + #endif /* MAP_MAP_H */ diff --git a/src/map/mapreg.h b/src/map/mapreg.h index cafd25b64..09d051bab 100644 --- a/src/map/mapreg.h +++ b/src/map/mapreg.h @@ -6,7 +6,7 @@ #define MAP_MAPREG_H #include "map/script.h" // struct reg_db -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct eri; @@ -48,10 +48,10 @@ struct mapreg_interface { bool (*config_read) (const char *w1, const char *w2); }; -struct mapreg_interface *mapreg; - #ifdef HERCULES_CORE void mapreg_defaults(void); #endif // HERCULES_CORE +HPShared struct mapreg_interface *mapreg; + #endif /* MAP_MAPREG_H */ diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index bed40e295..37c830e2e 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -21,6 +21,7 @@ #include <string.h> struct mapreg_interface mapreg_s; +struct mapreg_interface *mapreg; #define MAPREG_AUTOSAVE_INTERVAL (300*1000) diff --git a/src/map/mercenary.c b/src/map/mercenary.c index c60234d5d..ff37f396d 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -44,6 +44,8 @@ struct mercenary_interface mercenary_s; struct s_mercenary_db mercdb[MAX_MERCENARY_CLASS]; +struct mercenary_interface *mercenary; + int merc_search_index(int class_) { int i; diff --git a/src/map/mercenary.h b/src/map/mercenary.h index c96b5a5ef..9e0c59428 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -6,7 +6,7 @@ #include "map/status.h" // struct status_data, struct status_change #include "map/unit.h" // struct unit_data -#include "common/cbasetypes.h" +#include "common/hercules.h" struct map_session_data; @@ -97,10 +97,10 @@ struct mercenary_interface { bool (*read_skill_db_sub) (char* str[], int columns, int current); }; -struct mercenary_interface *mercenary; - #ifdef HERCULES_CORE void mercenary_defaults(void); #endif // HERCULES_CORE +HPShared struct mercenary_interface *mercenary; + #endif /* MAP_MERCENARY_H */ diff --git a/src/map/mob.c b/src/map/mob.c index 8112c208c..f64c7e582 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -48,6 +48,7 @@ #include <string.h> struct mob_interface mob_s; +struct mob_interface *mob; #define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode. diff --git a/src/map/mob.h b/src/map/mob.h index 85d2bf9b8..4b8a054b5 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -8,7 +8,7 @@ #include "map/map.h" // struct block_list #include "map/status.h" // struct status_data, struct status_change #include "map/unit.h" // struct unit_data, view_data -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // struct item #define MAX_RANDOMMONSTER 5 @@ -272,8 +272,8 @@ struct item_drop_list { #define mob_stop_walking(md, type) (unit->stop_walking(&(md)->bl, (type))) #define mob_stop_attack(md) (unit->stop_attack(&(md)->bl)) -#define mob_is_battleground(md) ( map->list[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) ) -#define mob_is_gvg(md) (map->list[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) ) +#define mob_is_battleground(md) (map->list[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST))) +#define mob_is_gvg(md) (map->list[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2)) #define mob_is_treasure(md) (((md)->class_ >= MOBID_TREAS01 && (md)->class_ <= MOBID_TREAS40) || ((md)->class_ >= MOBID_TREAS41 && (md)->class_ <= MOBID_TREAS49)) struct mob_interface { @@ -387,10 +387,10 @@ struct mob_interface { void (*destroy_mob_db) (int index); }; -struct mob_interface *mob; - #ifdef HERCULES_CORE void mob_defaults(void); #endif // HERCULES_CORE +HPShared struct mob_interface *mob; + #endif /* MAP_MOB_H */ diff --git a/src/map/npc.c b/src/map/npc.c index 8733ee7e4..bb0e772ae 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -43,6 +43,7 @@ #include <time.h> struct npc_interface npc_s; +struct npc_interface *npc; static int npc_id=START_NPC_NUM; static int npc_warp=0; diff --git a/src/map/npc.h b/src/map/npc.h index bc779b56b..14b89d128 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -8,7 +8,7 @@ #include "map/map.h" // struct block_list #include "map/status.h" // struct status_change #include "map/unit.h" // struct unit_data -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct HPluginData; @@ -279,12 +279,11 @@ struct npc_interface { int (*secure_timeout_timer) (int tid, int64 tick, int id, intptr_t data); }; -struct npc_interface *npc; - #ifdef HERCULES_CORE void npc_defaults(void); #endif // HERCULES_CORE +HPShared struct npc_interface *npc; /* comes from npc_chat.c */ #ifdef PCRE_SUPPORT @@ -326,8 +325,6 @@ struct npc_chat_interface { void (*finalize_pcrematch_entry) (struct pcrematch_entry* e); }; -struct npc_chat_interface *npc_chat; - /** * pcre interface (libpcre) * so that plugins may share and take advantage of the core's pcre @@ -344,14 +341,16 @@ struct pcre_interface { int (*get_substring) (const char *subject, int *ovector, int stringcount, int stringnumber, const char **stringptr); }; -struct pcre_interface *libpcre; - /** * Also defaults libpcre **/ #ifdef HERCULES_CORE void npc_chat_defaults(void); #endif // HERCULES_CORE + +HPShared struct npc_chat_interface *npc_chat; +HPShared struct pcre_interface *libpcre; + #endif // PCRE_SUPPORT #endif /* MAP_NPC_H */ diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 67b78dcea..0b9023ede 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -30,6 +30,8 @@ struct npc_chat_interface npc_chat_s; struct pcre_interface libpcre_s; +struct npc_chat_interface *npc_chat; +struct pcre_interface *libpcre; /** * Written by MouseJstr in a vision... (2/21/2005) diff --git a/src/map/party.c b/src/map/party.c index 6b35debe5..472c03423 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -35,6 +35,7 @@ #include <string.h> struct party_interface party_s; +struct party_interface *party; /*========================================== * Fills the given party_member structure according to the sd provided. diff --git a/src/map/party.h b/src/map/party.h index 95faa2213..c7893add2 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -6,7 +6,7 @@ #define MAP_PARTY_H #include "map/map.h" // TBL_PC -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" // struct party @@ -139,10 +139,10 @@ struct party_interface { int (*db_final) (DBKey key, DBData *data, va_list ap); }; -struct party_interface *party; - #ifdef HERCULES_CORE void party_defaults(void); #endif // HERCULES_CORE +HPShared struct party_interface *party; + #endif /* MAP_PARTY_H */ diff --git a/src/map/path.c b/src/map/path.c index 3ded5423e..723fd8e8f 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -29,6 +29,7 @@ #define DIR_EAST 8 struct path_interface path_s; +struct path_interface *path; /// @name Structures and defines for A* pathfinding /// @{ diff --git a/src/map/path.h b/src/map/path.h index bbd81b8c6..2ece8f84b 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -6,7 +6,7 @@ #define MAP_PATH_H #include "map/map.h" // enum cell_chk -#include "common/cbasetypes.h" +#include "common/hercules.h" #define MOVE_COST 10 #define MOVE_DIAGONAL_COST 14 @@ -53,10 +53,10 @@ struct path_interface { int (*distance_client) (int dx, int dy); }; -struct path_interface *path; - #ifdef HERCULES_CORE void path_defaults(void); #endif // HERCULES_CORE +HPShared struct path_interface *path; + #endif /* MAP_PATH_H */ diff --git a/src/map/pc.c b/src/map/pc.c index d7b7a9f48..49b8f1f94 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -57,6 +57,7 @@ #include <time.h> struct pc_interface pc_s; +struct pc_interface *pc; //Converts a class to its array index for CLASS_COUNT defined arrays. //Note that it does not do a validity check for speed purposes, where parsing diff --git a/src/map/pc.h b/src/map/pc.h index d35c29bc7..85bbd2016 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -5,8 +5,6 @@ #ifndef MAP_PC_H #define MAP_PC_H -#include "config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT - #include "map/battle.h" // battle #include "map/battleground.h" // enum bg_queue_types #include "map/buyingstore.h" // struct s_buyingstore @@ -19,7 +17,7 @@ #include "map/status.h" // enum sc_type, OPTION_* #include "map/unit.h" // struct unit_data, struct view_data #include "map/vending.h" // struct s_vending -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/ers.h" // struct eri #include "common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus, NEW_CARTS @@ -1072,10 +1070,10 @@ END_ZEROED_BLOCK; /* End */ int (*check_job_name) (const char *name); }; -struct pc_interface *pc; - #ifdef HERCULES_CORE void pc_defaults(void); #endif // HERCULES_CORE +HPShared struct pc_interface *pc; + #endif /* MAP_PC_H */ diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index f9a442d97..28bef6a85 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -21,6 +21,7 @@ static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd() struct pc_groups_interface pcg_s; +struct pc_groups_interface *pcg; /** * Returns dummy group. diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 4fee312a4..6f92a7955 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -5,7 +5,7 @@ #ifndef MAP_PC_GROUPS_H #define MAP_PC_GROUPS_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/conf.h" #include "common/db.h" @@ -96,10 +96,10 @@ struct pc_groups_interface { int (*get_idx) (GroupSettings *group); }; -struct pc_groups_interface *pcg; - #ifdef HERCULES_CORE void pc_groups_defaults(void); #endif // HERCULES_CORE +HPShared struct pc_groups_interface *pcg; + #endif /* MAP_PC_GROUPS_H */ diff --git a/src/map/pet.c b/src/map/pet.c index b612a9505..1ac6d117a 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -37,6 +37,7 @@ #include <string.h> struct pet_interface pet_s; +struct pet_interface *pet; #define MIN_PETTHINKTIME 100 diff --git a/src/map/pet.h b/src/map/pet.h index 06302c9b2..84df856bf 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -8,7 +8,7 @@ #include "map/map.h" // struct block_list #include "map/status.h" // enum sc_type #include "map/unit.h" // struct unit_data -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // NAME_LENGTH, struct s_pet #define MAX_PET_DB 300 @@ -153,10 +153,10 @@ struct pet_interface { int (*read_db) (); }; -struct pet_interface *pet; - #ifdef HERCULES_CORE void pet_defaults(void); #endif // HERCULES_CORE +HPShared struct pet_interface *pet; + #endif /* MAP_PET_H */ diff --git a/src/map/quest.c b/src/map/quest.c index 463a3395a..ddbd2f92d 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -39,6 +39,8 @@ struct quest_interface quest_s; struct quest_db *db_data[MAX_QUEST_DB]; ///< Quest database +struct quest_interface *quest; + /** * Searches a quest by ID. * diff --git a/src/map/quest.h b/src/map/quest.h index 9b5199625..ccb3e58f9 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -6,7 +6,7 @@ #define MAP_QUEST_H #include "map/map.h" // TBL_PC -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/conf.h" #define MAX_QUEST_DB (60355+1) // Highest quest ID + 1 @@ -61,10 +61,10 @@ struct quest_interface { struct quest_db *(*read_db_sub) (config_setting_t *cs, int n, const char *source); }; -struct quest_interface *quest; - #ifdef HERCULES_CORE void quest_defaults(void); #endif // HERCULES_CORE +HPShared struct quest_interface *quest; + #endif /* MAP_QUEST_H */ diff --git a/src/map/script.c b/src/map/script.c index 4fb196255..cbbf306d1 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -62,6 +62,7 @@ #endif struct script_interface script_s; +struct script_interface *script; static inline int GETVALUE(const unsigned char* buf, int i) { return (int)MakeDWord(MakeWord(buf[i], buf[i+1]), MakeWord(buf[i+2], 0)); diff --git a/src/map/script.h b/src/map/script.h index b3d2a3c8a..ad8ae82cb 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -6,7 +6,7 @@ #define MAP_SCRIPT_H #include "map/map.h" //EVENT_NAME_LENGTH -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" // struct item #include "common/sql.h" // Sql @@ -773,10 +773,10 @@ struct script_interface { void (*run_item_unequip_script) (struct map_session_data *sd, struct item_data *data, int oid); }; -struct script_interface *script; - #ifdef HERCULES_CORE void script_defaults(void); #endif // HERCULES_CORE +HPShared struct script_interface *script; + #endif /* MAP_SCRIPT_H */ diff --git a/src/map/searchstore.c b/src/map/searchstore.c index b9e23ae82..46b102ad5 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -15,6 +15,7 @@ #include "common/strlib.h" // safestrncpy struct searchstore_interface searchstore_s; +struct searchstore_interface *searchstore; /// retrieves search function by type static inline searchstore_search_t searchstore_getsearchfunc(unsigned char type) { diff --git a/src/map/searchstore.h b/src/map/searchstore.h index 2778740a5..24d7665e0 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -6,7 +6,7 @@ #define MAP_SEARCHSTORE_H #include "map/map.h" // MESSAGE_SIZE -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // MAX_SLOTS #include <time.h> @@ -95,10 +95,10 @@ struct searchstore_interface { bool (*result) (struct map_session_data* sd, unsigned int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const short* card, unsigned char refine); }; -struct searchstore_interface *searchstore; - #ifdef HERCULES_CORE void searchstore_defaults(void); #endif // HERCULES_CORE +HPShared struct searchstore_interface *searchstore; + #endif /* MAP_SEARCHSTORE_H */ diff --git a/src/map/skill.c b/src/map/skill.c index e3f85f8d1..00babb4f6 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -64,6 +64,8 @@ struct skill_interface skill_s; struct s_skill_dbs skilldbs; +struct skill_interface *skill; + //Since only mob-casted splash skills can hit ice-walls static inline int splash_target(struct block_list* bl) { #ifndef RENEWAL diff --git a/src/map/skill.h b/src/map/skill.h index aa0188be6..1db03bcd1 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -5,11 +5,9 @@ #ifndef MAP_SKILL_H #define MAP_SKILL_H -#include "config/core.h" // RENEWAL_CAST - #include "map/map.h" // struct block_list #include "map/status.h" // enum sc_type -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" // MAX_SKILL, struct square @@ -2084,10 +2082,10 @@ struct skill_interface { void (*get_requirement_unknown) (struct status_change *sc, struct map_session_data* sd, uint16 *skill_id, uint16 *skill_lv, struct skill_condition *req); }; -struct skill_interface *skill; - #ifdef HERCULES_CORE void skill_defaults(void); #endif // HERCULES_CORE +HPShared struct skill_interface *skill; + #endif /* MAP_SKILL_H */ diff --git a/src/map/status.c b/src/map/status.c index e70fb1eb1..dc99c1f95 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -46,6 +46,8 @@ struct status_interface status_s; struct s_status_dbs statusdbs; +struct status_interface *status; + /** * Returns the status change associated with a skill. * @param skill The skill to look up diff --git a/src/map/status.h b/src/map/status.h index 45a1300a0..274c64c5b 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -5,10 +5,8 @@ #ifndef MAP_STATUS_H #define MAP_STATUS_H -#include "config/core.h" // defType, RENEWAL, RENEWAL_ASPD - #include "common/conf.h" -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // NEW_CARTS struct block_list; @@ -2085,10 +2083,10 @@ struct status_interface { void (*read_job_db_sub) (int idx, const char *name, config_setting_t *jdb); }; -struct status_interface *status; - #ifdef HERCULES_CORE void status_defaults(void); #endif // HERCULES_CORE +HPShared struct status_interface *status; + #endif /* MAP_STATUS_H */ diff --git a/src/map/storage.c b/src/map/storage.c index 95194bc47..fb6e2ed45 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -28,6 +28,9 @@ struct storage_interface storage_s; struct guild_storage_interface gstorage_s; +struct storage_interface *storage; +struct guild_storage_interface *gstorage; + /*========================================== * Sort items in the warehouse *------------------------------------------*/ diff --git a/src/map/storage.h b/src/map/storage.h index 5f2c69f56..37f894f76 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -5,7 +5,7 @@ #ifndef MAP_STORAGE_H #define MAP_STORAGE_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct guild_storage; @@ -38,7 +38,6 @@ struct storage_interface { void (*sortitem) (struct item* items, unsigned int size); int (*reconnect_sub) (DBKey key, DBData *data, va_list ap); }; -struct storage_interface *storage; struct guild_storage_interface { struct DBMap* db; // int guild_id -> struct guild_storage* @@ -63,11 +62,12 @@ struct guild_storage_interface { DBData (*create) (DBKey key, va_list args); }; -struct guild_storage_interface *gstorage; - #ifdef HERCULES_CORE void storage_defaults(void); void gstorage_defaults(void); #endif // HERCULES_CORE +HPShared struct storage_interface *storage; +HPShared struct guild_storage_interface *gstorage; + #endif /* MAP_STORAGE_H */ diff --git a/src/map/trade.c b/src/map/trade.c index 2f6e2a648..8af3ddf4a 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -25,6 +25,7 @@ #include <string.h> struct trade_interface trade_s; +struct trade_interface *trade; /*========================================== * Initiates a trade request. diff --git a/src/map/trade.h b/src/map/trade.h index 85e73025c..010f67e26 100644 --- a/src/map/trade.h +++ b/src/map/trade.h @@ -5,6 +5,8 @@ #ifndef MAP_TRADE_H #define MAP_TRADE_H +#include "common/hercules.h" + //Max distance from traders to enable a trade to take place. //TODO: battle_config candidate? #define TRADE_DISTANCE 2 @@ -23,10 +25,10 @@ struct trade_interface { void (*commit) (struct map_session_data *sd); }; -struct trade_interface *trade; - #ifdef HERCULES_CORE void trade_defaults(void); #endif // HERCULES_CORE +HPShared struct trade_interface *trade; + #endif /* MAP_TRADE_H */ diff --git a/src/map/unit.c b/src/map/unit.c index 60911b85a..33360584a 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -49,6 +49,7 @@ const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; struct unit_interface unit_s; +struct unit_interface *unit; /** * Returns the unit_data for the given block_list. If the object is using diff --git a/src/map/unit.h b/src/map/unit.h index 00fff5981..0d970ca16 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -8,7 +8,7 @@ #include "map/clif.h" // clr_type #include "map/path.h" // struct walkpath_data #include "map/skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset -#include "common/cbasetypes.h" +#include "common/hercules.h" struct map_session_data; struct block_list; @@ -84,9 +84,6 @@ struct view_data { unsigned dead_sit : 2; }; -extern const short dirx[8]; -extern const short diry[8]; - struct unit_interface { int (*init) (bool minimal); int (*final) (void); @@ -139,8 +136,13 @@ struct unit_interface { int (*free) (struct block_list *bl, clr_type clrtype); }; -struct unit_interface *unit; +#ifdef HERCULES_CORE +extern const short dirx[8]; +extern const short diry[8]; void unit_defaults(void); +#endif // HERCULES_CORE + +HPShared struct unit_interface *unit; #endif /* MAP_UNIT_H */ diff --git a/src/map/vending.c b/src/map/vending.c index d0f0dee00..80c79984e 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -25,6 +25,7 @@ #include <string.h> struct vending_interface vending_s; +struct vending_interface *vending; /// Returns an unique vending shop id. static inline unsigned int getid(void) { diff --git a/src/map/vending.h b/src/map/vending.h index 189189227..2f624fac7 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -5,7 +5,7 @@ #ifndef MAP_VENDING_H #define MAP_VENDING_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct map_session_data; @@ -32,10 +32,10 @@ struct vending_interface { bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s); }; -struct vending_interface *vending; - #ifdef HERCULES_CORE void vending_defaults(void); #endif // HERCULES_CORE +HPShared struct vending_interface *vending; + #endif /* MAP_VENDING_H */ diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c index 68910f503..19d7ae2c5 100644 --- a/src/plugins/HPMHooking.c +++ b/src/plugins/HPMHooking.c @@ -2,7 +2,7 @@ // See the LICENSE file // Sample Hercules Plugin -#include "common/HPMi.h" +#include "common/hercules.h" #include "common/db.h" #include "common/malloc.h" #include "common/mmo.h" @@ -11,7 +11,6 @@ #if defined (HPMHOOKING_LOGIN) #define HPM_SERVER_TYPE SERVER_TYPE_LOGIN #define HPM_CORE_INCLUDE "HPMHooking/HPMHooking_login.HPMHooksCore.inc" -#define HPM_SYMBOL_INCLUDE "HPMHooking/HPMHooking_login.GetSymbol.inc" #define HPM_HOOKS_INCLUDE "HPMHooking/HPMHooking_login.Hooks.inc" #define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking_login.HookingPoints.inc" #define HPM_SOURCES_INCLUDE "HPMHooking/HPMHooking_login.sources.inc" @@ -19,7 +18,6 @@ #elif defined (HPMHOOKING_CHAR) #define HPM_SERVER_TYPE SERVER_TYPE_CHAR #define HPM_CORE_INCLUDE "HPMHooking/HPMHooking_char.HPMHooksCore.inc" -#define HPM_SYMBOL_INCLUDE "HPMHooking/HPMHooking_char.GetSymbol.inc" #define HPM_HOOKS_INCLUDE "HPMHooking/HPMHooking_char.Hooks.inc" #define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking_char.HookingPoints.inc" #define HPM_SOURCES_INCLUDE "HPMHooking/HPMHooking_char.sources.inc" @@ -43,7 +41,6 @@ #elif defined (HPMHOOKING_MAP) #define HPM_SERVER_TYPE SERVER_TYPE_MAP #define HPM_CORE_INCLUDE "HPMHooking/HPMHooking_map.HPMHooksCore.inc" -#define HPM_SYMBOL_INCLUDE "HPMHooking/HPMHooking_map.GetSymbol.inc" #define HPM_HOOKS_INCLUDE "HPMHooking/HPMHooking_map.Hooks.inc" #define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking_map.HookingPoints.inc" #define HPM_SOURCES_INCLUDE "HPMHooking/HPMHooking_map.sources.inc" @@ -69,7 +66,6 @@ #include "map/mercenary.h" #include "map/mob.h" #include "map/npc.h" -#include "map/npc.h" #include "map/party.h" #include "map/path.h" #include "map/pc.h" @@ -85,7 +81,6 @@ #else #define HPM_SERVER_TYPE SERVER_TYPE_UNKNOWN #define HPM_CORE_INCLUDE "HPMHooking/HPMHooking.HPMHooksCore.inc" -#define HPM_SYMBOL_INCLUDE "HPMHooking/HPMHooking.GetSymbol.inc" #define HPM_HOOKS_INCLUDE "HPMHooking/HPMHooking.Hooks.inc" #define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking.HookingPoints.inc" #define HPM_SOURCES_INCLUDE "HPMHooking/HPMHooking.sources.inc" @@ -149,10 +144,10 @@ HPExport void server_post_final (void) { } HPExport const char *Hooked (bool *fr) { + const char *ret = HPM_shared_symbols(HPM_SERVER_TYPE); + if (ret) + return ret; HPMforce_return = fr; - if (!(DB = GET_SYMBOL("DB"))) return "DB"; - if (!(iMalloc = GET_SYMBOL("iMalloc"))) return "iMalloc"; -#include HPM_SYMBOL_INCLUDE HPM_HP_load(); return NULL; } diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index 2741ce468..ff2feefa0 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -3,7 +3,7 @@ #include "config/core.h" -#include "common/HPMi.h" +#include "common/hercules.h" #include "common/cbasetypes.h" #include "common/conf.h" #include "common/malloc.h" @@ -141,7 +141,7 @@ int db2sql(config_setting_t *entry, int n, const char *source) { StrBuf->Printf(&buf, "'%u',", it->flag.bindonequip?1:0); // forceserial - StrBuf->Printf(&buf, "'%u',", it->flag.force_serial?1:0); + StrBuf->Printf(&buf, "'%u',", it->flag.force_serial?1:0); // buyingstore StrBuf->Printf(&buf, "'%u',", it->flag.buyingstore?1:0); @@ -357,21 +357,14 @@ CMDLINEARG(db2sql) map->minimal = torun = true; return true; } -HPExport void server_preinit (void) { - SQL = GET_SYMBOL("SQL"); - itemdb = GET_SYMBOL("itemdb"); - map = GET_SYMBOL("map"); - strlib = GET_SYMBOL("strlib"); - iMalloc = GET_SYMBOL("iMalloc"); - libconfig = GET_SYMBOL("libconfig"); - StrBuf = GET_SYMBOL("StrBuf"); +HPExport void server_preinit(void) { addArg("--db2sql",false,db2sql,NULL); } -HPExport void plugin_init (void) { +HPExport void plugin_init(void) { addCPCommand("server:tools:db2sql",db2sql); } -HPExport void server_online (void) { +HPExport void server_online(void) { if( torun ) do_db2sql(); } diff --git a/src/plugins/dbghelpplug.c b/src/plugins/dbghelpplug.c index 6ed16d7a6..b5f1fe485 100644 --- a/src/plugins/dbghelpplug.c +++ b/src/plugins/dbghelpplug.c @@ -5,8 +5,9 @@ // Ported from eAthena Dev Team's version @ http://eathena-project.googlecode.com/svn/trunk/src/plugins/dbghelpplug.c // Currently supported dbghelp 5.1 +#include "common/hercules.h" + #include "common/sysinfo.h" -#include "common/HPMi.h" #include "common/HPMDataCheck.h" @@ -108,8 +109,6 @@ typedef enum _SymTag { */ #endif /* _NO_CVCONST_H */ -struct sysinfo_interface *sysinfo; - ///////////////////////////////////////////////////////////////////// // dbghelp function prototypes // @@ -1800,7 +1799,6 @@ static LPTOP_LEVEL_EXCEPTION_FILTER previousFilter; **/ HPExport void plugin_init (void) { previousFilter = SetUnhandledExceptionFilter(Dhp__UnhandledExceptionFilter); - sysinfo = GET_SYMBOL("sysinfo"); } /** diff --git a/src/plugins/sample.c b/src/plugins/sample.c index d11c082b4..58be9c05f 100644 --- a/src/plugins/sample.c +++ b/src/plugins/sample.c @@ -2,7 +2,7 @@ // See the LICENSE file // Sample Hercules Plugin -#include "common/HPMi.h" +#include "common/hercules.h" /* Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces) */ #include "common/malloc.h" #include "common/mmo.h" #include "common/socket.h" @@ -11,7 +11,7 @@ #include "map/pc.h" #include "map/script.h" -#include "common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */ +#include "common/HPMDataCheck.h" /* should always be the last Hercules file included! (if you don't make it last, it'll intentionally break compile time) */ #include <stdio.h> #include <stdlib.h> @@ -121,17 +121,8 @@ HPExport void plugin_init (void) { char *server_name; /* core vars */ - server_type = GET_SYMBOL("SERVER_TYPE"); - server_name = GET_SYMBOL("SERVER_NAME"); - - /* core interfaces */ - iMalloc = GET_SYMBOL("iMalloc"); - - /* map-server interfaces */ - script = GET_SYMBOL("script"); - clif = GET_SYMBOL("clif"); - pc = GET_SYMBOL("pc"); - strlib = GET_SYMBOL("strlib"); + server_type = GET_SYMBOL("SERVER_TYPE"); // FIXME + server_name = GET_SYMBOL("SERVER_NAME"); // FIXME ShowInfo ("Server type is "); diff --git a/src/plugins/script_mapquit.c b/src/plugins/script_mapquit.c index e44582db7..8ed108f82 100644 --- a/src/plugins/script_mapquit.c +++ b/src/plugins/script_mapquit.c @@ -18,7 +18,7 @@ /// mapquit() script command -#include "common/HPMi.h" +#include "common/hercules.h" #include "map/map.h" #include "map/script.h" @@ -39,8 +39,6 @@ BUILDIN(mapquit) { return true; } HPExport void server_preinit(void) { - map = GET_SYMBOL("map"); - script = GET_SYMBOL("script"); } HPExport void plugin_init(void) { addScriptCommand("mapquit", "?", mapquit); |