I'm still struggling with changing zone and losing perceptions on client. First thing I noticed is a possible bug on RPWorld on the requestSync method it checks for the client id parameter but then goes ahead and tries to retrieve the PlayerEntry comparing the object instead of using the id.
This only return non-null if the object is exactly the one in the entry so I'm replacing that line with:
PlayerEntry entry = playerContainer.get(object.getInt("#clientid"));
But that brings me to the second issue, after I change zone and the sync is requested, it keeps being sent to the original zone (extracted from the entry). I haven't been able to find a place the entry's object is updated so the changces this zone is accurate are next to none so basically after I change zones my client keeps getting empty perceptions (confirmed it happens after the sync perception) and I suspect it's just being sent to the wrong zone
The engine thinks the object is in a zone, but is not on the objects of the zone so the event are lost when getting the caster of an action it retrieves the object from the PlayerEntry.
Anonymous
Forgot to login prior to adding the issue. Not sure if the owner can be updated.
I think the root of the problem is, that you ended up with two distinct objects representing the player. The "object" in your example code should be the exact same object that is in PlayerContainer.
The original concept of #clientid has a number of issues such as security, so nowadays the network connection information is used to associate clients with objects. #clientid is deprecated, but unfortuneteally was not cleaned up completely.
(To prevent the security issue, there are checks to ensure that #clientid and the network connection identify the same object before actions are executed.)
Please ensure, that you use the object in PlayerEntry to communicate with the client. Not a different object which has the same #clientid.
I think, however, that the object in PlayerEntry can be replaced with a different object, if need arises.
There is RPWorld.changeZone() to transfer an object to another zone. It works both for players as well as any other object.
I do use the RPWorld.changeZone() currently, that's where the issue arose.
Then I guess my question is, what is the proper way to add events on the server to be communicated to the client?
As you add event, change zones, etc. the object changes. And again, I see no updates on the PlayerEntry anywhere to keep this up to date.
I'll rework the code to keep the player entry updated all the time then and see how it goes. Thanks!
Right now I use the objects on the zones to add events to them as needed then call RPWorld.modify on them. You saying that is not the way?
There are a lot of patches to the issue I'm facing on Stendahl.
https://sourceforge.net/p/arianne/stendhal/ci/master/tree/src/games/stendhal/server/entity/Entity.java#l497
based on the comments is exactly the issue I'm seeing.