summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/HPMi.h7
-rw-r--r--src/map/HPMmap.c4
-rw-r--r--src/map/pc.c31
-rw-r--r--src/map/pc.h4
4 files changed, 44 insertions, 2 deletions
diff --git a/src/common/HPMi.h b/src/common/HPMi.h
index bd8d8fe64..e03f52e3b 100644
--- a/src/common/HPMi.h
+++ b/src/common/HPMi.h
@@ -71,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) */
@@ -138,6 +139,10 @@ 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)))
+/* 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 { \
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index a59fbb6ef..0bd231e3a 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -128,6 +128,10 @@ bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataType
ret->HPDataSRCPtr = (void**)(&((struct battleground_data *)ptr)->hdata);
ret->hdatac = &((struct battleground_data *)ptr)->hdatac;
break;
+ case HPDT_AUTOTRADE_VEND:
+ ret->HPDataSRCPtr = (void**)(&((struct autotrade_vending *)ptr)->hdata);
+ ret->hdatac = &((struct autotrade_vending *)ptr)->hdatac;
+ break;
default:
return false;
}
diff --git a/src/map/pc.c b/src/map/pc.c
index 49b8f1f94..36bcbae88 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -40,6 +40,7 @@
#include "common/cbasetypes.h"
#include "common/conf.h"
#include "common/core.h" // get_svn_revision()
+#include "common/HPM.h"
#include "common/malloc.h"
#include "common/mmo.h" // NAME_LENGTH, MAX_CARTS, NEW_CARTS
#include "common/nullpo.h"
@@ -11354,9 +11355,36 @@ void pc_autotrade_populate(struct map_session_data *sd) {
pc->autotrade_update(sd,PAUC_START);
+ for(i = 0; i < data->hdatac; i++ ) {
+ if( data->hdata[i]->flag.free ) {
+ aFree(data->hdata[i]->data);
+ }
+ aFree(data->hdata[i]);
+ }
+ if( data->hdata )
+ aFree(data->hdata);
+
idb_remove(pc->at_db, sd->status.char_id);
}
+/**
+ * @see DBApply
+ */
+int pc_autotrade_final(DBKey key, DBData *data, va_list ap) {
+ struct autotrade_vending* at_v = DB->data2ptr(data);
+ int i;
+ for(i = 0; i < at_v->hdatac; i++ ) {
+ if( at_v->hdata[i]->flag.free ) {
+ aFree(at_v->hdata[i]->data);
+ }
+ aFree(at_v->hdata[i]);
+ }
+ if( at_v->hdata )
+ aFree(at_v->hdata);
+
+ return 0;
+}
+
//Checks if the given class value corresponds to a player class. [Skotlex]
//JOB_NOVICE isn't checked for class_ is supposed to be unsigned
bool pc_db_checkid(unsigned int class_)
@@ -11373,7 +11401,7 @@ bool pc_db_checkid(unsigned int class_)
void do_final_pc(void) {
db_destroy(pc->itemcd_db);
- db_destroy(pc->at_db);
+ pc->at_db->destroy(pc->at_db,pc->autotrade_final);
pcg->final();
@@ -11733,6 +11761,7 @@ void pc_defaults(void) {
pc->autotrade_start = pc_autotrade_start;
pc->autotrade_prepare = pc_autotrade_prepare;
pc->autotrade_populate = pc_autotrade_populate;
+ pc->autotrade_final = pc_autotrade_final;
pc->check_job_name = pc_check_job_name;
}
diff --git a/src/map/pc.h b/src/map/pc.h
index 85bbd2016..26df30527 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -757,6 +757,9 @@ struct autotrade_vending {
struct item list[MAX_VENDING];
struct s_vending vending[MAX_VENDING];
unsigned char vend_num;
+ /* HPM Custom Struct */
+ struct HPluginData **hdata;
+ unsigned int hdatac;
};
/*=====================================
@@ -1066,6 +1069,7 @@ END_ZEROED_BLOCK; /* End */
void (*autotrade_start) (struct map_session_data *sd);
void (*autotrade_prepare) (struct map_session_data *sd);
void (*autotrade_populate) (struct map_session_data *sd);
+ int (*autotrade_final) (DBKey key, DBData *data, va_list ap);
int (*check_job_name) (const char *name);
};