ManaPlus
Public Member Functions
TmwAthena::InventoryHandler Class Reference

#include <inventoryhandler.h>

Inheritance diagram for TmwAthena::InventoryHandler:
Ea::InventoryHandler Net::InventoryHandler

Public Member Functions

 InventoryHandler ()
 
 ~InventoryHandler ()
 
void equipItem (const Item *const item) const
 
void unequipItem (const Item *const item) const
 
void useItem (const Item *const item) const
 
void useItem (const Item *const item, const int16_t useType) const
 
void dropItem (const Item *const item, const int amount) const
 
void closeStorage () const
 
void moveItem2 (const InventoryTypeT source, const int slot, const int amount, const InventoryTypeT destination) const
 
void useCard (const Item *const item)
 
void insertCard (const int cardIndex, const int itemIndex) const
 
void favoriteItem (const Item *const item, const bool favorite) const
 
void selectEgg (const Item *const item) const
 
int convertFromServerSlot (const int serverSlot) const
 
void selectCart (const BeingId accountId, const int type) const
 
void identifyItem (const Item *const item) const
 
void mergeItemsAck (const std::vector< Item * > &items) const
 
void mergetItemsCancel () const
 
void expandInventory () const
 
void expandInventoryConfirm () const
 
void expandInventoryReject () const
 
int getProjectileSlot () const
 
int getItemIndex () const
 
- Public Member Functions inherited from Ea::InventoryHandler
void clear () const
 
bool canSplit (const Item *const item) const A_CONST
 
void splitItem (const Item *const item, const int amount) const
 
void moveItem (const int oldIndex, const int newIndex) const
 
size_t getSize (const InventoryTypeT type) const A_CONST
 
void destroyStorage () const
 
void forgotStorage () const
 
InventorygetStorage () const
 
- Public Member Functions inherited from Net::InventoryHandler
 InventoryHandler ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Ea::InventoryHandler
static void pushPickup (const BeingId floorId)
 
- Protected Member Functions inherited from Ea::InventoryHandler
 InventoryHandler ()
 

Detailed Description

Definition at line 32 of file inventoryhandler.h.

Constructor & Destructor Documentation

◆ InventoryHandler()

TmwAthena::InventoryHandler::InventoryHandler ( )

Definition at line 59 of file inventoryhandler.cpp.

59  :
61 {
62  inventoryHandler = this;
63 }
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:89

References inventoryHandler.

◆ ~InventoryHandler()

TmwAthena::InventoryHandler::~InventoryHandler ( )
virtual

Reimplemented from Ea::InventoryHandler.

Definition at line 65 of file inventoryhandler.cpp.

66 {
67  inventoryHandler = nullptr;
68 }

References inventoryHandler.

Member Function Documentation

◆ closeStorage()

void TmwAthena::InventoryHandler::closeStorage ( ) const
virtual

Implements Net::InventoryHandler.

Definition at line 125 of file inventoryhandler.cpp.

126 {
127  createOutPacket(CMSG_CLOSE_STORAGE);
128 }
#define createOutPacket(name)
Definition: messageout.h:37

References createOutPacket.

◆ convertFromServerSlot()

int TmwAthena::InventoryHandler::convertFromServerSlot ( const int  serverSlot) const
virtual

Implements Net::InventoryHandler.

Definition at line 171 of file inventoryhandler.cpp.

172 {
173  if (serverSlot < 0 || serverSlot > 13)
174  return 0;
175 
176  return CAST_S32(EQUIP_CONVERT[serverSlot]);
177 }
#define CAST_S32
Definition: cast.h:30
const EquipSlot::Type EQUIP_CONVERT[]

References CAST_S32, and EQUIP_CONVERT.

◆ dropItem()

void TmwAthena::InventoryHandler::dropItem ( const Item *const  item,
const int  amount 
) const
virtual

Implements Net::InventoryHandler.

Definition at line 114 of file inventoryhandler.cpp.

115 {
116  if (item == nullptr)
117  return;
118 
119  createOutPacket(CMSG_PLAYER_INVENTORY_DROP);
120  outMsg.writeInt16(CAST_S16(
121  item->getInvIndex() + INVENTORY_OFFSET), "index");
122  outMsg.writeInt16(CAST_S16(amount), "amount");
123 }
#define CAST_S16
Definition: cast.h:28
int getInvIndex() const
Definition: item.h:165
static const int INVENTORY_OFFSET
Definition: inventory.h:27

References CAST_S16, createOutPacket, Item::getInvIndex(), and INVENTORY_OFFSET.

◆ equipItem()

void TmwAthena::InventoryHandler::equipItem ( const Item *const  item) const
virtual

Implements Net::InventoryHandler.

Definition at line 70 of file inventoryhandler.cpp.

71 {
72  if (item == nullptr)
73  return;
74 
75  createOutPacket(CMSG_PLAYER_EQUIP);
76  outMsg.writeInt16(CAST_S16(
77  item->getInvIndex() + INVENTORY_OFFSET), "index");
78  outMsg.writeInt16(0, "unused");
79 }

References CAST_S16, createOutPacket, Item::getInvIndex(), and INVENTORY_OFFSET.

◆ expandInventory()

void TmwAthena::InventoryHandler::expandInventory ( ) const
virtual

Implements Net::InventoryHandler.

Definition at line 197 of file inventoryhandler.cpp.

198 {
199 }

◆ expandInventoryConfirm()

void TmwAthena::InventoryHandler::expandInventoryConfirm ( ) const
virtual

Implements Net::InventoryHandler.

Definition at line 201 of file inventoryhandler.cpp.

202 {
203 }

◆ expandInventoryReject()

void TmwAthena::InventoryHandler::expandInventoryReject ( ) const
virtual

