ManaPlus
Public Member Functions | Private Attributes
Ea::EquipBackend Class Reference

#include <equipbackend.h>

Inheritance diagram for Ea::EquipBackend:
Equipment::Backend

Public Member Functions

 EquipBackend ()
 
ItemgetEquipment (const int index) const
 
void clear ()
 
void setEquipment (const int index, const int inventoryIndex)
 
- Public Member Functions inherited from Equipment::Backend
 Backend ()
 
virtual ~Backend ()
 

Private Attributes

int mEquipment [EQUIPMENT_SIZE]
 

Detailed Description

Definition at line 38 of file equipbackend.h.

Constructor & Destructor Documentation

◆ EquipBackend()

Ea::EquipBackend::EquipBackend ( )
inline

Definition at line 41 of file equipbackend.h.

42  {
43  memset(mEquipment, -1, sizeof(mEquipment));
44  }
int mEquipment[EQUIPMENT_SIZE]
Definition: equipbackend.h:105

References mEquipment.

Member Function Documentation

◆ clear()

void Ea::EquipBackend::clear ( )
inlinevirtual

Implements Equipment::Backend.

Definition at line 60 of file equipbackend.h.

61  {
62  Inventory *const inv = PlayerInfo::getInventory();
63  if (inv == nullptr)
64  return;
65  for (int i = 0; i < EQUIPMENT_SIZE; i++)
66  {
67  if (mEquipment[i] != -1)
68  {
69  Item* item = inv->getItem(i);
70  if (item != nullptr)
72  }
73 
74  mEquipment[i] = -1;
75  }
76  }
Item * getItem(const int index) const
Definition: inventory.cpp:83
Definition: item.h:50
void setEquipped(const Equipped equipped)
Definition: item.h:123
static const int EQUIPMENT_SIZE
Definition: equipment.h:29
const bool Equipped_false
Definition: equipped.h:30
Inventory * getInventory()
Definition: playerinfo.cpp:195

References EQUIPMENT_SIZE, Equipped_false, PlayerInfo::getInventory(), Inventory::getItem(), mEquipment, and Item::setEquipped().

Referenced by Ea::InventoryHandler::InventoryHandler(), EAthena::InventoryRecv::processInventoryEndContinue(), EAthena::InventoryRecv::processPlayerEquipment(), TmwAthena::InventoryRecv::processPlayerEquipment(), EAthena::InventoryRecv::processPlayerInventory(), TmwAthena::InventoryRecv::processPlayerInventory(), EAthena::InventoryRecv::processPlayerInventoryAdd(), and TmwAthena::InventoryRecv::processPlayerInventoryAdd().

◆ getEquipment()

Item* Ea::EquipBackend::getEquipment ( const int  index) const
inlinevirtual

Implements Equipment::Backend.

Definition at line 48 of file equipbackend.h.

49  {
50  int invyIndex = mEquipment[index];
51  if (invyIndex == -1)
52  return nullptr;
53 
54  const Inventory *const inv = PlayerInfo::getInventory();
55  if (inv != nullptr)
56  return inv->getItem(invyIndex);
57  return nullptr;
58  }

References PlayerInfo::getInventory(), Inventory::getItem(), and mEquipment.

◆ setEquipment()

void Ea::EquipBackend::setEquipment ( const int  index,
const int  inventoryIndex 
)
inline

Definition at line 78 of file equipbackend.h.

79  {
80  Inventory *const inv = PlayerInfo::getInventory();
81  if (inv == nullptr)
82  return;
83 
84  if (index < 0 || index >= EQUIPMENT_SIZE)
85  return;
86 
87  // Unequip existing item
88  Item *item = inv->getItem(mEquipment[index]);
89 
90  if (item != nullptr)
92 
93  // not checking index because it must be safe
94  mEquipment[index] = inventoryIndex;
95 
96  item = inv->getItem(inventoryIndex);
97  if (item != nullptr)
99 
100  if (inventoryWindow != nullptr)
101  inventoryWindow->updateButtons(nullptr);
102  }
void updateButtons(const Item *item)
const bool Equipped_true
Definition: equipped.h:30
InventoryWindow * inventoryWindow

References EQUIPMENT_SIZE, Equipped_false, Equipped_true, PlayerInfo::getInventory(), Inventory::getItem(), inventoryWindow, mEquipment, Item::setEquipped(), and InventoryWindow::updateButtons().

Referenced by EAthena::InventoryRecv::processInventoryEndContinue(), Ea::InventoryRecv::processPlayerArrowEquip(), EAthena::InventoryRecv::processPlayerEquip(), TmwAthena::InventoryRecv::processPlayerEquip(), EAthena::InventoryRecv::processPlayerEquipment(), TmwAthena::InventoryRecv::processPlayerEquipment(), EAthena::InventoryRecv::processPlayerUnEquip(), and TmwAthena::InventoryRecv::processPlayerUnEquip().

Field Documentation

◆ mEquipment

int Ea::EquipBackend::mEquipment[EQUIPMENT_SIZE]
private

Definition at line 105 of file equipbackend.h.

Referenced by clear(), EquipBackend(), getEquipment(), and setEquipment().


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