Jump to content
PcPocket

[Queue] 2 new commands

Recommended Posts

A very simple command for the queue system, very easy to do, but it isn't available  :huh:

 

queuecheck( queue_id, value );

return 1 if the value is found in the queue, 0 if not.

queueremove and queueadd does this checks, but you don't have the option to do the check without actually add / remove the value from the queue.

Other thing that would be very usefull.

 

queuevalues( queue_id );

returns all the values from the queue as an array. I haven't tested queue iterator yet so I don't know it's behavior, but from what I read I read from the docs, I can't do something like 'setarray .@list,queueiterator(queue_id);', if I can, than do not consider this suggestion, just the above one.

Share this post


Link to post
Share on other sites

A very simple command for the queue system, very easy to do, but it isn't available  :huh:

 

queuecheck( queue_id, value );

return 1 if the value is found in the queue, 0 if not.

queueremove and queueadd does this checks, but you don't have the option to do the check without actually add / remove the value from the queue.

Other thing that would be very usefull.

 

queuevalues( queue_id );

returns all the values from the queue as an array. I haven't tested queue iterator yet so I don't know it's behavior, but from what I read I read from the docs, I can't do something like 'setarray .@list,queueiterator(queue_id);', if I can, than do not consider this suggestion, just the above one.

1) there's command called qicheck.

2) there's queueiterator, which I think does the work, for what you would need array(maybe for looping and checking), that's what iterator do(loop through each value)

 

Hope I didn't misunderstood your questions.

Share this post


Link to post
Share on other sites

1) 
 
*qicheck(<queue_iterator_id>);
checks whether there is a next member in the iterator's queue, 1 when
it does, 0 otherwise.

It's a command for the iterator, not to check if a value is in the queue.
 
2) Yeah, I tested it now. There is no need for "queuevalues", I mean.. it would be nice, but you can do it with queueiterator.
I remain with my main suggestion :D

Share this post


Link to post
Share on other sites

Moving to suggestions forum..

 

Edit: I would like to suggest 3rd thing in this case :P

Move queue system to different interface rather than in script-> pointer...

Share this post


Link to post
Share on other sites

Sorry for the wrong area haha anyway, how does this work? Somebody from developer team visit this area?

Well, another thing..
I just finished my system, and I noticed that my queuesize is return -1 after some actions. I use queueremove when player die/change map/logout, maybe this is causing the queue counting to be reduced twice.

I don't know, I just know that a queue can't ever have a size smaller than 0.

Share this post


Link to post
Share on other sites

Sorry for the wrong area haha anyway, how does this work? Somebody from developer team visit this area?

Well, another thing..

I just finished my system, and I noticed that my queuesize is return -1 after some actions. I use queueremove when player die/change map/logout, maybe this is causing the queue counting to be reduced twice.

I don't know, I just know that a queue can't ever have a size smaller than 0.

Hmmm.. Strange. I have whole BG system using queue, it never got below 0

Share this post


Link to post
Share on other sites

Yeah.. the system I'm working is a BG system too.

I use queueremove on everybody on the queue when it is full enough to start the match.
And queueopt to call a function that will remove the player from the queue ( on the 3 options, move from map, die or logout ).

After I player 2 modules, the queue gets to -1. I will do some tests to figure out whats the reason. If I don't find out, I will patch in the source to never get it below 0 haha.

 

By the way, queue check command:

 

bool script_hqueue_check(int idx, int var) {	if( idx < 0 || idx >= script->hqs || script->hq[idx].size == -1 ) {		ShowWarning("script_hqueue_add: unknown queue id %dn",idx);		return false;	} else {		int i;		for (i = 0; i < script->hq[idx].size; i++) {			if (script->hq[idx].item[i] == var) {				return true;			}		}		return false;	}}BUILDIN(queuecheck) {		int idx = script_getnum(st, 2);	int var = script_getnum(st, 3);	script_pushint(st,script->queue_check(idx,var)?1:0);		return true;}

They may want to invert the 'true' and 'false' returns, as all queue commands return 0 upon success ( why? I don't know )
And of course, the rest.
 

		BUILDIN_DEF(queuecheck,"ii"),
	script->queue_check = script_hqueue_check;

script.h
 

	bool (*queue_check) (int idx, int var);

@Edit

I found out the piece of code causing it.

function	Players2BG	{	.@queue01 = queueiterator(getarg(0));	for (.@elem = qiget(.@queue01); qicheck(.@queue01); .@elem = qiget(.@queue01)) {		announce "Adding player"+.@elem+" from queue"+getarg(0)+" to BG Team "+getarg(1),8;		player2bg(getarg(1),.@elem,$@BG_Status);		queueremove(getarg(0),.@elem); // Removes from the queue	}	return;} 

Then, the second time I go to the battleground ( the first one works fine ):
0380336757.jpg(
( the announce is in portuguese in the picture )
getarg(0) = Queue ID
getarg(1) = BG Team ID

I'm almost sure that I'm missing a qiclear in the end of the function, will test it now, must solve it.
But.. I still think that the number of elements in the queue shouldn't be able to be lower than 0.


@edit2
Yeah.. qiclear didn't solve the problem.
I tested something new, I put 'queueremove($bgTeamQueue01,-1);' in the top of npc script, so everytime I click on it, it attempts to remove a non-existant value from the queue.

Result: After I played one match, every queueremove, lowered the queuecount by 1. So if I click 10 times, npc show that queue has -10 members..
This just works after I play once ( so Players2BG gets called ).

Trying to figure out why.

@edit3
Yeah, there is a bug in queueremove command, trying to fix, post here soon.

@edit4
Aparently, queueremove isn't actually removing a value from the queue, but changing it value to -1?

Edited by PcPocket

Share this post


Link to post
Share on other sites

confirming this bug

http://upaste.me/adea21853ecefe7a9

 

when player A joins, queue list as

1. 2000000
when player B joins, queue list as
1. 20000002. 2000001
and now remove player A, queue list as
1. -12. 2000001
this is definitely not right

the queuesize is display correctly as only 1 person, but the queueiterator still having 2 entry

 

ima thinking of know how to fix this bug

 

EDIT:

found 4 bugs in the process XD

Fix *queueremove should return true if player is not in the queue

Fix *queueiterator return same amount of *queuesize upon *queueremove

Fix *queuedel doesn't remove player's side queue

Fix @QMapChangeTo$ not usable when HQO_OnMapChange triggered

Edited by AnnieRuru

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.