From 48b6dc7122b45d50af2e99ed55488d4fc584ea99 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 10 Apr 2015 08:01:08 -0400 Subject: [PATCH] Changed 'region snapshots' from a list to a map, allowing for the removal of previous update operations. (They were stacking before this commit, leading to problems for players just entering the region) It appears that object updating is now functional. :) --- src/org/apollo/game/model/area/Region.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/org/apollo/game/model/area/Region.java b/src/org/apollo/game/model/area/Region.java index 838e560e..6912778a 100644 --- a/src/org/apollo/game/model/area/Region.java +++ b/src/org/apollo/game/model/area/Region.java @@ -75,7 +75,7 @@ public final class Region { /** * The Set containing RegionUpdateMessages which can be sent to add every non-Mob Entity in this Region. */ - private final List> snapshots = new ArrayList<>(Position.HEIGHT_LEVELS); + private final List> snapshots = new ArrayList<>(Position.HEIGHT_LEVELS); /** * The Set containing UpdateOperations. @@ -102,7 +102,7 @@ public final class Region { listeners.add(new UpdateRegionListener()); for (int height = 0; height < Position.HEIGHT_LEVELS; height++) { - snapshots.add(new ArrayList<>()); + snapshots.add(new HashMap<>()); updates.add(new ArrayList<>(DEFAULT_SET_SIZE)); } } @@ -220,7 +220,7 @@ public final class Region { * @return The Set of RegionUpdateMessages. */ public List getSnapshot(int height) { - List copy = new ArrayList<>(snapshots.get(height)); + List copy = new ArrayList<>(snapshots.get(height).values()); Collections.sort(copy); return ImmutableList.copyOf(copy); } @@ -313,9 +313,10 @@ public final class Region { int height = entity.getPosition().getHeight(); updates.get(height).add(message); + snapshots.get(height).remove(entity); if (entity.getEntityType() != EntityType.STATIC_OBJECT || type == EntityUpdateType.REMOVE) { - snapshots.get(height).add(message); + snapshots.get(height).put(entity, message); } }