ManaPlus
Public Member Functions | Private Attributes
EAthena::InventoryHandler Class Reference

#include <inventoryhandler.h>

Inheritance diagram for EAthena::InventoryHandler:
Ea::InventoryHandler Net::InventoryHandler

Public Member Functions

 InventoryHandler ()
 
 ~InventoryHandler ()
 
void clear () const
 
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 moveItemInventoryToStorage (const int slot, const int amount) 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
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 ()
 

Private Attributes

int mItemIndex
 

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()

EAthena::InventoryHandler::InventoryHandler ( )

Definition at line 76 of file inventoryhandler.cpp.

76  :
78  mItemIndex(0)
79 {
80  inventoryHandler = this;
81 
84 }
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:89
Ea::InventoryItems mCartItems
Ea::InventoryItems mInventoryItems

References inventoryHandler, EAthena::InventoryRecv::mCartItems, and EAthena::InventoryRecv::mInventoryItems.

◆ ~InventoryHandler()

EAthena::InventoryHandler::~InventoryHandler ( )
virtual

Reimplemented from Ea::InventoryHandler.

Definition at line 86 of file inventoryhandler.cpp.

87 {
88  inventoryHandler = nullptr;
89 }

References inventoryHandler.

Member Function Documentation

◆ clear()

void EAthena::InventoryHandler::clear ( ) const
virtual

◆ closeStorage()

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

Implements Net::InventoryHandler.

Definition at line 313 of file inventoryhandler.cpp.

314 {
315  createOutPacket(CMSG_CLOSE_STORAGE);
316 }
#define createOutPacket(name)
Definition: messageout.h:37

References createOutPacket.

◆ convertFromServerSlot()

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

Implements Net::InventoryHandler.

Definition at line 573 of file inventoryhandler.cpp.

574 {
575  if (serverSlot < 0 || serverSlot >= 17)
576  return 0;
577 
578  return CAST_S32(EQUIP_CONVERT[serverSlot]);
579 }
#define CAST_S32
Definition: cast.h:30
const EquipSlot::Type EQUIP_CONVERT[]

References CAST_S32, and EQUIP_CONVERT.

◆ dropItem()

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

Implements Net::InventoryHandler.

Definition at line 158 of file inventoryhandler.cpp.

