From 883fd21cfd6fd307fead556ddee9b172457ea31d Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 2 Dec 2019 19:43:11 -0500 Subject: [PATCH] object indicators: fix unmarking objects matched by name --- .../ObjectIndicatorsPlugin.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java index dad5bd5c52..012c404b47 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java @@ -309,7 +309,7 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener return; } - markObject(name, object); + markObject(objectDefinition, name, object); } private void checkObjectPoints(TileObject object) @@ -406,13 +406,14 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener return false; } - private void markObject(String name, final TileObject object) + /** mark or unmark an object + * + * @param objectComposition transformed composition of object based on vars + * @param name name of objectComposition + * @param object tile object, for multilocs object.getId() is the base id + */ + private void markObject(ObjectComposition objectComposition, String name, final TileObject object) { - if (object == null) - { - return; - } - final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, object.getLocalLocation()); final int regionId = worldPoint.getRegionID(); final ObjectPoint point = new ObjectPoint( @@ -427,9 +428,11 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener if (objects.remove(object)) { - // Use object id instead of name to match the object point with this object due to the object name being - // able to change because of multilocs. - if (!objectPoints.removeIf(op -> (op.getId() == -1 || op.getId() == object.getId()) + // Find the object point that caused this object to be marked, there are two cases: + // 1) object is a multiloc, the name may have changed since marking - match from base id + // 2) not a multiloc, but an object has spawned with an identical name and a different + // id as what was originally marked + if (!objectPoints.removeIf(op -> ((op.getId() == -1 || op.getId() == object.getId()) || op.getName().equals(objectComposition.getName())) && op.getRegionX() == worldPoint.getRegionX() && op.getRegionY() == worldPoint.getRegionY() && op.getZ() == worldPoint.getPlane()))