viewing paste all 4 queue bugs | Diff

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
 src/map/pc.c     |  2 +-
 src/map/script.c | 15 ++++++++++-----
 src/map/script.h |  2 +-
 3 files changed, 12 insertions(+), 7 deletions(-)
 
diff --git a/src/map/pc.c b/src/map/pc.c
index 4d4f415..8750568 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -5452,7 +5452,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short map_index, int x, int
        for( i = 0; i < sd->queues_count; i++ ) {
            struct hQueue *queue;
            if( (queue = script->queue(sd->queues[i])) && queue->onMapChange[0] != '\0' ) {
-               pc->setregstr(sd, script->add_str("QMapChangeTo"), map->list[m].name);
+               pc->setregstr(sd, script->add_str("@QMapChangeTo$"), map->list[m].name);
                npc->event(sd, queue->onMapChange, 0);
            }
        }
diff --git a/src/map/script.c b/src/map/script.c
index 54d8d33..b913702 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -18923,6 +18923,9 @@ bool script_hqueue_remove(int idx, int var) {
            }
 
        }
+       else
+           return true;
+
    }
    return false;
 }
@@ -18959,7 +18962,7 @@ BUILDIN(queueopt) {
                else
                    script->hq[idx].onDeath[0] = '\0';
                break;
-           case HQO_onLogOut:
+           case HQO_OnLogOut:
                if( script_hasdata(st, 4) )
                    safestrncpy(script->hq[idx].onLogOut, script_getstr(st, 4), EVENT_NAME_LENGTH);
                else
@@ -18992,7 +18995,7 @@ bool script_hqueue_del(int idx)
            if (script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = map->id2sd(script->hq[idx].item[i])) != NULL) {
                int j;
                for(j = 0; j < sd->queues_count; j++) {
-                   if( sd->queues[j] == script->hq[idx].item[i] ) {
+                   if (sd->queues[j] == idx) {
                        break;
                    }
                }
@@ -19051,7 +19054,7 @@ BUILDIN(queueiterator) {
    int qid = script_getnum(st, 2);
    struct hQueue *queue = NULL;
    int idx = script->hqis;
-   int i;
+   int i, count = 0;
 
    if( qid < 0 || qid >= script->hqs || script->hq[qid].size == -1 || !(queue = script->queue(qid)) ) {
        ShowWarning("queueiterator: invalid queue id %d\n",qid);
@@ -19078,9 +19081,11 @@ BUILDIN(queueiterator) {
 
    RECREATE(script->hqi[ idx ].item, int, queue->size);
 
-   memcpy(script->hqi[idx].item, queue->item, sizeof(int)*queue->size);
+   for (i = 0; i < queue->size; i++)
+       if (queue->item[i] != -1)
+           script->hqi[idx].item[count++] = queue->item[i];
 
-   script->hqi[ idx ].items = queue->size;
+   script->hqi[ idx ].items = count;
    script->hqi[ idx ].pos = 0;
 
    script_pushint(st,idx);
diff --git a/src/map/script.h b/src/map/script.h
index ff660de..cd02f72 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -225,7 +225,7 @@ typedef enum c_op {
 
 enum hQueueOpt {
    HQO_NONE,
-   HQO_onLogOut,
+   HQO_OnLogOut,
    HQO_OnDeath,
    HQO_OnMapChange,
    HQO_MAX,
 
Viewed 1223 times, submitted by AnnieRuru.