Playing with packets and phx...
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
- Pere
- Posts: 400
- Joined: Sat Jan 05, 2008 11:09 am
- Location: Catalunya, Berguedà
Playing with packets and phx...
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
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!
- janiii
- L2j Veteran
- Posts: 4269
- Joined: Wed May 28, 2008 3:15 pm
- Location: Slovakia
Re: Playing with packets and phx...
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!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
- Pere
- Posts: 400
- Joined: Sat Jan 05, 2008 11:09 am
- Location: Catalunya, Berguedà
Re: Playing with packets and phx...
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.
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!
- janiii
- L2j Veteran
- Posts: 4269
- Joined: Wed May 28, 2008 3:15 pm
- Location: Slovakia
Re: Playing with packets and phx...
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!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
- JIV
- L2j Veteran
- Posts: 1882
- Joined: Sun Jan 06, 2008 8:17 pm
- Location: Slovakia
- Contact:
Re: Playing with packets and phx...
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.

- Pere
- Posts: 400
- Joined: Sat Jan 05, 2008 11:09 am
- Location: Catalunya, Berguedà
Re: Playing with packets and phx...
uh lol true!
thank you for opening my eyes ^^
thank you for opening my eyes ^^
Bones tardes amics meus tots!
- JIV
- L2j Veteran
- Posts: 1882
- Joined: Sun Jan 06, 2008 8:17 pm
- Location: Slovakia
- Contact:
Re: Playing with packets and phx...
checked again and it looks like mmocore implementation mistake..
try: http://pastebin.com/sn2JPTg8 should fix issue.
try: http://pastebin.com/sn2JPTg8 should fix issue.
- Pere
- Posts: 400
- Joined: Sat Jan 05, 2008 11:09 am
- Location: Catalunya, Berguedà
Re: Playing with packets and phx...
I'm wondering why is this commented... maybe too risky to uncomment xD
Bones tardes amics meus tots!
- Pere
- Posts: 400
- Joined: Sat Jan 05, 2008 11:09 am
- Location: Catalunya, Berguedà
Re: Playing with packets and phx...
Forget about my last comment, thank you so much ;D
Bones tardes amics meus tots!
- JIV
- L2j Veteran
- Posts: 1882
- Joined: Sun Jan 06, 2008 8:17 pm
- Location: Slovakia
- Contact:
Re: Playing with packets and phx...
its working now?
- Pere
- Posts: 400
- Joined: Sat Jan 05, 2008 11:09 am
- Location: Catalunya, Berguedà
Re: Playing with packets and phx...
could not test yet, I must restart more than 1 server to change a lib u.U
Bones tardes amics meus tots!
- Pere
- Posts: 400
- Joined: Sat Jan 05, 2008 11:09 am
- Location: Catalunya, Berguedà
Re: Playing with packets and phx...
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.
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!
- JIV
- L2j Veteran
- Posts: 1882
- Joined: Sun Jan 06, 2008 8:17 pm
- Location: Slovakia
- Contact:
Re: Playing with packets and phx...
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.

- Pere
- Posts: 400
- Joined: Sat Jan 05, 2008 11:09 am
- Location: Catalunya, Berguedà
Re: Playing with packets and phx...
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
..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!