summaryrefslogtreecommitdiff
path: root/src/map/script.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.h')
-rw-r--r--src/map/script.h55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/map/script.h b/src/map/script.h
index ff660dec8..b153cf81a 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,27 @@ 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
+ VECTOR_DECL(int) entries; ///< Items in the queue.
+ bool valid; ///< Whether the queue is valid.
+ /// 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 {
+ VECTOR_DECL(int) entries; ///< Entries in the queue (iterator's cached copy)
+ bool valid; ///< Whether the queue is valid (initialized - not necessarily having entries available)
+ int pos; ///< Iterator's cursor
};
struct script_state {
@@ -515,9 +521,8 @@ struct script_interface {
struct eri *st_ers;
struct eri *stack_ers;
/* */
- struct hQueue *hq;
- struct hQueueIterator *hqi;
- int hqs, hqis;
+ VECTOR_DECL(struct script_queue) hq;
+ VECTOR_DECL(struct script_queue_iterator) hqi;
/* */
char **buildin;
unsigned int buildin_count;
@@ -667,12 +672,12 @@ 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);
int (*queue_create) (void);
- void (*queue_clear) (int idx);
+ bool (*queue_clear) (int idx);
/* */
const char * (*parse_curly_close) (const char *p);
const char * (*parse_syntax_close) (const char *p);