159 {
160  if (item == nullptr)
161  return;
162 
163  createOutPacket(CMSG_PLAYER_INVENTORY_DROP);
164  const int16_t index = CAST_S16(item->getInvIndex() + INVENTORY_OFFSET);
165  if (packetVersion >= 20101124)
166  {
167  outMsg.writeInt16(index, "index");
168  outMsg.writeInt16(CAST_S16(amount), "amount");
169  }
170  else if (packetVersion >= 20080827)
171  {
172  outMsg.writeInt16(0, "unknown");
173  outMsg.writeInt16(index, "index");
174  outMsg.writeInt32(0, "unknown");
175  outMsg.writeInt16(0, "unknown");
176  outMsg.writeInt8(0, "unknown");
177  outMsg.writeInt16(CAST_S16(amount), "amount");
178  }
179  else if (packetVersion >= 20070212)
180  {
181  outMsg.writeInt16(0, "unknown");
182  outMsg.writeInt8(0, "unknown");
183  outMsg.writeInt16(index, "index");
184  outMsg.writeInt8(0, "unknown");
185  outMsg.writeInt16(CAST_S16(amount), "amount");
186  }
187  else if (packetVersion >= 20070108)
188  {
189  outMsg.writeInt32(0, "unknown");
190  outMsg.writeInt32(0, "unknown");
191  outMsg.writeInt16(0, "unknown");
192  outMsg.writeInt16(index, "index");
193  outMsg.writeInt32(0, "unknown");
194  outMsg.writeInt16(CAST_S16(amount), "amount");
195  }
196  else if (packetVersion >= 20060327)
197  {
198  outMsg.writeInt32(0, "unknown");
199  outMsg.writeInt16(0, "unknown");
200  outMsg.writeInt16(index, "index");
201  outMsg.writeInt32(0, "unknown");
202  outMsg.writeInt8(0, "unknown");
203  outMsg.writeInt16(CAST_S16(amount), "amount");
204  }
205  else if (packetVersion >= 20050719)
206  {
207  outMsg.writeInt8(0, "unknown");
208  outMsg.writeInt16(index, "index");
209  outMsg.writeInt8(0, "unknown");
210  outMsg.writeInt32(0, "unknown");
211  outMsg.writeInt16(CAST_S16(amount), "amount");
212  }
213  else if (packetVersion >= 20050718)
214  {
215  outMsg.writeInt32(0, "unknown");
216  outMsg.writeInt16(index, "index");
217  outMsg.writeInt16(0, "unknown");
218  outMsg.writeInt16(CAST_S16(amount), "amount");
219  }
220  else if (packetVersion >= 20050628)
221  {
222  outMsg.writeInt8(0, "unknown");
223  outMsg.writeInt16(index, "index");
224  outMsg.writeInt32(0, "unknown");
225  outMsg.writeInt8(0, "unknown");
226  outMsg.writeInt16(CAST_S16(amount), "amount");
227  }
228  else if (packetVersion >= 20050509)
229  {
230  outMsg.writeInt16(0, "unknown");
231  outMsg.writeInt8(0, "unknown");
232  outMsg.writeInt16(index, "index");
233  outMsg.writeInt8(0, "unknown");
234  outMsg.writeInt16(CAST_S16(amount), "amount");
235  }
236  else if (packetVersion >= 20050110)
237  {
238  outMsg.writeInt32(0, "unknown");
239  outMsg.writeInt32(0, "unknown");
240  outMsg.writeInt32(0, "unknown");
241  outMsg.writeInt8(0, "unknown");
242  outMsg.writeInt16(index, "index");
243  outMsg.writeInt8(0, "unknown");
244  outMsg.writeInt16(CAST_S16(amount), "amount");
245  }
246  else if (packetVersion >= 20041129)
247  {
248  outMsg.writeInt16(0, "unknown");
249  outMsg.writeInt16(index, "index");
250  outMsg.writeInt32(0, "unknown");
251  outMsg.writeInt16(CAST_S16(amount), "amount");
252  }
253  else if (packetVersion >= 20041025)
254  {
255  outMsg.writeInt32(0, "unknown");
256  outMsg.writeInt16(index, "index");
257  outMsg.writeInt16(0, "unknown");
258  outMsg.writeInt16(CAST_S16(amount), "amount");
259  }
260  else if (packetVersion >= 20041005)
261  {
262  outMsg.writeInt16(0, "unknown");
263  outMsg.writeInt8(0, "unknown");
264  outMsg.writeInt16(index, "index");
265  outMsg.writeInt32(0, "unknown");
266  outMsg.writeInt8(0, "unknown");
267  outMsg.writeInt16(CAST_S16(amount), "amount");
268  }
269  else if (packetVersion >= 20040920)
270  {
271  outMsg.writeInt32(0, "unknown");
272  outMsg.writeInt32(0, "unknown");
273  outMsg.writeInt16(0, "unknown");
274  outMsg.writeInt16(index, "index");
275  outMsg.writeInt16(0, "unknown");
276  outMsg.writeInt8(0, "unknown");
277  outMsg.writeInt16(CAST_S16(amount), "amount");
278  }
279  else if (packetVersion >= 20040906)
280  {
281  outMsg.writeInt32(0, "unknown");
282  outMsg.writeInt16(index, "index");
283  outMsg.writeInt32(0, "unknown");
284  outMsg.writeInt16(0, "unknown");
285  outMsg.writeInt8(0, "unknown");
286  outMsg.writeInt16(CAST_S16(amount), "amount");
287  }
288  else if (packetVersion >= 20040809)
289  {
290  outMsg.writeInt32(0, "unknown");
291  outMsg.writeInt16(0, "unknown");
292  outMsg.writeInt16(index, "index");
293  outMsg.writeInt32(0, "unknown");
294  outMsg.writeInt8(0, "unknown");
295  outMsg.writeInt16(CAST_S16(amount), "amount");
296  }
297  else if (packetVersion >= 20040726)
298  {
299  outMsg.writeInt16(0, "unknown");
300  outMsg.writeInt8(0, "unknown");
301  outMsg.writeInt16(index, "index");
302  outMsg.writeInt32(0, "unknown");
303  outMsg.writeInt8(0, "unknown");
304  outMsg.writeInt16(CAST_S16(amount), "amount");
305  }
306  else
307  {
308  outMsg.writeInt16(index, "index");
309  outMsg.writeInt16(CAST_S16(amount), "amount");
310  }
311 }
#define CAST_S16
Definition: cast.h:28
int getInvIndex() const
Definition: item.h:165
static const int INVENTORY_OFFSET
Definition: inventory.h:27
int packetVersion
Definition: client.cpp:125

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

