summaryrefslogtreecommitdiff
path: root/src/map/HPMmap.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-10-24 05:50:20 -0200
committershennetsind <ind@henn.et>2013-10-24 05:50:20 -0200
commit8b07c677e351056b0d23fbc3726f80829ae4d253 (patch)
tree7020d88a5e56975c1a40e078246fbdd20408f548 /src/map/HPMmap.c
parent45d8123e73ea9b213ad57c32524286fe44a08721 (diff)
downloadhercules-8b07c677e351056b0d23fbc3726f80829ae4d253.tar.gz
hercules-8b07c677e351056b0d23fbc3726f80829ae4d253.tar.bz2
hercules-8b07c677e351056b0d23fbc3726f80829ae4d253.tar.xz
hercules-8b07c677e351056b0d23fbc3726f80829ae4d253.zip
Fixed Bug #7759
Modified how @commands from HPM plugins are handled so that they are persistent to @reloadatcommand (also prepares for the future load/unload during runtime feature) http://hercules.ws/board/tracker/issue-7759-reloadatcommand/ Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/HPMmap.c')
-rw-r--r--src/map/HPMmap.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index 3ba9ae725..ca4a7a2e8 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -11,6 +11,7 @@
#include "map.h"
//
+#include "atcommand.h"
#include "chat.h"
#include "chrif.h"
#include "duel.h"
@@ -33,6 +34,18 @@
#include <string.h>
#include <time.h>
+struct HPM_atcommand_list {
+ //tracking currently not enabled
+ // - requires modifying how plugins calls atcommand creation
+ // - needs load/unload during runtime support
+ //unsigned int pID;/* plugin id */
+ char name[ATCOMMAND_LENGTH];
+ AtCommandFunc func;
+};
+
+struct HPM_atcommand_list *atcommand_list = NULL;
+unsigned int atcommand_list_items = 0;
+
void HPM_map_addToMSD(struct map_session_data *sd, void *data, unsigned int id, unsigned int type, bool autofree) {
struct HPluginData *HPData;
unsigned int i;
@@ -103,4 +116,40 @@ void HPM_map_plugin_load_sub(struct hplugin *plugin) {
plugin->hpi->addToMSD = HPM->import_symbol("addToMSD",plugin->idx);
plugin->hpi->getFromMSD = HPM->import_symbol("getFromMSD",plugin->idx);
plugin->hpi->removeFromMSD = HPM->import_symbol("removeFromMSD",plugin->idx);
-} \ No newline at end of file
+}
+
+bool HPM_map_add_atcommand(char *name, AtCommandFunc func) {
+ unsigned int i = 0;
+
+ for(i = 0; i < atcommand_list_items; i++) {
+ if( !strcmpi(atcommand_list[i].name,name) ) {
+ ShowDebug("HPM_map_add_atcommand: duplicate command '%s', skipping...\n", name);
+ return false;
+ }
+ }
+
+ i = atcommand_list_items;
+
+ RECREATE(atcommand_list, struct HPM_atcommand_list , ++atcommand_list_items);
+
+ safestrncpy(atcommand_list[i].name, name, sizeof(atcommand_list[i].name));
+ atcommand_list[i].func = func;
+
+ return true;
+}
+
+void HPM_map_atcommands(void) {
+ unsigned int i;
+
+ for(i = 0; i < atcommand_list_items; i++) {
+ if( !atcommand->add(atcommand_list[i].name,atcommand_list[i].func) ) {
+ ShowDebug("HPM_map_atcommands: duplicate command '%s', skipping...\n", atcommand_list[i].name);
+ continue;
+ }
+ }
+}
+
+void HPM_map_do_final(void) {
+ if( atcommand_list )
+ aFree(atcommand_list);
+}