Merge pull request #2714 from ThatGamerBlue/grounditems-316
grounditems: fix items not disappearing
This commit is contained in:
@@ -38,7 +38,6 @@ import net.runelite.api.coords.WorldPoint;
|
|||||||
import net.runelite.api.events.AnimationChanged;
|
import net.runelite.api.events.AnimationChanged;
|
||||||
import net.runelite.api.events.HitsplatApplied;
|
import net.runelite.api.events.HitsplatApplied;
|
||||||
import net.runelite.api.events.PlayerDeath;
|
import net.runelite.api.events.PlayerDeath;
|
||||||
import net.runelite.api.events.PlayerDeath;
|
|
||||||
import net.runelite.api.events.SpotAnimationChanged;
|
import net.runelite.api.events.SpotAnimationChanged;
|
||||||
import net.runelite.api.events.InteractingChanged;
|
import net.runelite.api.events.InteractingChanged;
|
||||||
import net.runelite.api.events.OverheadTextChanged;
|
import net.runelite.api.events.OverheadTextChanged;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||||
|
* Copyright (c) 2020, ThatGamerBlue <thatgamerblue@gmail.com>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -82,6 +83,7 @@ import net.runelite.api.events.FriendsChatChanged;
|
|||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.GrandExchangeOfferChanged;
|
import net.runelite.api.events.GrandExchangeOfferChanged;
|
||||||
import net.runelite.api.events.GrandExchangeSearched;
|
import net.runelite.api.events.GrandExchangeSearched;
|
||||||
|
import net.runelite.api.events.ItemSpawned;
|
||||||
import net.runelite.api.events.Menu;
|
import net.runelite.api.events.Menu;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
import net.runelite.api.events.MenuOpened;
|
import net.runelite.api.events.MenuOpened;
|
||||||
@@ -120,11 +122,14 @@ import net.runelite.rs.api.RSFriendSystem;
|
|||||||
import net.runelite.rs.api.RSIndexedSprite;
|
import net.runelite.rs.api.RSIndexedSprite;
|
||||||
import net.runelite.rs.api.RSItemContainer;
|
import net.runelite.rs.api.RSItemContainer;
|
||||||
import net.runelite.rs.api.RSNPC;
|
import net.runelite.rs.api.RSNPC;
|
||||||
|
import net.runelite.rs.api.RSNode;
|
||||||
import net.runelite.rs.api.RSNodeDeque;
|
import net.runelite.rs.api.RSNodeDeque;
|
||||||
import net.runelite.rs.api.RSNodeHashTable;
|
import net.runelite.rs.api.RSNodeHashTable;
|
||||||
import net.runelite.rs.api.RSPacketBuffer;
|
import net.runelite.rs.api.RSPacketBuffer;
|
||||||
import net.runelite.rs.api.RSPlayer;
|
import net.runelite.rs.api.RSPlayer;
|
||||||
|
import net.runelite.rs.api.RSScene;
|
||||||
import net.runelite.rs.api.RSSprite;
|
import net.runelite.rs.api.RSSprite;
|
||||||
|
import net.runelite.rs.api.RSTile;
|
||||||
import net.runelite.rs.api.RSTileItem;
|
import net.runelite.rs.api.RSTileItem;
|
||||||
import net.runelite.rs.api.RSUsername;
|
import net.runelite.rs.api.RSUsername;
|
||||||
import net.runelite.rs.api.RSWidget;
|
import net.runelite.rs.api.RSWidget;
|
||||||
@@ -826,7 +831,7 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
{
|
{
|
||||||
List<Projectile> projectiles = new ArrayList<Projectile>();
|
List<Projectile> projectiles = new ArrayList<Projectile>();
|
||||||
RSNodeDeque projectileDeque = this.getProjectilesDeque();
|
RSNodeDeque projectileDeque = this.getProjectilesDeque();
|
||||||
Node head = projectileDeque.getHead();
|
Node head = projectileDeque.getSentinel();
|
||||||
|
|
||||||
for (Node node = head.getNext(); node != head; node = node.getNext())
|
for (Node node = head.getNext(); node != head; node = node.getNext())
|
||||||
{
|
{
|
||||||
@@ -842,7 +847,7 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
{
|
{
|
||||||
List<GraphicsObject> graphicsObjects = new ArrayList<GraphicsObject>();
|
List<GraphicsObject> graphicsObjects = new ArrayList<GraphicsObject>();
|
||||||
RSNodeDeque graphicsObjectDeque = this.getGraphicsObjectDeque();
|
RSNodeDeque graphicsObjectDeque = this.getGraphicsObjectDeque();
|
||||||
Node head = graphicsObjectDeque.getHead();
|
Node head = graphicsObjectDeque.getSentinel();
|
||||||
|
|
||||||
for (Node node = head.getNext(); node != head; node = node.getNext())
|
for (Node node = head.getNext(); node != head; node = node.getNext())
|
||||||
{
|
{
|
||||||
@@ -1062,8 +1067,39 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
public static void gameStateChanged(int idx)
|
public static void gameStateChanged(int idx)
|
||||||
{
|
{
|
||||||
GameStateChanged gameStateChange = new GameStateChanged();
|
GameStateChanged gameStateChange = new GameStateChanged();
|
||||||
gameStateChange.setGameState(client.getGameState());
|
GameState gameState = client.getGameState();
|
||||||
|
gameStateChange.setGameState(gameState);
|
||||||
client.getCallbacks().post(GameStateChanged.class, gameStateChange);
|
client.getCallbacks().post(GameStateChanged.class, gameStateChange);
|
||||||
|
if (gameState == GameState.LOGGED_IN)
|
||||||
|
{
|
||||||
|
int plane = client.getPlane();
|
||||||
|
RSScene scene = client.getScene();
|
||||||
|
RSTile[][][] tiles = scene.getTiles();
|
||||||
|
RSNodeDeque[][][] allItemDeque = client.getGroundItemDeque();
|
||||||
|
RSNodeDeque[][] planeItems = allItemDeque[plane];
|
||||||
|
|
||||||
|
for (int x = 0; x < 104; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 104; y++)
|
||||||
|
{
|
||||||
|
RSNodeDeque itemDeque = planeItems[x][y];
|
||||||
|
if (itemDeque != null)
|
||||||
|
{
|
||||||
|
RSTile tile = tiles[plane][x][y];
|
||||||
|
RSNode head = itemDeque.getSentinel();
|
||||||
|
|
||||||
|
for (RSNode current = head.getNext(); current != head; current = current.getNext())
|
||||||
|
{
|
||||||
|
RSTileItem item = (RSTileItem) current;
|
||||||
|
item.setX(x);
|
||||||
|
item.setY(y);
|
||||||
|
ItemSpawned event = new ItemSpawned(tile, item);
|
||||||
|
client.getCallbacks().post(ItemSpawned.class, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||||
|
* Copyright (c) 2020, ThatGamerBlue <thatgamerblue@gmail.com>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -30,6 +31,7 @@ import net.runelite.api.CollisionData;
|
|||||||
import net.runelite.api.CollisionDataFlag;
|
import net.runelite.api.CollisionDataFlag;
|
||||||
import net.runelite.api.Constants;
|
import net.runelite.api.Constants;
|
||||||
import net.runelite.api.DecorativeObject;
|
import net.runelite.api.DecorativeObject;
|
||||||
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.GroundObject;
|
import net.runelite.api.GroundObject;
|
||||||
import net.runelite.api.TileItemPile;
|
import net.runelite.api.TileItemPile;
|
||||||
import net.runelite.api.Node;
|
import net.runelite.api.Node;
|
||||||
@@ -464,12 +466,19 @@ public abstract class RSTileMixin implements RSTile
|
|||||||
RSNodeDeque oldQueue = lastGroundItems[z][x][y];
|
RSNodeDeque oldQueue = lastGroundItems[z][x][y];
|
||||||
RSNodeDeque newQueue = groundItemDeque[z][x][y];
|
RSNodeDeque newQueue = groundItemDeque[z][x][y];
|
||||||
|
|
||||||
|
if (client.getGameState() != GameState.LOGGED_IN)
|
||||||
|
{
|
||||||
|
lastGroundItems[z][x][y] = newQueue;
|
||||||
|
client.setLastItemDespawn(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (oldQueue != newQueue)
|
if (oldQueue != newQueue)
|
||||||
{
|
{
|
||||||
if (oldQueue != null)
|
if (oldQueue != null)
|
||||||
{
|
{
|
||||||
// despawn everything in old ..
|
// despawn everything in old ..
|
||||||
RSNode head = oldQueue.getHead();
|
RSNode head = oldQueue.getSentinel();
|
||||||
for (RSNode cur = head.getNext(); cur != head; cur = cur.getNext())
|
for (RSNode cur = head.getNext(); cur != head; cur = cur.getNext())
|
||||||
{
|
{
|
||||||
RSTileItem item = (RSTileItem) cur;
|
RSTileItem item = (RSTileItem) cur;
|
||||||
@@ -510,54 +519,42 @@ public abstract class RSTileMixin implements RSTile
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The new item gets added to either the head, or the tail, depending on its price
|
// The new item gets added to either the head, or the tail, depending on its price
|
||||||
RSNode head = itemDeque.getHead();
|
RSNode head = itemDeque.getSentinel();
|
||||||
RSNode current = null;
|
RSTileItem current = null;
|
||||||
RSNode previous = head.getPrevious();
|
RSNode next = head.getPrevious();
|
||||||
boolean forward = false;
|
//boolean forward = false;
|
||||||
if (head != previous)
|
if (head != next)
|
||||||
{
|
{
|
||||||
RSTileItem prev = (RSTileItem) previous;
|
RSTileItem prev = (RSTileItem) next;
|
||||||
if (x != prev.getX() || y != prev.getY())
|
if (x != prev.getX() || y != prev.getY())
|
||||||
{
|
{
|
||||||
current = prev;
|
current = prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RSNode next = head.getNext();
|
RSNode previous = head.getNext();
|
||||||
if (current == null && head != next)
|
if (current == null && head != previous)
|
||||||
{
|
{
|
||||||
RSTileItem n = (RSTileItem) next;
|
RSTileItem n = (RSTileItem) previous;
|
||||||
if (x != n.getX() || y != n.getY())
|
if (x != n.getX() || y != n.getY())
|
||||||
{
|
{
|
||||||
current = n;
|
current = n;
|
||||||
forward = true;
|
//forward = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastUnlink != null && lastUnlink != previous && lastUnlink != next)
|
if (lastUnlink != null && lastUnlink != next && lastUnlink != previous)
|
||||||
{
|
{
|
||||||
ItemDespawned itemDespawned = new ItemDespawned(this, lastUnlink);
|
ItemDespawned itemDespawned = new ItemDespawned(this, lastUnlink);
|
||||||
client.getCallbacks().post(ItemDespawned.class, itemDespawned);
|
client.getCallbacks().post(ItemDespawned.class, itemDespawned);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current == null)
|
if (current != null)
|
||||||
{
|
{
|
||||||
return; // already seen this spawn, or no new item
|
current.setX(x);
|
||||||
|
current.setY(y);
|
||||||
|
ItemSpawned event = new ItemSpawned(this, current);
|
||||||
|
client.getCallbacks().post(ItemSpawned.class, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
RSTileItem item = (RSTileItem) current;
|
|
||||||
item.setX(x);
|
|
||||||
item.setY(y);
|
|
||||||
|
|
||||||
ItemSpawned itemSpawned = new ItemSpawned(this, item);
|
|
||||||
client.getCallbacks().post(ItemSpawned.class, itemSpawned);
|
|
||||||
|
|
||||||
current = forward ? current.getNext() : current.getPrevious();
|
|
||||||
|
|
||||||
// Send spawn events for anything on this tile which is at the wrong location, which happens
|
|
||||||
// when the scene base changes
|
|
||||||
} while (current != head && (((RSTileItem) current).getX() != x || ((RSTileItem) current).getY() != y));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, ThatGamerBlue <thatgamerblue@gmail.com>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
package net.runelite.rs.api;
|
package net.runelite.rs.api;
|
||||||
|
|
||||||
import net.runelite.mapping.Import;
|
import net.runelite.mapping.Import;
|
||||||
@@ -8,7 +32,7 @@ public interface RSNodeDeque
|
|||||||
RSNode getCurrent();
|
RSNode getCurrent();
|
||||||
|
|
||||||
@Import("sentinel")
|
@Import("sentinel")
|
||||||
RSNode getHead();
|
RSNode getSentinel();
|
||||||
|
|
||||||
@Import("last")
|
@Import("last")
|
||||||
RSNode last();
|
RSNode last();
|
||||||
|
|||||||
Reference in New Issue
Block a user