summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorshennetsind <shennetsind@users.noreply.github.com>2015-03-10 16:14:21 -0300
committershennetsind <shennetsind@users.noreply.github.com>2015-03-10 16:14:21 -0300
commitc091b38e4400560ca0644afef9f08e4f9d6835b0 (patch)
treebd4ab3aeb652db6dd6283081e55138ab68e01fd7 /src
parent308677fb86dc98ed9c0adc18dea396c1cd5f6ff6 (diff)
parent0bd4a0178cd5beb8bee955777afe32392d75afa9 (diff)
downloadhercules-c091b38e4400560ca0644afef9f08e4f9d6835b0.tar.gz
hercules-c091b38e4400560ca0644afef9f08e4f9d6835b0.tar.bz2
hercules-c091b38e4400560ca0644afef9f08e4f9d6835b0.tar.xz
hercules-c091b38e4400560ca0644afef9f08e4f9d6835b0.zip
Merge pull request #461 from dastgir/bg_HPM
Battleground Data to HPM Struct
Diffstat (limited to 'src')
-rw-r--r--src/common/HPMi.h5
-rw-r--r--src/map/HPMmap.c4
-rw-r--r--src/map/battleground.c23
-rw-r--r--src/map/battleground.h4
4 files changed, 35 insertions, 1 deletions
diff --git a/src/common/HPMi.h b/src/common/HPMi.h
index d4b2e323c..10cf4fd9f 100644
--- a/src/common/HPMi.h
+++ b/src/common/HPMi.h
@@ -83,6 +83,7 @@ enum HPluginDataTypes {
HPDT_MOBDB,
HPDT_MOBDATA,
HPDT_ITEMDATA,
+ HPDT_BGDATA,
};
/* used in macros and conf storage */
@@ -146,6 +147,10 @@ enum HPluginConfType {
#define addToITEMDATA(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_ITEMDATA,HPMi->pid,(ptr),(data),(index),(autofree)))
#define getFromITEMDATA(ptr,index) (HPMi->getFromHPData(HPDT_ITEMDATA,HPMi->pid,(ptr),(index)))
#define removeFromITEMDATA(ptr,index) (HPMi->removeFromHPData(HPDT_ITEMDATA,HPMi->pid,(ptr),(index)))
+/* battleground_data */
+#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) \
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index 3da49c3b9..d6a1bd8ef 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -114,6 +114,10 @@ bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataType
ret->HPDataSRCPtr = (void**)(&((struct item_data *)ptr)->hdata);
ret->hdatac = &((struct item_data *)ptr)->hdatac;
break;
+ case HPDT_BGDATA:
+ ret->HPDataSRCPtr = (void**)(&((struct battleground_data *)ptr)->hdata);
+ ret->hdatac = &((struct battleground_data *)ptr)->hdatac;
+ break;
default:
return false;
}
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 2d4ba6bf1..f0bad2b3d 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -22,6 +22,7 @@
#include "pet.h"
#include "../common/cbasetypes.h"
#include "../common/conf.h"
+#include "../common/HPM.h"
#include "../common/malloc.h"
#include "../common/nullpo.h"
#include "../common/showmsg.h"
@@ -856,9 +857,27 @@ void do_init_battleground(bool minimal) {
bg->config_read();
}
+/**
+ * @see DBApply
+ */
+int bg_team_db_final(DBKey key, DBData *data, va_list ap) {
+ struct battleground_data* bgd = DB->data2ptr(data);
+ int i;
+ for(i = 0; i < bgd->hdatac; i++ ) {
+ if( bgd->hdata[i]->flag.free ) {
+ aFree(bgd->hdata[i]->data);
+ }
+ aFree(bgd->hdata[i]);
+ }
+ if( bgd->hdata )
+ aFree(bgd->hdata);
+
+ return 0;
+}
+
void do_final_battleground(void)
{
- db_destroy(bg->team_db);
+ bg->team_db->destroy(bg->team_db,bg->team_db_final);
if (bg->arena) {
int i;
@@ -868,6 +887,7 @@ void do_final_battleground(void)
}
aFree(bg->arena);
}
+
}
void battleground_defaults(void) {
bg = &bg_s;
@@ -911,6 +931,7 @@ void battleground_defaults(void) {
bg->send_xy_timer_sub = bg_send_xy_timer_sub;
bg->send_xy_timer = bg_send_xy_timer;
bg->afk_timer = bg_afk_timer;
+ bg->team_db_final = bg_team_db_final;
/* */
bg->str2teamtype = bg_str2teamtype;
/* */
diff --git a/src/map/battleground.h b/src/map/battleground.h
index 9878d6be0..87d56516a 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -48,6 +48,9 @@ struct battleground_data {
// Logout Event
char logout_event[EVENT_NAME_LENGTH];
char die_event[EVENT_NAME_LENGTH];
+ /* HPM Custom Struct */
+ struct HPluginData **hdata;
+ unsigned int hdatac;
};
struct bg_arena {
@@ -112,6 +115,7 @@ struct battleground_interface {
int (*send_xy_timer_sub) (DBKey key, DBData *data, va_list ap);
int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data);
int (*afk_timer) (int tid, int64 tick, int id, intptr_t data);
+ int (*team_db_final) (DBKey key, DBData *data, va_list ap);
/* */
enum bg_queue_types (*str2teamtype) (const char *str);
/* */