Playing with packets and phx...

This is not a Support area! Discuss about the Server here. Non-Server related discussion goes in Off-Topic Discussion.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
Pere
Posts: 400
Joined: Sat Jan 05, 2008 11:09 am
Location: Catalunya, Berguedà

Playing with packets and phx...

Post by Pere »

I have added this line to ExBrExtraUserInfo:
writeS(getClient().getActiveChar().getName());

What do you think that this should send to my client? Of course, my character name!
But no, sometimes (only sometimes) it sends me the name of the character that sent me his charinfo!!!

How the hell can I receive a packet whose getClient() is not my client??

It is very strange, no need to know but I'm very curious :S
Bones tardes amics meus tots!
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

Re: Playing with packets and phx...

Post by janiii »

because the packet is broadcasted also to other players around you? you broadcast the packet, so the players will get the packet with your info.
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
User avatar
Pere
Posts: 400
Joined: Sat Jan 05, 2008 11:09 am
Location: Catalunya, Berguedà

Re: Playing with packets and phx...

Post by Pere »

In the packet's class, if you do getClient() (the same than this.getClient(), so packet.getClient()) you are getting the client which will receive the packet.. as far as I know -_-

I want this to get if the packet receiver is GM, to send him different title colors depending on character's things like being clan leader or not.. but sometimes the GM receives the info like he was a player. And then, "debugging" with the method that I told in the post above, I've got that.
Bones tardes amics meus tots!
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

Re: Playing with packets and phx...

Post by janiii »

ExBrExtraUserInfo is a server packet. you give the packet parameter with a l2pcinstance, but you broadcast it to other players too.
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Playing with packets and phx...

Post by JIV »

it dont work that way :) i dont recommend you using getClient() for SendablePacket if its sended to multiple users. Simple workaround - send to each player new packet.
User avatar
Pere
Posts: 400
Joined: Sat Jan 05, 2008 11:09 am
Location: Catalunya, Berguedà

Re: Playing with packets and phx...

Post by Pere »

uh lol true!
thank you for opening my eyes ^^
Bones tardes amics meus tots!
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Playing with packets and phx...

Post by JIV »

checked again and it looks like mmocore implementation mistake..
try: http://pastebin.com/sn2JPTg8 should fix issue.
User avatar
Pere
Posts: 400
Joined: Sat Jan 05, 2008 11:09 am
Location: Catalunya, Berguedà

Re: Playing with packets and phx...

Post by Pere »

I'm wondering why is this commented... maybe too risky to uncomment xD
Bones tardes amics meus tots!
User avatar
Pere
Posts: 400
Joined: Sat Jan 05, 2008 11:09 am
Location: Catalunya, Berguedà

Re: Playing with packets and phx...

Post by Pere »

Forget about my last comment, thank you so much ;D
Bones tardes amics meus tots!
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Playing with packets and phx...

Post by JIV »

its working now?
User avatar
Pere
Posts: 400
Joined: Sat Jan 05, 2008 11:09 am
Location: Catalunya, Berguedà

Re: Playing with packets and phx...

Post by Pere »

could not test yet, I must restart more than 1 server to change a lib u.U
Bones tardes amics meus tots!
User avatar
Pere
Posts: 400
Joined: Sat Jan 05, 2008 11:09 am
Location: Catalunya, Berguedà

Re: Playing with packets and phx...

Post by Pere »

Tested, and was a total mess to comment the first setclient! It caused too many nullpointers in the packet handlers, like creaturesay or enterworld.
I've uncommented this and now everything seems to work perfectly, even with broadcasted packets! ^^
I'd suggest a commit for the SelectorThread part.
Bones tardes amics meus tots!
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Playing with packets and phx...

Post by JIV »

its not safe either :) patch is wrong, cause getClient is used promary for runImpl() and when you change it during write it can fail there. maybe create new getWriteClient(), active client during white.
User avatar
Pere
Posts: 400
Joined: Sat Jan 05, 2008 11:09 am
Location: Catalunya, Berguedà

Re: Playing with packets and phx...

Post by Pere »

And what about only setting it to the current write client and then not setting to null?
..well, indeed this is really dirty, we/I should create another variable better to get the client in write processes.

EDIT: here the patch if anyone is interested or you want to commit

Code: Select all

Index: src/org/mmocore/network/AbstractPacket.java===================================================================--- src/org/mmocore/network/AbstractPacket.java	(revision 4322)+++ src/org/mmocore/network/AbstractPacket.java	(working copy)@@ -28,9 +28,15 @@     protected ByteBuffer _buf;      T _client;+    T _writeClient;      public final T getClient()     {         return _client;     }++    public final T getWriteClient()+    {+        return _writeClient;+    } }Index: src/org/mmocore/network/SelectorThread.java===================================================================--- src/org/mmocore/network/SelectorThread.java	(revision 4322)+++ src/org/mmocore/network/SelectorThread.java	(working copy)@@ -565,12 +565,16 @@         final int dataPos = headerPos + HEADER_SIZE;         WRITE_BUFFER.position(dataPos); +        // set client+        sp._writeClient = client;         // set the write buffer         sp._buf = WRITE_BUFFER;         // write content to buffer         sp.write();         // delete the write buffer         sp._buf = null;+        // release client+        sp._writeClient = null;          // size (inclusive header)         int dataSize = WRITE_BUFFER.position() - dataPos; 
Bones tardes amics meus tots!
Post Reply