summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-06-15 20:52:44 +0200
committerHaru <haru@dotalux.com>2015-08-15 00:51:42 +0200
commit51b7adcf4e5b2a347081ec9a6903102c4909a404 (patch)
tree39a080440b4bd78b786c8f9372f7883b55fd3ba9 /src/plugins
parentf8edb93a6a26cd81eeaad0eac23e33da7740c8b4 (diff)
downloadhercules-51b7adcf4e5b2a347081ec9a6903102c4909a404.tar.gz
hercules-51b7adcf4e5b2a347081ec9a6903102c4909a404.tar.bz2
hercules-51b7adcf4e5b2a347081ec9a6903102c4909a404.tar.xz
hercules-51b7adcf4e5b2a347081ec9a6903102c4909a404.zip
HPM compatibility improvements
Improved compatibility, portability and standards conformance. - Since it is not possible to portably and reliably re-use the core's symbols in plugins, symbols are no longer exported unless explicitly required, in the UNIX builds. This mimics the Windows behavior and adds HPM compatibility to OSes such as FreeBSD. Credits to Andrei Karas for making this possible. - For convenience, it is no longer necessary to call GET_SYMBOL, since the plugin will automatically import all the available symbols when it's loaded, depending on the included headers. - Plugins are now supposed to include the "common/hercules.h" header before including anything else. Incluing common/HPMi.h, common/cbasetypes.h or conf/core.h is no longer necessary, as those are guaranteed to be automatically included by hercules.h. - HPM API version bumped to 1.1. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/HPMHooking.c13
-rw-r--r--src/plugins/db2sql.c17
-rw-r--r--src/plugins/dbghelpplug.c6
-rw-r--r--src/plugins/sample.c17
-rw-r--r--src/plugins/script_mapquit.c4
5 files changed, 16 insertions, 41 deletions
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);