summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-09-14 15:00:02 +0200
committerHaru <haru@dotalux.com>2015-11-14 19:03:36 +0100
commit778db38c4a584cbc3a8a9e56fcef54447e9bee47 (patch)
tree7175b7b09bb4a6feddb879c2689fb4f18392b63b /src/map
parent1c9e25d58901e9c5bcea6bcbe885bd9c3eb5c72b (diff)
downloadhercules-778db38c4a584cbc3a8a9e56fcef54447e9bee47.tar.gz
hercules-778db38c4a584cbc3a8a9e56fcef54447e9bee47.tar.bz2
hercules-778db38c4a584cbc3a8a9e56fcef54447e9bee47.tar.xz
hercules-778db38c4a584cbc3a8a9e56fcef54447e9bee47.zip
Renamed hQueue/hQueueIterator/hQueueOpt to latest standards
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/battleground.c14
-rw-r--r--src/map/clif.c2
-rw-r--r--src/map/map.c6
-rw-r--r--src/map/pc.c12
-rw-r--r--src/map/script.c38
-rw-r--r--src/map/script.h53
6 files changed, 66 insertions, 59 deletions
diff --git a/src/map/battleground.c b/src/map/battleground.c
index cbf859b80..2b7614761 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -472,7 +472,7 @@ struct bg_arena *bg_name2arena (char *name) {
return NULL;
}
int bg_id2pos ( int queue_id, int account_id ) {
- struct hQueue *queue = script->queue(queue_id);
+ struct script_queue *queue = script->queue(queue_id);
if( queue ) {
int i, pos = 1;
for(i = 0; i < queue->size; i++ ) {
@@ -496,7 +496,7 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo
if( !response )
bg->queue_pc_cleanup(sd);
else {
- struct hQueue *queue = script->queue(arena->queue_id);
+ struct script_queue *queue = script->queue(arena->queue_id);
int i, count = 0;
sd->bg_queue.ready = 1;
@@ -531,7 +531,7 @@ void bg_queue_player_cleanup(struct map_session_data *sd) {
sd->bg_queue.type = 0;
}
void bg_match_over(struct bg_arena *arena, bool canceled) {
- struct hQueue *queue = script->queue(arena->queue_id);
+ struct script_queue *queue = script->queue(arena->queue_id);
int i;
nullpo_retv(arena);
@@ -560,7 +560,7 @@ void bg_match_over(struct bg_arena *arena, bool canceled) {
script->queue_clear(arena->queue_id);
}
void bg_begin(struct bg_arena *arena) {
- struct hQueue *queue = script->queue(arena->queue_id);
+ struct script_queue *queue = script->queue(arena->queue_id);
int i, count = 0;
nullpo_retv(arena);
@@ -645,7 +645,7 @@ int bg_afk_timer(int tid, int64 tick, int id, intptr_t data) {
}
void bg_queue_pregame(struct bg_arena *arena) {
- struct hQueue *queue;
+ struct script_queue *queue;
int i;
nullpo_retv(arena);
@@ -667,7 +667,7 @@ int bg_fillup_timer(int tid, int64 tick, int id, intptr_t data) {
void bg_queue_check(struct bg_arena *arena) {
int count;
- struct hQueue *queue;
+ struct script_queue *queue;
nullpo_retv(arena);
queue = script->queue(arena->queue_id);
@@ -684,7 +684,7 @@ void bg_queue_check(struct bg_arena *arena) {
}
void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type) {
enum BATTLEGROUNDS_QUEUE_ACK result = bg->can_queue(sd,arena,type);
- struct hQueue *queue;
+ struct script_queue *queue = NULL;
int i, count = 0;
nullpo_retv(sd);
diff --git a/src/map/clif.c b/src/map/clif.c
index bc4313f46..2b9ed43c6 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -610,7 +610,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target
case BG_QUEUE:
if( sd && sd->bg_queue.arena ) {
- struct hQueue *queue = script->queue(sd->bg_queue.arena->queue_id);
+ struct script_queue *queue = script->queue(sd->bg_queue.arena->queue_id);
for( i = 0; i < queue->size; i++ ) {
struct map_session_data *qsd = NULL;
diff --git a/src/map/map.c b/src/map/map.c
index cd2ba17c2..dd5baa626 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1803,9 +1803,9 @@ int map_quit(struct map_session_data *sd) {
pc->itemcd_do(sd,false);
for( i = 0; i < sd->queues_count; i++ ) {
- struct hQueue *queue;
- if( (queue = script->queue(sd->queues[i])) && queue->onLogOut[0] != '\0' ) {
- npc->event(sd, queue->onLogOut, 0);
+ struct script_queue *queue = script->queue(sd->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 */
diff --git a/src/map/pc.c b/src/map/pc.c
index 351d77b26..0671bfb5e 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -5527,10 +5527,10 @@ int pc_setpos(struct map_session_data* sd, unsigned short map_index, int x, int
sd->state.pmap = sd->bl.m;
for( i = 0; i < sd->queues_count; i++ ) {
- struct hQueue *queue;
- if( (queue = script->queue(sd->queues[i])) && queue->onMapChange[0] != '\0' ) {
+ struct script_queue *queue = script->queue(sd->queues[i]);
+ if (queue && queue->event_mapchange[0] != '\0') {
pc->setregstr(sd, script->add_str("QMapChangeTo"), map->list[m].name);
- npc->event(sd, queue->onMapChange, 0);
+ npc->event(sd, queue->event_mapchange, 0);
}
}
@@ -7635,9 +7635,9 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
}
for( i = 0; i < sd->queues_count; i++ ) {
- struct hQueue *queue;
- if( (queue = script->queue(sd->queues[i])) && queue->onDeath[0] != '\0' )
- npc->event(sd, queue->onDeath, 0);
+ struct script_queue *queue = script->queue(sd->queues[i]);
+ if (queue && queue->event_death[0] != '\0')
+ npc->event(sd, queue->event_death, 0);
}
npc->script_event(sd,NPCE_DIE);
diff --git a/src/map/script.c b/src/map/script.c
index de52dd9ea..45f84ec18 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -18790,7 +18790,7 @@ BUILDIN(montransform) {
return true;
}
-struct hQueue *script_hqueue_get(int idx)
+struct script_queue *script_hqueue_get(int idx)
{
if (idx < 0 || idx >= VECTOR_LENGTH(script->hq) || VECTOR_INDEX(script->hq, idx).size == -1)
return NULL;
@@ -18812,9 +18812,9 @@ int script_hqueue_create(void)
VECTOR_INDEX(script->hq, idx).id = i;
VECTOR_INDEX(script->hq, idx).size = 0;
VECTOR_INDEX(script->hq, idx).items = 0;
- VECTOR_INDEX(script->hq, idx).onDeath[0] = '\0';
- VECTOR_INDEX(script->hq, idx).onLogOut[0] = '\0';
- VECTOR_INDEX(script->hq, idx).onMapChange[0] = '\0';
+ VECTOR_INDEX(script->hq, idx).event_death[0] = '\0';
+ VECTOR_INDEX(script->hq, idx).event_logout[0] = '\0';
+ VECTOR_INDEX(script->hq, idx).event_mapchange[0] = '\0';
return idx;
}
/* set .@id,queue(); */
@@ -18947,28 +18947,28 @@ BUILDIN(queueopt) {
if (idx < 0 || idx >= VECTOR_LENGTH(script->hq) || VECTOR_INDEX(script->hq, idx).size == -1) {
ShowWarning("buildin_queueopt: unknown queue id %d\n",idx);
script_pushint(st, 1);
- } else if( var <= HQO_NONE || var >= HQO_MAX ) {
+ } else if( var <= SQO_NONE || var >= SQO_MAX ) {
ShowWarning("buildin_queueopt: unknown optionType %d\n",var);
script_pushint(st, 1);
} else {
- switch( (enum hQueueOpt)var ) {
- case HQO_OnDeath:
+ switch ((enum ScriptQueueOptions)var) {
+ case SQO_ONDEATH:
if( script_hasdata(st, 4) )
- safestrncpy(VECTOR_INDEX(script->hq, idx).onDeath, script_getstr(st, 4), EVENT_NAME_LENGTH);
+ safestrncpy(VECTOR_INDEX(script->hq, idx).event_death, script_getstr(st, 4), EVENT_NAME_LENGTH);
else
- VECTOR_INDEX(script->hq, idx).onDeath[0] = '\0';
+ VECTOR_INDEX(script->hq, idx).event_death[0] = '\0';
break;
- case HQO_onLogOut:
+ case SQO_ONLOGOUT:
if( script_hasdata(st, 4) )
- safestrncpy(VECTOR_INDEX(script->hq, idx).onLogOut, script_getstr(st, 4), EVENT_NAME_LENGTH);
+ safestrncpy(VECTOR_INDEX(script->hq, idx).event_logout, script_getstr(st, 4), EVENT_NAME_LENGTH);
else
- VECTOR_INDEX(script->hq, idx).onLogOut[0] = '\0';
+ VECTOR_INDEX(script->hq, idx).event_logout[0] = '\0';
break;
- case HQO_OnMapChange:
+ case SQO_ONMAPCHANGE:
if( script_hasdata(st, 4) )
- safestrncpy(VECTOR_INDEX(script->hq, idx).onMapChange, script_getstr(st, 4), EVENT_NAME_LENGTH);
+ safestrncpy(VECTOR_INDEX(script->hq, idx).event_mapchange, script_getstr(st, 4), EVENT_NAME_LENGTH);
else
- VECTOR_INDEX(script->hq, idx).onMapChange[0] = '\0';
+ VECTOR_INDEX(script->hq, idx).event_mapchange[0] = '\0';
break;
default:
ShowWarning("buildin_queueopt: unsupported optionType %d\n",var);
@@ -19047,7 +19047,7 @@ void script_hqueue_clear(int idx) {
/* creates a new queue iterator, returns its id */
BUILDIN(queueiterator) {
int qid = script_getnum(st, 2);
- struct hQueue *queue = NULL;
+ struct script_queue *queue = NULL;
int idx = VECTOR_LENGTH(script->hqi);
int i;
@@ -19088,7 +19088,7 @@ BUILDIN(queueiterator) {
/* returns next/first member in the iterator, 0 if none */
BUILDIN(qiget) {
int idx = script_getnum(st, 2);
- struct hQueueIterator *it = NULL;
+ struct script_queue_iterator *it = NULL;
if (idx < 0 || idx >= VECTOR_LENGTH(script->hqi)) {
ShowWarning("buildin_qiget: unknown queue iterator id %d\n",idx);
@@ -19111,7 +19111,7 @@ BUILDIN(qiget) {
/* returns 1:0 if there is the current member in the iterator exists */
BUILDIN(qicheck) {
int idx = script_getnum(st, 2);
- struct hQueueIterator *it = NULL;
+ struct script_queue_iterator *it = NULL;
if (idx < 0 || idx >= VECTOR_LENGTH(script->hqi)) {
ShowWarning("buildin_qicheck: unknown queue iterator id %d\n",idx);
@@ -20376,7 +20376,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(showevent, "i?"),
/**
- * hQueue [Ind/Hercules]
+ * script_queue [Ind/Hercules]
**/
BUILDIN_DEF(queue,""),
BUILDIN_DEF(queuesize,"i"),
diff --git a/src/map/script.h b/src/map/script.h
index d3c64f401..aa31389f6 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -223,12 +223,13 @@ typedef enum c_op {
#endif // PCRE_SUPPORT
} c_op;
-enum hQueueOpt {
- HQO_NONE,
- HQO_onLogOut,
- HQO_OnDeath,
- HQO_OnMapChange,
- HQO_MAX,
+/// Script queue options
+enum ScriptQueueOptions {
+ SQO_NONE, ///< No options set
+ SQO_ONLOGOUT, ///< Execute event on logout
+ SQO_ONDEATH, ///< Execute event on death
+ SQO_ONMAPCHANGE, ///< Execute event on map change
+ SQO_MAX,
};
enum e_script_state { RUN,STOP,END,RERUNLINE,GOTO,RETFUNC,CLOSE };
@@ -391,22 +392,28 @@ struct script_stack {
struct reg_db scope; ///< scope variables
};
-/* [Ind/Hercules] */
-struct hQueue {
- int id;
- int *item;
- int items;/* how many actual items are in the array */
- int size;/* size of the *item array, not the current amount of items in it since it can have empty slots */
- /* events */
- char onLogOut[EVENT_NAME_LENGTH];
- char onDeath[EVENT_NAME_LENGTH];
- char onMapChange[EVENT_NAME_LENGTH];
+/**
+ * Data structure to represent a script queue.
+ * @author Ind/Hercules
+ */
+struct script_queue {
+ int id; ///< Queue identifier
+ int *item; ///< Items in the queue (variable-size array)
+ int items; ///< Amount of elements in \c item
+ int size; ///< Capacity of the \c item array (not the current amount of items in it since it can have empty slots
+ /// Events
+ char event_logout[EVENT_NAME_LENGTH]; ///< Logout event
+ char event_death[EVENT_NAME_LENGTH]; ///< Death event
+ char event_mapchange[EVENT_NAME_LENGTH]; ///< Map change event
};
-struct hQueueIterator {
- int *item;
- int items;
- int pos;
+/**
+ * Iterator for a struct script_queue.
+ */
+struct script_queue_iterator {
+ int *item; ///< Items in the queue (iterator's cached copy)
+ int items; ///< Amount of elements in \c item
+ int pos; ///< Iterator's cursor
};
struct script_state {
@@ -515,8 +522,8 @@ struct script_interface {
struct eri *st_ers;
struct eri *stack_ers;
/* */
- VECTOR_DECL(struct hQueue) hq;
- VECTOR_DECL(struct hQueueIterator) hqi;
+ VECTOR_DECL(struct script_queue) hq;
+ VECTOR_DECL(struct script_queue_iterator) hqi;
/* */
char **buildin;
unsigned int buildin_count;
@@ -666,7 +673,7 @@ struct script_interface {
void (*setd_sub) (struct script_state *st, struct map_session_data *sd, const char *varname, int elem, void *value, struct reg_db *ref);
void (*attach_state) (struct script_state* st);
/* */
- struct hQueue *(*queue) (int idx);
+ struct script_queue *(*queue) (int idx);
bool (*queue_add) (int idx, int var);
bool (*queue_del) (int idx);
bool (*queue_remove) (int idx, int var);