◆ equipItem()

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

Implements Net::InventoryHandler.

Definition at line 99 of file inventoryhandler.cpp.

100 {
101  if (item == nullptr)
102  return;
103 
104  createOutPacket(CMSG_PLAYER_EQUIP);
105  outMsg.writeInt16(CAST_S16(
106  item->getInvIndex() + INVENTORY_OFFSET), "index");
107  // here we set flag for any slots,
108  // probably better set to slot from item properties
109  if (packetVersion >= 20130320)
110  outMsg.writeInt32(0xFFFFFFFFU, "wear location");
111  else
112  outMsg.writeInt16(0x7FFFU, "wear location");
113 }

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

◆ expandInventory()

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

Implements Net::InventoryHandler.

Definition at line 618 of file inventoryhandler.cpp.

619 {
620  if (packetVersionMain < 20181031 &&
621  packetVersionRe < 20181031 &&
622  packetVersionZero < 20181114)
623  {
624  return;
625  }
626  createOutPacket(CMSG_INVENTORY_EXPAND);
627 }
int packetVersionRe
Definition: client.cpp:127
int packetVersionMain
Definition: client.cpp:126
int packetVersionZero
Definition: client.cpp:128

References createOutPacket, packetVersionMain, packetVersionRe, and packetVersionZero.

◆ expandInventoryConfirm()

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

Implements Net::InventoryHandler.

Definition at line 629 of file inventoryhandler.cpp.

630 {
631  if (packetVersionMain < 20181031 &&
632  packetVersionRe < 20181031 &&
633  packetVersionZero < 20181114)
634  {
635  return;
636  }
637  createOutPacket(CMSG_INVENTORY_EXPAND_CONFIRM);
638 }

References createOutPacket, packetVersionMain, packetVersionRe, and packetVersionZero.

◆ expandInventoryReject()

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

Implements Net::InventoryHandler.

Definition at line 640 of file inventoryhandler.cpp.

641 {
642  if (packetVersionMain < 20181031 &&
643  packetVersionRe < 20181031 &&
644  packetVersionZero < 20181114)
645  {
646  return;
647  }
648  createOutPacket(CMSG_INVENTORY_EXPAND_REJECT);
649 }

References createOutPacket, packetVersionMain, packetVersionRe, and packetVersionZero.

◆ favoriteItem()

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

Implements Net::InventoryHandler.

Definition at line 549 of file inventoryhandler.cpp.

551 {
552  if (item == nullptr)
553  return;
554  if (packetVersion < 20120410)
555  return;
556  createOutPacket(CMSG_PLAYER_FAVORITE_ITEM);
557  outMsg.writeInt16(CAST_S16(item->getInvIndex()
558  + INVENTORY_OFFSET),
559  "item index");
560  outMsg.writeInt8(static_cast<int8_t>(favorite), "favorite flag");
561 }

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

◆ getItemIndex()

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

Implements Net::InventoryHandler.

Definition at line 97 of file inventoryhandler.h.

98  { return mItemIndex; }

References mItemIndex.

◆ getProjectileSlot()

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

Implements Net::InventoryHandler.

Definition at line 94 of file inventoryhandler.h.

95  { return 10; }

◆ identifyItem()

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

Implements Net::InventoryHandler.

Definition at line 591 of file inventoryhandler.cpp.

592 {
593  if (packetVersion < 20150513)
594  return;
595  createOutPacket(CMSG_QUICK_IDENTIFY_ITEM);
596  outMsg.writeInt16(CAST_S16(item->getInvIndex()),
597  "item index");
598 }

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

◆ insertCard()

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

Implements Net::InventoryHandler.

Definition at line 539 of file inventoryhandler.cpp.

541 {
542  createOutPacket(CMSG_PLAYER_INSERT_CARD);
543  outMsg.writeInt16(CAST_S16(cardIndex + INVENTORY_OFFSET),
544  "card index");
545  outMsg.writeInt16(CAST_S16(itemIndex + INVENTORY_OFFSET),
546  "item index");
547 }

