summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/map.c10
-rw-r--r--src/map/pc.c11
-rw-r--r--src/map/pc.h3
-rw-r--r--src/map/script.c20
-rw-r--r--src/map/unit.c5
5 files changed, 20 insertions, 29 deletions
diff --git a/src/map/map.c b/src/map/map.c
index dd5baa626..fff1593a4 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1802,16 +1802,16 @@ int map_quit(struct map_session_data *sd) {
skill->cooldown_save(sd);
pc->itemcd_do(sd,false);
- for( i = 0; i < sd->queues_count; i++ ) {
- struct script_queue *queue = script->queue(sd->queues[i]);
+ for (i = 0; i < VECTOR_LENGTH(sd->script_queues); i++) {
+ struct script_queue *queue = script->queue(VECTOR_INDEX(sd->script_queues, i));
if (queue && queue->event_logout[0] != '\0') {
npc->event(sd, queue->event_logout, 0);
}
}
/* two times, the npc event above may assign a new one or delete others */
- for( i = 0; i < sd->queues_count; i++ ) {
- if( sd->queues[i] != -1 )
- script->queue_remove(sd->queues[i],sd->status.account_id);
+ while (VECTOR_LENGTH(sd->script_queues)) {
+ int qid = VECTOR_LAST(sd->script_queues);
+ script->queue_remove(qid, sd->status.account_id);
}
npc->script_event(sd, NPCE_LOGOUT);
diff --git a/src/map/pc.c b/src/map/pc.c
index 1b7fcd610..43adf331b 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1126,8 +1126,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
sd->bg_queue.client_has_bg_data = 0;
sd->bg_queue.type = 0;
- sd->queues = NULL;
- sd->queues_count = 0;
+ VECTOR_INIT(sd->script_queues);
sd->state.dialog = 0;
@@ -5526,8 +5525,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short map_index, int x, int
int i;
sd->state.pmap = sd->bl.m;
- for( i = 0; i < sd->queues_count; i++ ) {
- struct script_queue *queue = script->queue(sd->queues[i]);
+ for (i = 0; i < VECTOR_LENGTH(sd->script_queues); i++) {
+ struct script_queue *queue = script->queue(VECTOR_INDEX(sd->script_queues, i));
if (queue && queue->event_mapchange[0] != '\0') {
pc->setregstr(sd, script->add_str("@Queue_Destination_Map$"), map->list[m].name);
npc->event(sd, queue->event_mapchange, 0);
@@ -7634,8 +7633,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
npc->event(sd, bgd->die_event, 0);
}
- for( i = 0; i < sd->queues_count; i++ ) {
- struct script_queue *queue = script->queue(sd->queues[i]);
+ for (i = 0; i < VECTOR_LENGTH(sd->script_queues); i++ ) {
+ struct script_queue *queue = script->queue(VECTOR_INDEX(sd->script_queues, i));
if (queue && queue->event_death[0] != '\0')
npc->event(sd, queue->event_death, 0);
}
diff --git a/src/map/pc.h b/src/map/pc.h
index 2c8b24acf..62571f12a 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -531,8 +531,7 @@ END_ZEROED_BLOCK;
enum bg_queue_types type;
} bg_queue;
- int *queues;
- unsigned int queues_count;
+ VECTOR_DECL(int) script_queues;
/* Made Possible Thanks to Yommy~! */
unsigned int cryptKey; ///< Packet obfuscation key to be used for the next received packet
diff --git a/src/map/script.c b/src/map/script.c
index bf477968c..cfc7ed052 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -18891,12 +18891,8 @@ bool script_hqueue_add(int idx, int var)
VECTOR_PUSH(queue->entries, var);
if (var >= START_ACCOUNT_NUM && (sd = map->id2sd(var)) != NULL) {
- ARR_FIND(0, sd->queues_count, i, sd->queues[i] == -1);
-
- if (i == sd->queues_count)
- RECREATE(sd->queues, int, ++sd->queues_count);
-
- sd->queues[i] = idx;
+ VECTOR_ENSURE(sd->script_queues, 1, 1);
+ VECTOR_PUSH(sd->script_queues, idx);
}
return true;
}
@@ -18952,10 +18948,10 @@ bool script_hqueue_remove(int idx, int var)
VECTOR_ERASE(queue->entries, i);
if (var >= START_ACCOUNT_NUM && (sd = map->id2sd(var)) != NULL) {
- ARR_FIND(0, sd->queues_count, i, sd->queues[i] == -1);
+ ARR_FIND(0, VECTOR_LENGTH(sd->script_queues), i, VECTOR_INDEX(sd->script_queues, i) == queue->id);
- if (i != sd->queues_count)
- sd->queues[i] = -1;
+ if (i != VECTOR_LENGTH(sd->script_queues))
+ VECTOR_ERASE(sd->script_queues, i);
}
return true;
}
@@ -19107,10 +19103,10 @@ bool script_hqueue_clear(int idx)
if (entry >= START_ACCOUNT_NUM && (sd = map->id2sd(entry)) != NULL) {
int i;
- ARR_FIND(0, sd->queues_count, i, sd->queues[i] == idx);
+ ARR_FIND(0, VECTOR_LENGTH(sd->script_queues), i, VECTOR_INDEX(sd->script_queues, i) == queue->id);
- if (i != sd->queues_count)
- sd->queues[i] = -1;
+ if (i != VECTOR_LENGTH(sd->script_queues))
+ VECTOR_ERASE(sd->script_queues, i);
}
}
VECTOR_CLEAR(queue->entries);
diff --git a/src/map/unit.c b/src/map/unit.c
index 7c253c5c2..3046db9e1 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -2645,10 +2645,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
aFree(sd->instance);
sd->instance = NULL;
}
- if( sd->queues != NULL ) {
- aFree(sd->queues);
- sd->queues = NULL;
- }
+ VECTOR_CLEAR(sd->script_queues);
if( sd->quest_log != NULL ) {
aFree(sd->quest_log);
sd->quest_log = NULL;