Implements Net::InventoryHandler.

Definition at line 205 of file inventoryhandler.cpp.

206 {
207 }

◆ favoriteItem()

void TmwAthena::InventoryHandler::favoriteItem ( const Item *const  item,
const bool  favorite 
) const
virtual

Implements Net::InventoryHandler.

Definition at line 162 of file inventoryhandler.cpp.

164 {
165 }

◆ getItemIndex()

int TmwAthena::InventoryHandler::getItemIndex ( ) const
inlinevirtual

Implements Net::InventoryHandler.

Definition at line 92 of file inventoryhandler.h.

93  { return 0; }

◆ getProjectileSlot()

int TmwAthena::InventoryHandler::getProjectileSlot ( ) const
inlinevirtual

Implements Net::InventoryHandler.

Definition at line 89 of file inventoryhandler.h.

90  { return 10; }

◆ identifyItem()

void TmwAthena::InventoryHandler::identifyItem ( const Item *const  item) const
virtual

Implements Net::InventoryHandler.

Definition at line 184 of file inventoryhandler.cpp.

185 {
186 }

◆ insertCard()

void TmwAthena::InventoryHandler::insertCard ( const int  cardIndex,
const int  itemIndex 
) const
virtual

Implements Net::InventoryHandler.

Definition at line 157 of file inventoryhandler.cpp.

159 {
160 }

◆ mergeItemsAck()

void TmwAthena::InventoryHandler::mergeItemsAck ( const std::vector< Item * > &  items) const
virtual

Implements Net::InventoryHandler.

Definition at line 188 of file inventoryhandler.cpp.

190 {
191 }

◆ mergetItemsCancel()

void TmwAthena::InventoryHandler::mergetItemsCancel ( ) const
virtual

Implements Net::InventoryHandler.

Definition at line 193 of file inventoryhandler.cpp.

194 {
195 }

◆ moveItem2()

void TmwAthena::InventoryHandler::moveItem2 ( const InventoryTypeT  source,
const int  slot,
const int  amount,
const InventoryTypeT  destination 
) const
virtual

Implements Net::InventoryHandler.

Definition at line 130 of file inventoryhandler.cpp.

134 {
135  if (source == InventoryType::Inventory &&
136  destination == InventoryType::Storage)
137  {
138  createOutPacket(CMSG_MOVE_TO_STORAGE);
139  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET),
140  "index");
141  outMsg.writeInt32(amount, "amount");
142  }
143  else if (source == InventoryType::Storage &&
144  destination == InventoryType::Inventory)
145  {
146  createOutPacket(CMSG_MOVE_FROM_STORAGE);
147  outMsg.writeInt16(CAST_S16(slot + STORAGE_OFFSET),
148  "index");
149  outMsg.writeInt32(amount, "amount");
150  }
151 }
static const int STORAGE_OFFSET
Definition: inventory.h:28

References CAST_S16, createOutPacket, InventoryType::Inventory, INVENTORY_OFFSET, InventoryType::Storage, and STORAGE_OFFSET.

◆ selectCart()

void TmwAthena::InventoryHandler::selectCart ( const BeingId  accountId,
const int  type 
) const
virtual

Implements Net::InventoryHandler.

Definition at line 179 of file inventoryhandler.cpp.

181 {
182 }

◆ selectEgg()

void TmwAthena::InventoryHandler::selectEgg ( const Item *const  item) const
virtual

Implements Net::InventoryHandler.

Definition at line 167 of file inventoryhandler.cpp.

168 {
169 }

◆ unequipItem()

void TmwAthena::InventoryHandler::unequipItem ( const Item *const  item) const
virtual

Implements Net::InventoryHandler.

Definition at line 81 of file inventoryhandler.cpp.

82 {
83  if (item == nullptr)
84  return;
85 
86  createOutPacket(CMSG_PLAYER_UNEQUIP);
87  outMsg.writeInt16(CAST_S16(
88  item->getInvIndex() + INVENTORY_OFFSET), "index");
89 }

References CAST_S16, createOutPacket, Item::getInvIndex(), and INVENTORY_OFFSET.

◆ useCard()

void TmwAthena::InventoryHandler::useCard ( const Item *const  item)
virtual

Implements Net::InventoryHandler.

Definition at line 153 of file inventoryhandler.cpp.

154 {
155 }

◆ useItem() [1/2]

void TmwAthena::InventoryHandler::useItem ( const Item *const  item) const
virtual

Implements Net::InventoryHandler.

Definition at line 91 of file inventoryhandler.cpp.

92 {
93  if (item == nullptr)
94  return;
95 
96  createOutPacket(CMSG_PLAYER_INVENTORY_USE);
97  outMsg.writeInt16(CAST_S16(
98  item->getInvIndex() + INVENTORY_OFFSET), "index");
99  outMsg.writeInt32(item->getId(), "item id");
100 }
int getId() const
Definition: item.h:81

References CAST_S16, createOutPacket, Item::getId(), Item::getInvIndex(), and INVENTORY_OFFSET.

◆ useItem() [2/2]

void TmwAthena::InventoryHandler::useItem ( const Item *const  item,
const int16_t  useType 
) const
virtual

Implements Net::InventoryHandler.

Definition at line 102 of file inventoryhandler.cpp.

104 {
105  if (item == nullptr)
106  return;
107 
108  createOutPacket(CMSG_PLAYER_INVENTORY_USE);
109  outMsg.writeInt16(CAST_S16(
110  item->getInvIndex() + INVENTORY_OFFSET), "index");
111  outMsg.writeInt32(item->getId(), "item id");
112 }

References CAST_S16, createOutPacket, Item::getId(), Item::getInvIndex(), and INVENTORY_OFFSET.


The documentation for this class was generated from the following files: