59static int getSlot(
int eAthenaSlot)
66 if (eAthenaSlot & 0x8000)
71 while (!(eAthenaSlot & mask))
76 return EQUIP_POINTS[position];
83 static const Uint16 _messages[] = {
122 int index, amount, itemId, equipType;
123 int identified, cards[4], itemType;
144 for (
int loop = 0; loop < number; loop++)
152 for (
int &card : cards)
156 INVENTORY_OFFSET : STORAGE_OFFSET;
160 Log::info(
"Index: %d, ID: %d, Type: %d, Identified: %d, "
161 "Qty: %d, Cards: %d, %d, %d, %d",
162 index, itemId, itemType, identified, amount,
163 cards[0], cards[1], cards[2], cards[3]);
167 inventory->
setItem(index, itemId, amount);
178 for (
int loop = 0; loop < number; loop++)
180 index = msg.
readInt16() - STORAGE_OFFSET;
189 for (
int &card : cards)
194 Log::info(
"Index: %d, ID: %d, Type: %d, Identified: %d, "
195 "Qty: %d, Cards: %d, %d, %d, %d",
196 index, itemId, itemType, identified, amount,
197 cards[0], cards[1], cards[2], cards[3]);
206 index = msg.
readInt16() - INVENTORY_OFFSET;
212 for (
int &card : cards)
231 if (item && item->
getId() == itemId)
234 inventory->
setItem(index, itemId, amount);
241 index = msg.
readInt16() - INVENTORY_OFFSET;
245 item->increaseQuantity(-amount);
246 if (item->getQuantity() == 0)
253 index = msg.
readInt16() - INVENTORY_OFFSET;
262 item->setQuantity(amount);
272 index = msg.
readInt16() - INVENTORY_OFFSET;
284 item->setQuantity(amount);
317 index = msg.
readInt16() - STORAGE_OFFSET;
323 for (
int &card : cards)
329 item->increaseQuantity(amount);
337 index = msg.
readInt16() - STORAGE_OFFSET;
341 item->increaseQuantity(-amount);
342 if (item->getQuantity() == 0)
362 for (
int loop = 0; loop < number; loop++)
364 index = msg.
readInt16() - INVENTORY_OFFSET;
374 inventory->
setItem(index, itemId, 1);
384 index = msg.
readInt16() - INVENTORY_OFFSET;
395 index = msg.
readInt16() - INVENTORY_OFFSET;
422 Log::info(
"Couldn't set attacke range due to the lack"
423 "of an initialized map.");
435 index -= INVENTORY_OFFSET;
455 Item *item =
event.getItem(
"item");
460 int index = item->
getInvIndex() + INVENTORY_OFFSET;
481 int amount =
event.getInt(
"amount", 1);
491 int newIndex =
event.getInt(
"newIndex", -1);
499 int source =
event.getInt(
"source");
500 int destination =
event.getInt(
"destination");
501 int amount =
event.getInt(
"amount", 1);
void listen(Event::Channel channel)
Map * getCurrentMap()
Returns the currently active map.
static Game * instance()
Provides access to the game instance.
void updateButtons()
Updates the buttons.
void close() override
Closes the Storage Window, as well as telling the server that the window has been closed.
void clear()
Reset all item slots.
void setItem(int index, int id, int quantity)
Sets the item at the given position.
Item * getItem(int index) const
Returns the item at the specified index.
void removeItemAt(int index)
Remove the item at the specified index from the inventory.
const ItemInfo & get(int id) const
Defines a class for storing generic item infos.
Represents one or more instances of a certain item type.
int getQuantity() const
Returns the number of items.
int getInvIndex() const
Returns the inventory index of this item.
int getId() const
Returns the item id.
void setAttackRange(int range)
Sets the attack range.
void pickedUp(const ItemInfo &itemInfo, int amount, unsigned char fail)
Shows item pickup notifications.
int getTileWidth() const
Returns the tile width of this map.
const uint16_t * handledMessages
void setEquipment(int index, int inventoryIndex)
size_t getSize(int type) const override
~InventoryHandler() override
void event(Event::Channel channel, const Event &event) override
InventoryWindow * mStorageWindow
void handleMessage(MessageIn &msg) override
std::vector< InventoryItem > mInventoryItems
Used for parsing an incoming message from eAthena.
void skip(unsigned int length)
Skips a given number of bytes.
uint16_t readInt16()
Reads an unsigned 16-bit integer from the message.
uint8_t readInt8()
Reads an unsigned 8-bit integer from the message.
uint16_t getId() const
Returns the message ID.
uint32_t readInt32()
Reads an unsigned 32-bit integer from the message.
unsigned int getLength() const
Returns the message length.
Used for building an outgoing message to eAthena.
void writeInt32(uint32_t value)
Writes an unsigned 32-bit integer to the message.
void writeInt16(uint16_t value)
Writes an unsigned 16-bit integer to the message.
ItemDB * itemDb
Items info database.
void serverNotice(const std::string &message)
InventoryWindow * inventoryWindow
LocalPlayer * local_player
Net::InventoryHandler * inventoryHandler
void info(const char *log_text,...) LOG_PRINTF_ATTR
Inventory * getInventory()
Returns the player's inventory.
Warning: buffers and other variables are shared, so there can be only one connection active at a time...
@ SMSG_PLAYER_ATTACK_RANGE
@ SMSG_PLAYER_INVENTORY_ADD
@ SMSG_PLAYER_INVENTORY_USE
@ SMSG_PLAYER_STORAGE_CLOSE
@ SMSG_PLAYER_STORAGE_REMOVE
@ SMSG_PLAYER_INVENTORY_REMOVE
@ CMSG_PLAYER_INVENTORY_USE
@ SMSG_PLAYER_STORAGE_ADD
@ SMSG_PLAYER_STORAGE_EQUIP
@ CMSG_PLAYER_INVENTORY_DROP
@ SMSG_PLAYER_ARROW_EQUIP
@ SMSG_PLAYER_STORAGE_STATUS
@ SMSG_PLAYER_STORAGE_ITEMS
Used to cache storage data until we get size data for it.