summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authordastgir <dastgirpojee@rocketmail.com>2015-09-09 09:28:39 -0400
committerdastgir <dastgirpojee@rocketmail.com>2015-09-09 10:03:58 -0400
commit0af11c16f1daf23d77a237b9452945706e9b40bc (patch)
tree004aa5258eb7eb37a29b8dc04a9df6b357ee0857 /src/map
parentc76aa5f4843a521b1839875bf6c139f4658bd6d1 (diff)
downloadhercules-0af11c16f1daf23d77a237b9452945706e9b40bc.tar.gz
hercules-0af11c16f1daf23d77a237b9452945706e9b40bc.tar.bz2
hercules-0af11c16f1daf23d77a237b9452945706e9b40bc.tar.xz
hercules-0af11c16f1daf23d77a237b9452945706e9b40bc.zip
Autotrade Struct to HPM
Diffstat (limited to 'src/map')
-rw-r--r--src/map/HPMmap.c4
-rw-r--r--src/map/pc.c31
-rw-r--r--src/map/pc.h4
3 files changed, 38 insertions, 1 deletions
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);
};