From 90e0656c7562fc1761fefc023df56078732da3c0 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 24 May 2013 09:16:09 +0000 Subject: Slight cleanup in the cInventory / cItemGrid API git-svn-id: http://mc-server.googlecode.com/svn/trunk@1504 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/ItemGrid.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/ItemGrid.h') diff --git a/source/ItemGrid.h b/source/ItemGrid.h index 7a2a828b1..de8be059a 100644 --- a/source/ItemGrid.h +++ b/source/ItemGrid.h @@ -42,15 +42,18 @@ public: int GetSlotNum(int a_X, int a_Y) const; // tolua_end + /// Converts slot number into XY coords; sets coords to -1 on invalid slot number. Exported in ManualBindings.cpp void GetSlotCoords(int a_SlotNum, int & a_X, int & a_Y) const; + + cItem & GetSlot(int a_X, int a_Y); // TODO: This will be removed! + cItem & GetSlot(int a_SlotNum); // TODO: This will be removed! + // tolua_begin // Retrieve slots by coords or slot number; Logs warning and returns the first slot on invalid coords / slotnum const cItem & GetSlot(int a_X, int a_Y) const; - cItem & GetSlot(int a_X, int a_Y); const cItem & GetSlot(int a_SlotNum) const; - cItem & GetSlot(int a_SlotNum); // Set slot by coords or slot number; Logs warning and doesn't set on invalid coords / slotnum void SetSlot(int a_X, int a_Y, const cItem & a_Item); @@ -89,6 +92,12 @@ public: */ int ChangeSlotCount(int a_SlotNum, int a_AddToCount); + /** Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot. + If the slot is empty, ignores the call. + Returns the new count. + */ + int ChangeSlotCount(int a_X, int a_Y, int a_AddToCount); + /// Returns the number of items of type a_Item that are stored int HowManyItems(const cItem & a_Item); @@ -110,6 +119,9 @@ public: /// Adds the specified damage to the specified item; returns true if the item broke (but the item is left intact) bool DamageItem(int a_SlotNum, short a_Amount); + /// Adds the specified damage to the specified item; returns true if the item broke (but the item is left intact) + bool DamageItem(int a_X, int a_Y, short a_Amount); + // tolua_end -- cgit v1.2.3