diff options
Diffstat (limited to 'src/common/HPMi.h')
-rw-r--r-- | src/common/HPMi.h | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 10cf4fd9f..e03f52e3b 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -4,26 +4,18 @@ #ifndef COMMON_HPMI_H #define COMMON_HPMI_H -#include "../common/cbasetypes.h" -#include "../common/console.h" -#include "../common/core.h" -#include "../common/sql.h" +#include "common/hercules.h" +#include "common/console.h" +#include "common/core.h" +#include "common/showmsg.h" +#include "common/sql.h" struct script_state; struct AtCommandInfo; struct socket_data; struct map_session_data; -#ifdef WIN32 - #define HPExport __declspec(dllexport) -#else - #define HPExport -#endif - -/* after */ -#include "../common/showmsg.h" - -#define HPM_VERSION "1.0" +#define HPM_VERSION "1.1" #define HPM_ADDCONF_LENGTH 40 struct hplugin_info { @@ -39,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 { @@ -84,11 +71,12 @@ enum HPluginDataTypes { HPDT_MOBDATA, HPDT_ITEMDATA, HPDT_BGDATA, + HPDT_AUTOTRADE_VEND, }; /* used in macros and conf storage */ enum HPluginConfType { - HPCT_BATTLE, /* battle-conf (map-server */ + HPCT_BATTLE, /* battle-conf (map-server) */ HPCT_LOGIN, /* login-server.conf (login-server) */ HPCT_CHAR, /* char-server.conf (char-server) */ HPCT_CHAR_INTER, /* inter-server.conf (char-server) */ @@ -151,34 +139,42 @@ enum HPluginConfType { #define addToBGDATA(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_BGDATA,HPMi->pid,(ptr),(data),(index),(autofree))) #define getFromBGDATA(ptr,index) (HPMi->getFromHPData(HPDT_BGDATA,HPMi->pid,(ptr),(index))) #define removeFromBGDATA(ptr,index) (HPMi->removeFromHPData(HPDT_BGDATA,HPMi->pid,(ptr),(index))) - -/* HPMi->addCommand */ -#define addAtcommand(cname,funcname) \ - if ( HPMi->addCommand != NULL ) { \ +/* autotrade_vending */ +#define addToATVEND(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_AUTOTRADE_VEND,HPMi->pid,(ptr),(data),(index),(autofree))) +#define getFromATVEND(ptr,index) (HPMi->getFromHPData(HPDT_AUTOTRADE_VEND,HPMi->pid,(ptr),(index))) +#define removeFromATVEND(ptr,index) (HPMi->removeFromHPData(HPDT_AUTOTRADE_VEND,HPMi->pid,(ptr),(index))) + +/// HPMi->addCommand +#define addAtcommand(cname,funcname) do { \ + if (HPMi->addCommand != NULL) { \ HPMi->addCommand(cname,atcommand_ ## funcname); \ } else { \ ShowWarning("HPM (%s):addAtcommand(\"%s\",%s) failed, addCommand sub is NULL!\n",pinfo.name,cname,# funcname);\ - } -/* HPMi->addScript */ -#define addScriptCommand(cname,scinfo,funcname) \ - if ( HPMi->addScript != NULL ) { \ + } \ +} while(0) +/// HPMi->addScript +#define addScriptCommand(cname,scinfo,funcname) do { \ + if (HPMi->addScript != NULL) { \ HPMi->addScript(cname,scinfo,buildin_ ## funcname, false); \ } else { \ ShowWarning("HPM (%s):addScriptCommand(\"%s\",\"%s\",%s) failed, addScript sub is NULL!\n",pinfo.name,cname,scinfo,# funcname);\ - } -#define addScriptCommandDeprecated(cname,scinfo,funcname) \ - if ( HPMi->addScript != NULL ) { \ + } \ +} while(0) +#define addScriptCommandDeprecated(cname,scinfo,funcname) do { \ + if (HPMi->addScript != NULL) { \ HPMi->addScript(cname,scinfo,buildin_ ## funcname, true); \ } else { \ ShowWarning("HPM (%s):addScriptCommandDeprecated(\"%s\",\"%s\",%s) failed, addScript sub is NULL!\n",pinfo.name,cname,scinfo,# funcname);\ - } -/* HPMi->addCPCommand */ -#define addCPCommand(cname,funcname) \ - if ( HPMi->addCPCommand != NULL ) { \ + } \ +} while(0) +/// HPMi->addCPCommand +#define addCPCommand(cname,funcname) do { \ + if (HPMi->addCPCommand != NULL) { \ HPMi->addCPCommand(cname,console_parse_ ## funcname); \ } else { \ ShowWarning("HPM (%s):addCPCommand(\"%s\",%s) failed, addCPCommand sub is NULL!\n",pinfo.name,cname,# funcname);\ - } + } \ +} while(0) /* HPMi->addPacket */ #define addPacket(cmd,len,receive,point) HPMi->addPacket(cmd,len,receive,point,HPMi->pid) /* HPMi->addBattleConf */ @@ -200,7 +196,7 @@ enum HPluginConfType { #define addGroupPermission(pcgname,maskptr) HPMi->addPCGPermission(HPMi->pid,pcgname,&maskptr) /* Hercules Plugin Mananger Include Interface */ -HPExport struct HPMi_interface { +struct HPMi_interface { /* */ unsigned int pid; /* */ @@ -224,10 +220,17 @@ HPExport struct HPMi_interface { bool (*addConf) (unsigned int pluginID, enum HPluginConfType type, char *name, void (*func) (const char *val)); /* pc group permission */ void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask); + + 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; -#endif +HPExport void *(*import_symbol) (char *name, unsigned int pID); +#define HPM_SYMBOL(n, s) ((s) = import_symbol((n),HPMi->pid)) +#endif // !HERCULES_CORE + #endif /* COMMON_HPMI_H */ |