Register FAQ Search Today's Posts Mark Forums Read
Go Back   JazzJackrabbit Community Forums » Maintenance & Feedback » JJ2+ Issue Tracker

Bug Report jjSendPacket not sending packets

Zah dud4h

JCF Member

Joined: Dec 2014

Posts: 26

Zah dud4h is doing well so far

Feb 11, 2021, 03:58 PM
Zah dud4h is offline
jjSendPacket not sending packets

Well, there's something weird going on with the jjSendPacket function, apparently.

As a server, if you put a negative number in its second parameter (e.g. `jjSendPacket(packet, -clientID)`), it will do something different than what it should do according to the documentation.

Once you put the negative value of a clientID, the server decides not to send the packet back to players that are not using the clientIDs 1, 3 or 7 (probably also 15 and 31, since there seems to be a pattern here).

Judging by the pattern of the numbers, i suspect there is something in the code that tries to do a bitwise "AND" operation (&) instead of using the "AND" logic comparator (&&), or perhaps some other bitwise operator mistake.

I've sent an attachment with the mutator code I used to test this behavior with multiple clients. It should send packets to the server by just pressing the left mouse button.

Note that when I used this mutator, there was no level script running alongside it in the background, nor any other mutator.

I suggest that people should avoid using this until it gets fixed and that they rather should send packets to the players excluding the clientID they want manually. Here's a possible workaround:

Code:
array<bool> clientExists(32,false);
for (int i = 1;i < 32;i++) {
  jjPLAYER@ play = jjPlayers[i];
  if (play.isActive) clientExists[play.clientID] = true;
}
for (int i = 1;i < 32;i++) {
  if (i == clientID) continue;
  if (clientExists[i]) {  
    jjSendPacket(replyPacket, i);
  }
}
Attached Files
File Type: txt teststream3b.txt (1.0 KB, 0 views)
__________________
.

Last edited by Zah dud4h; Feb 12, 2021 at 02:51 AM.
Seren Seren's Avatar

JCF Member

Joined: Feb 2010

Posts: 850

Seren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to all

Feb 12, 2021, 09:21 AM
Seren is offline
Quote:
Originally Posted by Zah dud4h View Post
Once you put the negative value of a clientID, the server decides not to send the packet back to players that are not using the clientIDs 1, 3 or 7 (probably also 15 and 31, since there seems to be a pattern here).

Judging by the pattern of the numbers, i suspect there is something in the code that tries to do a bitwise "AND" operation (&) instead of using the "AND" logic comparator (&&), or perhaps some other bitwise operator mistake.
No, and this behavior description is not entirely accurate, but thanks for the report, there is indeed a problem with negative arguments to the function!
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,822

Violet CLM has disabled reputation

Feb 12, 2021, 09:27 AM
Violet CLM is offline
Thanks for the report! This bug is news to me but I think I've gotten it fixed locally... I just want to be sure I'm understanding the report right. This sentence I'm having a little trouble parsing:
Quote:
Once you put the negative value of a clientID, the server decides not to send the packet back to players that are not using the clientIDs 1, 3 or 7
Because jjSendPacket actually has a bool return value, I was able to see that in my testing, it returns true or false depending on the exact (negative) toClientID argument. When it returns false, packets are not sent to any clients. Does that match what you're seeing, or are we somehow experiencing different (yet related) issues?
__________________
Zah dud4h

JCF Member

Joined: Dec 2014

Posts: 26

Zah dud4h is doing well so far

Feb 12, 2021, 03:49 PM
Zah dud4h is offline
Quote:
Originally Posted by Violet CLM View Post
Thanks for the report! This bug is news to me but I think I've gotten it fixed locally... I just want to be sure I'm understanding the report right. This sentence I'm having a little trouble parsing:

Because jjSendPacket actually has a bool return value, I was able to see that in my testing, it returns true or false depending on the exact (negative) toClientID argument. When it returns false, packets are not sent to any clients. Does that match what you're seeing, or are we somehow experiencing different (yet related) issues?
So i've tested this again by changing the jjSendPacket line with this bit of code.

Code:
for (int i = 1;i < 32;i++) {
	jjDebug(i + ": did it send? " + jjSendPacket(packet,-i));
}
Apparently the results were:

Quote:
1: did it send? true
2: did it send? false
3: did it send? true
4: did it send? false
5: did it send? false
6: did it send? false
7: did it send? true
8: did it send? true
9: did it send? true
10: did it send? true
11: did it send? true
12: did it send? true
13: did it send? true
14: did it send? true
15: did it send? false
16: did it send? false
17: did it send? false
18: did it send? true
19: did it send? false
20: did it send? false
21: did it send? true
22: did it send? true
23: did it send? true
24: did it send? true
25: did it send? true
26: did it send? true
27: did it send? true
28: did it send? true
29: did it send? true
30: did it send? true
31: did it send? true
The function works as intended when you insert the negative numbers from above that resulted as "true" in the return,aswell as skipping sending packets to the clientID matching it.

However once you insert those who resulted as "false" in the return,it wouldn't send to anybody.

I stand corrected when i claimed it has something to do with a bitwise operator,as this seems to be a different unrelated pattern.
(2, 4, 5, 6, 15, 16, 17, 19, 20)
__________________
.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,822

Violet CLM has disabled reputation

Feb 12, 2021, 05:11 PM
Violet CLM is offline
Okay, great, that matches what I'm seeing. It's not a "pattern" so much as the game is trying to read unrelated memory by mistake. We should be able to get it fixed no problem now that we know about it though, and thanks for including that workaround script in the first post.
__________________
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,822

Violet CLM has disabled reputation

Mar 21, 2021, 05:24 PM
Violet CLM is offline
Fix will be available in 5.8.
__________________
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 06:35 AM.