Menu

#214 [Stendhal] Notification of intra-zone position change

open
nobody
None
5
2011-03-28
2011-03-28
No

Notification of intra-zone position change is firing ( calling getZone().notifyMovement() ) when entity is changing zones, even it should not to.

For example. Let say we have two zones and notification area (which implements MovementListener) in each of them, and two portals which connects that two zones are inside these areas. Then when player is changing zones, 'exit event' of area in origin zone should fire and then 'enter event' of area in destination zone should fire.

This works very well with onAdded and onRemoved methods of ActiveEntity.

But onMoved is firing with bad event data. It will fire additional enter and exit event which should not happen. Enter event will fire on departure zone with coordinates from new area in destination zone. That happens because getZone() is returning last area when actual zone is null.

So to asure that this event does not fire on zone change I changed 'getZone()' to 'zone' at IF condition in Entity class at two places:

[code]
if (moved && (zone != null)) {

onMoved(oldX, oldY, x, y);

}

[/code]

So onAdded and onRemoved are called when entity is changing zones and onMoved is only called when moving inside the zone.
If you think this is ok, I could submit a patch, although its just two little changes. :)

Discussion

Anonymous
Anonymous

Add attachments
Cancel