From 6280e89d8b255e062ae79df8a73b222b64e642f0 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sat, 30 May 2020 16:30:02 -0700 Subject: [PATCH] Added support for dropping cursor item to ground --- .../com/riiablo/engine/client/CursorMovementSystem.java | 2 +- core/src/com/riiablo/save/CharData.java | 4 ++++ core/src/com/riiablo/save/ItemData.java | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/com/riiablo/engine/client/CursorMovementSystem.java b/core/src/com/riiablo/engine/client/CursorMovementSystem.java index 75d739ba..be7633df 100644 --- a/core/src/com/riiablo/engine/client/CursorMovementSystem.java +++ b/core/src/com/riiablo/engine/client/CursorMovementSystem.java @@ -102,7 +102,7 @@ public class CursorMovementSystem extends BaseSystem { Vector2 position = mPosition.get(src).position; iso.toTile(tmpVec2.set(position)); - Riiablo.cursor.setItem(null); + Riiablo.charData.dropCursor(); if (socket == null) { factory.createItem(cursor, tmpVec2); } else { diff --git a/core/src/com/riiablo/save/CharData.java b/core/src/com/riiablo/save/CharData.java index 32f36c23..7e0504c1 100644 --- a/core/src/com/riiablo/save/CharData.java +++ b/core/src/com/riiablo/save/CharData.java @@ -380,6 +380,10 @@ public class CharData implements ItemData.UpdateListener, Pool.Poolable { return itemData; } + public void dropCursor() { + itemData.drop(); + } + public void itemToCursor(int i) { itemData.pickup(i); } diff --git a/core/src/com/riiablo/save/ItemData.java b/core/src/com/riiablo/save/ItemData.java index 3f27166a..737b80d2 100644 --- a/core/src/com/riiablo/save/ItemData.java +++ b/core/src/com/riiablo/save/ItemData.java @@ -212,6 +212,14 @@ public class ItemData { setLocation(item, Location.CURSOR); } + // TODO: should item location change if the item is dropped? is this what UNK3 and UNK5 represent? + void drop() { + assert cursor != INVALID_ITEM; + Item item = itemData.get(cursor); + cursor = INVALID_ITEM; + setLocation(item, null); + } + void storeCursor(StoreLoc storeLoc, int x, int y) { assert cursor != INVALID_ITEM; store(storeLoc, cursor, x, y);