summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 4ceb32991..5cc48c7ce 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -17051,8 +17051,14 @@ BUILDIN(queuesize) {
if( idx < 0 || idx >= script->hqs || script->hq[idx].items == -1 ) {
ShowWarning("buildin_queuesize: unknown queue id %d\n",idx);
script_pushint(st, 0);
- } else
- script_pushint(st, script->hq[ idx ].items );
+ } else {
+ /* value of script->hq[].items isn't to be trusted for we dont reduce the size when members are removed to save on memory allocation */
+ int i, count = 0;
+ for( i = 0; i < script->hq[ idx ].items; i++ )
+ if( script->hq[ idx ].item[i] != -1 )
+ count++;
+ script_pushint(st, count);
+ }
return true;
}
@@ -17119,13 +17125,13 @@ bool script_hqueue_remove(int idx, int var) {
for(i = 0; i < script->hq[idx].items; i++) {
if( script->hq[idx].item[i] == var ) {
- return true;
+ break;
}
}
if( i != script->hq[idx].items ) {
struct map_session_data *sd;
- script->hq[idx].item[i] = 0;
+ script->hq[idx].item[i] = -1;
if( var >= START_ACCOUNT_NUM && (sd = iMap->id2sd(var)) ) {
for(i = 0; i < sd->queues_count; i++) {
@@ -17240,7 +17246,7 @@ BUILDIN(queueiterator) {
int idx = script->hqis;
int i;
- if( qid < 0 || qid >= script->hqs || script->hq[idx].items == -1 || !(queue = script->queue(qid)) ) {
+ if( qid < 0 || qid >= script->hqs || script->hq[qid].items == -1 || !(queue = script->queue(qid)) ) {
ShowWarning("queueiterator: invalid queue id %d\n",qid);
return true;
}
@@ -17258,8 +17264,8 @@ BUILDIN(queueiterator) {
idx = i;
RECREATE(script->hqi[ idx ].item, int, queue->items);
-
- memcpy(&script->hqi[idx].item, &queue->item, sizeof(int)*queue->items);
+
+ memcpy(script->hqi[idx].item, queue->item, sizeof(int)*queue->items);
script->hqi[ idx ].items = queue->items;
script->hqi[ idx ].pos = 0;