ManaPlus
Functions | Variables
Ea::InventoryRecv Namespace Reference

Functions

void processItemUseResponse (Net::MessageIn &msg)
 
void processPlayerStorageStatus (Net::MessageIn &msg)
 
void processPlayerStorageClose (Net::MessageIn &msg)
 
void processPlayerAttackRange (Net::MessageIn &msg)
 
void processPlayerArrowEquip (Net::MessageIn &msg)
 

Variables

EquipBackend mEquips
 
InventoryItems mStorageItems
 
InventorymStorage = 0
 
PickupQueue mSentPickups
 
bool mDebugInventory = true
 

Function Documentation

◆ processItemUseResponse()

void Ea::InventoryRecv::processItemUseResponse ( Net::MessageIn msg)

Definition at line 60 of file inventoryrecv.cpp.

61 {
62  BLOCK_START("InventoryRecv::processItemUseResponse")
63  Inventory *const inventory = localPlayer != nullptr
64  ? PlayerInfo::getInventory() : nullptr;
65 
66  const int index = msg.readInt16("index") - INVENTORY_OFFSET;
67  const int amount = msg.readInt16("amount");
68 
69  if (msg.readUInt8("result") == 0)
70  {
72  }
73  else
74  {
75  if (inventory != nullptr)
76  {
77  if (Item *const item = inventory->getItem(index))
78  {
79  if (amount != 0)
80  item->setQuantity(amount);
81  else
82  inventory->removeItemAt(index);
83  }
84  }
85  }
86  BLOCK_END("InventoryRecv::processItemUseResponse")
87 }
Definition: item.h:50
static const int INVENTORY_OFFSET
Definition: inventory.h:27
if(!vert) return
LocalPlayer * localPlayer
bool msg(InputEvent &event)
Definition: chat.cpp:39
void notify(const unsigned int message)
Inventory * getInventory()
Definition: playerinfo.cpp:195
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References BLOCK_END, BLOCK_START, PlayerInfo::getInventory(), Inventory::getItem(), INVENTORY_OFFSET, localPlayer, Actions::msg(), NotifyManager::notify(), Inventory::removeItemAt(), and NotifyTypes::USE_FAILED.

◆ processPlayerArrowEquip()

void Ea::InventoryRecv::processPlayerArrowEquip ( Net::MessageIn msg)

Definition at line 160 of file inventoryrecv.cpp.

161 {
162  BLOCK_START("InventoryRecv::processPlayerArrowEquip")
163  int index = msg.readInt16("index");
164  if (index <= 1)
165  return;
166 
167  index -= INVENTORY_OFFSET;
168  mEquips.setEquipment(inventoryHandler->getProjectileSlot(), index);
169  ArrowsListener::distributeEvent();
170  BLOCK_END("InventoryRecv::processPlayerArrowEquip")
171 }
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:89
EquipBackend mEquips
void processPlayerArrowEquip(Net::MessageIn &msg)

References BLOCK_END, BLOCK_START, ArrowsListener::distributeEvent(), Net::InventoryHandler::getProjectileSlot(), INVENTORY_OFFSET, inventoryHandler, mEquips, Actions::msg(), and Ea::EquipBackend::setEquipment().

◆ processPlayerAttackRange()

void Ea::InventoryRecv::processPlayerAttackRange ( Net::MessageIn msg)

Definition at line 145 of file inventoryrecv.cpp.

146 {
147  BLOCK_START("InventoryRecv::processPlayerAttackRange")
148  const int range = msg.readInt16("range");
149  if (localPlayer != nullptr)
150  localPlayer->setAttackRange(range);
152  range,
153  Notify_true);
155  0,
156  Notify_true);
157  BLOCK_END("InventoryRecv::processPlayerAttackRange")
158 }
@ PLAYER_ATTACK_RANGE
Definition: attributes.h:52
void processPlayerAttackRange(Net::MessageIn &msg)
void setStatMod(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:159
void setStatBase(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:143
const bool Notify_true
Definition: notify.h:30

References BLOCK_END, BLOCK_START, localPlayer, Actions::msg(), Notify_true, Attributes::PLAYER_ATTACK_RANGE, Being::setAttackRange(), PlayerInfo::setStatBase(), and PlayerInfo::setStatMod().

◆ processPlayerStorageClose()

void Ea::InventoryRecv::processPlayerStorageClose ( Net::MessageIn msg)

Definition at line 126 of file inventoryrecv.cpp.

127 {
128  BLOCK_START("InventoryRecv::processPlayerStorageClose")
129  // Storage access has been closed
130  // Storage window deletes itself
131  if (storageWindow != nullptr)
132  {
134  storageWindow->close();
135  }
136  storageWindow = nullptr;
137 
138  if (mStorage != nullptr)
139  mStorage->clear();
140 
142  BLOCK_END("InventoryRecv::processPlayerStorageClose")
143 }
void clear()
Definition: inventory.cpp:238
#define delete2(var)
Definition: delete2.h:25
InventoryWindow * storageWindow
Inventory * mStorage

References BLOCK_END, BLOCK_START, Inventory::clear(), InventoryWindow::close(), delete2, mStorage, storageWindow, and InventoryWindow::unsetInventory().

◆ processPlayerStorageStatus()

void Ea::InventoryRecv::processPlayerStorageStatus ( Net::MessageIn msg)

Definition at line 89 of file inventoryrecv.cpp.

90 {
91  BLOCK_START("InventoryRecv::processPlayerStorageStatus")
92  /*
93  * This is the closest we get to an "Open Storage" packet from the
94  * server. It always comes after the two SMSG_PLAYER_STORAGE_...
95  * packets that update storage contents.
96  */
97  msg.readInt16("used count");
98  const int size = msg.readInt16("max size");
99 
100  if (mStorage == nullptr)
102 
103  FOR_EACH (Ea::InventoryItems::const_iterator, it, mStorageItems)
104  {
105  mStorage->setItem((*it).slot,
106  (*it).id,
107  (*it).type,
108  (*it).quantity,
109  (*it).refine,
110  (*it).color,
111  (*it).identified,
112  (*it).damaged,
113  (*it).favorite,
114  (*it).equip,
116  }
117  mStorageItems.clear();
118 
119  if (storageWindow == nullptr)
120  {
122  }
123  BLOCK_END("InventoryRecv::processPlayerStorageStatus")
124 }
virtual void setItem(const int index, const int id, const ItemTypeT type, const int quantity, const uint8_t refine, const ItemColor color, const Identified identified, const Damaged damaged, const Favorite favorite, const Equipm equipment, const Equipped equipped)
Definition: inventory.cpp:141
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:25
#define new
Definition: debug_new.h:147
const bool Equipped_false
Definition: equipped.h:30
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
InventoryItems mStorageItems
std::vector< InventoryItem > InventoryItems
int size()
Definition: emotedb.cpp:306

References BLOCK_END, BLOCK_START, CREATEWIDGETV, Equipped_false, FOR_EACH, DragDropSource::Inventory, Actions::msg(), mStorage, mStorageItems, Inventory::setItem(), EmoteDB::size(), InventoryType::Storage, and storageWindow.

Variable Documentation

◆ mDebugInventory

bool Ea::InventoryRecv::mDebugInventory = true

◆ mEquips

EquipBackend Ea::InventoryRecv::mEquips

◆ mSentPickups

PickupQueue Ea::InventoryRecv::mSentPickups

◆ mStorage

Inventory * Ea::InventoryRecv::mStorage = 0

◆ mStorageItems

InventoryItems Ea::InventoryRecv::mStorageItems