ManaPlus
Functions
EAthena::PetRecv Namespace Reference

Functions

void processPetMessage (Net::MessageIn &msg)
 
void processPetRoulette (Net::MessageIn &msg)
 
void processEggsList (Net::MessageIn &msg)
 
void processPetData (Net::MessageIn &msg)
 
void processPetStatus (Net::MessageIn &msg)
 
void processPetFood (Net::MessageIn &msg)
 
void processPetCatchProcess (Net::MessageIn &msg)
 
void processPetEvolution (Net::MessageIn &msg)
 

Function Documentation

◆ processEggsList()

void EAthena::PetRecv::processEggsList ( Net::MessageIn msg)

Definition at line 74 of file petrecv.cpp.

75 {
76  const int count = (msg.readInt16("len") - 4) / 2;
77  const Inventory *const inv = PlayerInfo::getInventory();
78  if (inv == nullptr)
79  return;
81 
82  if (count == 1)
83  {
84  const int index = msg.readInt16("index") - INVENTORY_OFFSET;
85  const Item *const item = inv->getItem(index);
87  return;
88  }
90 
91  for (int f = 0; f < count; f ++)
92  {
93  const int index = msg.readInt16("index") - INVENTORY_OFFSET;
94  const Item *const item = inv->getItem(index);
95 
96  if (item != nullptr)
97  dialog->addItem(item, 0);
98  }
99 }
Item * getItem(const int index) const
Definition: inventory.cpp:83
Definition: item.h:50
virtual void selectEgg(const Item *const item) const =0
void addItem(const Item *const item, const int price)
Definition: selldialog.cpp:238
static const int INVENTORY_OFFSET
Definition: inventory.h:27
#define CREATEWIDGETR0(type)
Definition: createwidget.h:39
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:89
bool msg(InputEvent &event)
Definition: chat.cpp:39
MenuTypeT menu
Definition: menu.cpp:28
@ Eggs
Definition: menutype.h:35
Inventory * getInventory()
Definition: playerinfo.cpp:195

References SellDialog::addItem(), CREATEWIDGETR0, MenuType::Eggs, PlayerInfo::getInventory(), Inventory::getItem(), INVENTORY_OFFSET, inventoryHandler, EAthena::menu, Actions::msg(), and Net::InventoryHandler::selectEgg().

◆ processPetCatchProcess()

void EAthena::PetRecv::processPetCatchProcess ( Net::MessageIn msg)

Definition at line 179 of file petrecv.cpp.

180 {
182 }
void notify(const unsigned int message)

References NotifyManager::notify(), and NotifyTypes::PET_CATCH_PROCESS.

◆ processPetData()

void EAthena::PetRecv::processPetData ( Net::MessageIn msg)

Definition at line 101 of file petrecv.cpp.

102 {
103  if (actorManager == nullptr)
104  return;
105  const int cmd = msg.readUInt8("type");
106  const BeingId id = msg.readBeingId("pet id");
107  Being *const dstBeing = actorManager->findBeing(id);
108  const int data = msg.readInt32("data");
109  if (cmd == 0) // pre init
110  {
111  PetInfo *const info = new PetInfo;
112  info->id = id;
114  PlayerInfo::setPetBeing(dstBeing);
115  return;
116  }
117  PetInfo *const info = PlayerInfo::getPet();
118  if (info == nullptr)
119  return;
120  switch (cmd)
121  {
122  case 1: // intimacy
123  info->intimacy = data;
124  break;
125  case 2: // hunger
126  info->hungry = data;
127  break;
128  case 3: // accesory
129  info->equip = data;
130  break;
131  case 4: // performance
132  info->performance = data;
133  break;
134  case 5: // hair style
135  info->hairStyle = data;
136  break;
137  default:
138  break;
139  }
140 }
ActorManager * actorManager
int BeingId
Definition: beingid.h:30
Being * findBeing(const BeingId id) const
Definition: being.h:96
uint32_t data
bool info(InputEvent &event)
Definition: commands.cpp:57
void setPetBeing(Being *const being)
Definition: playerinfo.cpp:560
void setPet(PetInfo *const info)
Definition: playerinfo.cpp:554
PetInfo * getPet()
Definition: playerinfo.cpp:576

References actorManager, data, ActorManager::findBeing(), PlayerInfo::getPet(), Actions::info(), Actions::msg(), PlayerInfo::setPet(), and PlayerInfo::setPetBeing().

◆ processPetEvolution()

void EAthena::PetRecv::processPetEvolution ( Net::MessageIn msg)

Definition at line 184 of file petrecv.cpp.

185 {
187  msg.readUInt8("result");
188 }
#define UNIMPLEMENTEDPACKET
Definition: logger.h:56

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processPetFood()

void EAthena::PetRecv::processPetFood ( Net::MessageIn msg)

Definition at line 169 of file petrecv.cpp.

170 {
171  const int result = msg.readUInt8("result");
172  msg.readItemId("food id");
173  if (result != 0)
175  else
177 }

References Actions::msg(), NotifyManager::notify(), NotifyTypes::PET_FEED_ERROR, and NotifyTypes::PET_FEED_OK.

◆ processPetMessage()

void EAthena::PetRecv::processPetMessage ( Net::MessageIn msg)

Definition at line 48 of file petrecv.cpp.

49 {
50  // techinally this is hercules pet emote,
51  // but it may send also hungry level on connect
52  // for both exists other packets.
53  msg.readBeingId("pet id");
54  msg.readInt32("param");
55 }

References Actions::msg().

◆ processPetRoulette()

void EAthena::PetRecv::processPetRoulette ( Net::MessageIn msg)

Definition at line 57 of file petrecv.cpp.

58 {
59  const uint8_t data = msg.readUInt8("data");
60  switch (data)
61  {
62  case 0:
64  break;
65  case 1:
67  break;
68  default:
70  break;
71  }
72 }

References data, Actions::msg(), NotifyManager::notify(), NotifyTypes::PET_CATCH_FAILED, NotifyTypes::PET_CATCH_SUCCESS, and NotifyTypes::PET_CATCH_UNKNOWN.

◆ processPetStatus()

void EAthena::PetRecv::processPetStatus ( Net::MessageIn msg)

Definition at line 142 of file petrecv.cpp.

143 {
144  const std::string name = msg.readString(24, "pet name");
145  msg.readUInt8("rename flag");
146  const int level = msg.readInt16("level");
147  const int hungry = msg.readInt16("hungry");
148  const int intimacy = msg.readInt16("intimacy");
149  const int equip = msg.readInt16("equip"); // look like always int16
150 
151 // Being *const being = PlayerInfo::getPetBeing();
152 // if (being)
153 // being->setLevel(level);
154 
155  PetInfo *const info = PlayerInfo::getPet();
156  if (info == nullptr)
157  return;
158  info->name = name;
159  info->level = level;
160  info->hungry = hungry;
161  info->intimacy = intimacy;
162  info->equip = equip;
163  if (msg.getVersion() >= 20081126)
164  info->race = msg.readInt16("class");
165  else
166  info->race = 0;
167 }

References PlayerInfo::getPet(), Actions::info(), and Actions::msg().