References CAST_S16, createOutPacket, and INVENTORY_OFFSET.

◆ mergeItemsAck()

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

Implements Net::InventoryHandler.

Definition at line 600 of file inventoryhandler.cpp.

601 {
602  createOutPacket(CMSG_MERGE_ITEM_ACK);
603  const size_t sz = items.size();
604  outMsg.writeInt16(CAST_S16(sz * 2 + 4),
605  "len");
606  FOR_EACH (STD_VECTOR<Item*>::const_iterator, it, items)
607  {
608  outMsg.writeInt16(CAST_S16((*it)->getInvIndex() + 2),
609  "item index");
610  }
611 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25

References CAST_S16, createOutPacket, and FOR_EACH.

◆ mergetItemsCancel()

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

Implements Net::InventoryHandler.

Definition at line 613 of file inventoryhandler.cpp.

614 {
615  createOutPacket(CMSG_MERGE_ITEM_CANCEL);
616 }

References createOutPacket.

◆ moveItem2()

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

Implements Net::InventoryHandler.

Definition at line 484 of file inventoryhandler.cpp.

488 {
489  int packet = 0;
490  int offset = INVENTORY_OFFSET;
491  if (source == InventoryType::Inventory)
492  {
493  if (destination == InventoryType::Storage)
494  {
495  moveItemInventoryToStorage(slot, amount);
496  return;
497  }
498  else if (destination == InventoryType::Cart)
499  {
500  packet = CMSG_MOVE_TO_CART;
501  }
502  }
503  else if (source == InventoryType::Storage)
504  {
505  offset = STORAGE_OFFSET;
506  if (destination == InventoryType::Inventory)
507  packet = CMSG_MOVE_FROM_STORAGE;
508  else if (destination == InventoryType::Cart)
509  packet = CMSG_MOVE_FROM_STORAGE_TO_CART;
510  }
511  else if (source == InventoryType::Cart)
512  {
513  if (destination == InventoryType::Inventory)
514  packet = CMSG_MOVE_FROM_CART;
515  else if (destination == InventoryType::Storage)
516  packet = CMSG_MOVE_FROM_CART_TO_STORAGE;
517  }
518 
519  // for packetVersion < 20101124 need use other packet offset
520  if (packet != 0)
521  {
523  outMsg.writeInt16(CAST_S16(slot + offset), "index");
524  outMsg.writeInt32(amount, "amount");
525  }
526 }
void moveItemInventoryToStorage(const int slot, const int amount) const
static const int STORAGE_OFFSET
Definition: inventory.h:28
#define packet(name, id, sz, comment)

References InventoryType::Cart, CAST_S16, createOutPacket, InventoryType::Inventory, INVENTORY_OFFSET, moveItemInventoryToStorage(), packet, InventoryType::Storage, and STORAGE_OFFSET.

◆ moveItemInventoryToStorage()

void EAthena::InventoryHandler::moveItemInventoryToStorage ( const int  slot,
const int  amount 
) const

Definition at line 318 of file inventoryhandler.cpp.

320 {
321  createOutPacket(CMSG_MOVE_TO_STORAGE);
322  if (packetVersion >= 20101124)
323  {
324  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
325  outMsg.writeInt32(amount, "amount");
326  }
327  else if (packetVersion >= 20080827)
328  {
329  outMsg.writeInt8(0, "unknown");
330  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
331  outMsg.writeInt32(0, "unknown");
332  outMsg.writeInt32(0, "unknown");
333  outMsg.writeInt32(0, "unknown");
334  outMsg.writeInt16(0, "unknown");
335  outMsg.writeInt8(0, "unknown");
336  outMsg.writeInt32(amount, "amount");
337  }
338  else if (packetVersion >= 20070212)
339  {
340  outMsg.writeInt32(0, "unknown");
341  outMsg.writeInt8(0, "unknown");
342  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
343  outMsg.writeInt8(0, "unknown");
344  outMsg.writeInt32(amount, "amount");
345  }
346  else if (packetVersion >= 20070108)
347  {
348  outMsg.writeInt16(0, "unknown");
349  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
350  outMsg.writeInt32(0, "unknown");
351  outMsg.writeInt16(0, "unknown");
352  outMsg.writeInt8(0, "unknown");
353  outMsg.writeInt32(amount, "amount");
354  }
355  else if (packetVersion >= 20060327)
356  {
357  outMsg.writeInt16(0, "unknown");
358  outMsg.writeInt8(0, "unknown");
359  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
360  outMsg.writeInt32(0, "unknown");
361  outMsg.writeInt32(0, "unknown");
362  outMsg.writeInt32(0, "unknown");
363  outMsg.writeInt32(amount, "amount");
364  }
365  else if (packetVersion >= 20050719)
366  {
367  outMsg.writeInt32(0, "unknown");
368  outMsg.writeInt32(0, "unknown");
369  outMsg.writeInt32(0, "unknown");
370  outMsg.writeInt16(0, "unknown");
371  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
372  outMsg.writeInt32(0, "unknown");
373  outMsg.writeInt32(0, "unknown");
374  outMsg.writeInt8(0, "unknown");
375  outMsg.writeInt32(amount, "amount");
376  }
377  else if (packetVersion >= 20050718)
378  {
379  outMsg.writeInt32(0, "unknown");
380  outMsg.writeInt32(0, "unknown");
381  outMsg.writeInt16(0, "unknown");
382  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
383  outMsg.writeInt16(0, "unknown");
384  outMsg.writeInt8(0, "unknown");
385  outMsg.writeInt32(amount, "amount");
386  }
387  else if (packetVersion >= 20050628)
388  {
389  outMsg.writeInt32(0, "unknown");
390  outMsg.writeInt32(0, "unknown");
391  outMsg.writeInt32(0, "unknown");
392  outMsg.writeInt16(0, "unknown");
393  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
394  outMsg.writeInt32(0, "unknown");
395  outMsg.writeInt32(0, "unknown");
396  outMsg.writeInt16(0, "unknown");
397  outMsg.writeInt32(amount, "amount");
398  }
399  else if (packetVersion >= 20050509)
400  {
401  outMsg.writeInt32(0, "unknown");
402  outMsg.writeInt8(0, "unknown");
403  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
404  outMsg.writeInt8(0, "unknown");
405  outMsg.writeInt32(amount, "amount");
406  }
407  else if (packetVersion >= 20050110)
408  {
409  outMsg.writeInt32(0, "unknown");
410  outMsg.writeInt32(0, "unknown");
411  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
412  outMsg.writeInt32(0, "unknown");
413  outMsg.writeInt16(0, "unknown");
414  outMsg.writeInt32(amount, "amount");
415  }
416  else if (packetVersion >= 20041129)
417  {
418  outMsg.writeInt16(0, "unknown");
419  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
420  outMsg.writeInt32(0, "unknown");
421  outMsg.writeInt32(amount, "amount");
422  }
423  else if (packetVersion >= 20041025)
424  {
425  outMsg.writeInt32(0, "unknown");
426  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
427  outMsg.writeInt8(0, "unknown");
428  outMsg.writeInt32(amount, "amount");
429  }
430  else if (packetVersion >= 20041005)
431  {
432  outMsg.writeInt16(0, "unknown");
433  outMsg.writeInt8(0, "unknown");
434  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
435  outMsg.writeInt32(0, "unknown");
436  outMsg.writeInt8(0, "unknown");
437  outMsg.writeInt32(amount, "amount");
438  }
439  else if (packetVersion >= 20040920)
440  {
441  outMsg.writeInt32(0, "unknown");
442  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
443  outMsg.writeInt32(0, "unknown");
444  outMsg.writeInt32(0, "unknown");
445  outMsg.writeInt32(0, "unknown");
446  outMsg.writeInt8(0, "unknown");
447  outMsg.writeInt32(amount, "amount");
448  }
449  else if (packetVersion >= 20040906)
450  {
451  outMsg.writeInt8(0, "unknown");
452  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
453  outMsg.writeInt32(0, "unknown");
454  outMsg.writeInt32(0, "unknown");
455  outMsg.writeInt16(0, "unknown");
456  outMsg.writeInt32(amount, "amount");
457  }
458  else if (packetVersion >= 20040809)
459  {
460  outMsg.writeInt16(0, "unknown");
461  outMsg.writeInt8(0, "unknown");
462  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
463  outMsg.writeInt32(0, "unknown");
464  outMsg.writeInt32(0, "unknown");
465  outMsg.writeInt32(0, "unknown");
466  outMsg.writeInt32(amount, "amount");
467  }
468  else if (packetVersion >= 20040726)
469  {
470  outMsg.writeInt16(0, "unknown");
471  outMsg.writeInt8(0, "unknown");
472  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
473  outMsg.writeInt32(0, "unknown");
474  outMsg.writeInt8(0, "unknown");
475  outMsg.writeInt32(amount, "amount");
476  }
477  else
478  {
479  outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
480  outMsg.writeInt32(amount, "amount");
481  }
482 }

References CAST_S16, createOutPacket, INVENTORY_OFFSET, and packetVersion.

Referenced by moveItem2().

◆ selectCart()

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

Implements Net::InventoryHandler.

Definition at line 581 of file inventoryhandler.cpp.

583 {
584  if (packetVersion < 20150805)
585  return;
586  createOutPacket(CMSG_SELECT_CART);
587  outMsg.writeBeingId(accountId, "account id");
588  outMsg.writeInt8(CAST_S8(type), "type");
589 }
#define CAST_S8
Definition: cast.h:26

References CAST_S8, createOutPacket, and packetVersion.

◆ selectEgg()

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

Implements Net::InventoryHandler.

Definition at line 563 of file inventoryhandler.cpp.

564 {
565  if (item == nullptr)
566  return;
567  createOutPacket(CMSG_PET_SELECT_EGG);
568  outMsg.writeInt16(CAST_S16(
569  item->getInvIndex() + INVENTORY_OFFSET), "index");
571 }
MenuTypeT menu
Definition: menu.cpp:28
@ Unknown
Definition: menutype.h:29

References CAST_S16, createOutPacket, Item::getInvIndex(), INVENTORY_OFFSET, EAthena::menu, and MenuType::Unknown.

◆ unequipItem()

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

Implements Net::InventoryHandler.

Definition at line 115 of file inventoryhandler.cpp.

116 {
117  if (item == nullptr)
118  return;
119 
120  createOutPacket(CMSG_PLAYER_UNEQUIP);
121  outMsg.writeInt16(CAST_S16(
122  item->getInvIndex() + INVENTORY_OFFSET), "index");
123 }

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

◆ useCard()

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

Implements Net::InventoryHandler.

Definition at line 528 of file inventoryhandler.cpp.

529 {
530  if (item == nullptr)
531  return;
532 
533  mItemIndex = item->getInvIndex();
534  createOutPacket(CMSG_PLAYER_USE_CARD);
535  outMsg.writeInt16(CAST_S16(
536  mItemIndex + INVENTORY_OFFSET), "index");
537 }

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

◆ useItem() [1/2]

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

Implements Net::InventoryHandler.

Definition at line 125 of file inventoryhandler.cpp.

126 {
127  if (item == nullptr)
128  return;
129 
130  createOutPacket(CMSG_PLAYER_INVENTORY_USE);
131  outMsg.writeInt16(CAST_S16(
132  item->getInvIndex() + INVENTORY_OFFSET), "index");
133  outMsg.writeInt32(item->getId(), "unused");
134 }
int getId() const
Definition: item.h:81

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

◆ useItem() [2/2]

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

Implements Net::InventoryHandler.

Definition at line 136 of file inventoryhandler.cpp.

138 {
139  if (item == nullptr)
140  return;
141 
142  if (serverVersion > 0)
143  {
144  createOutPacket(CMSG_PLAYER_INVENTORY_USE2);
145  outMsg.writeInt16(CAST_S16(
146  item->getInvIndex() + INVENTORY_OFFSET), "index");
147  outMsg.writeInt16(useType, "use type");
148  }
149  else
150  {
151  createOutPacket(CMSG_PLAYER_INVENTORY_USE);
152  outMsg.writeInt16(CAST_S16(
153  item->getInvIndex() + INVENTORY_OFFSET), "index");
154  outMsg.writeInt32(item->getId(), "unused");
155  }
156 }
int serverVersion
Definition: client.cpp:124

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

Field Documentation

◆ mItemIndex

int EAthena::InventoryHandler::mItemIndex
private

Definition at line 101 of file inventoryhandler.h.

Referenced by getItemIndex(), and useCard().


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