ManaPlus
itemrecv.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2018 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include "net/eathena/itemrecv.h"
24 
25 #include "actormanager.h"
26 #include "itemcolormanager.h"
27 #include "logger.h"
28 
30 
31 #include "net/messagein.h"
32 
33 #include "debug.h"
34 
35 extern bool packets_zero;
36 
37 namespace EAthena
38 {
39 
41 {
42  const BeingId id = msg.readBeingId("id");
43  const int itemId = msg.readInt16("item id");
44  ItemTypeT itemType = ItemType::Unknown;
45  if (msg.getVersion() >= 20130000)
46  itemType = static_cast<ItemTypeT>(msg.readInt16("type"));
47  const Identified identified = fromInt(
48  msg.readUInt8("identify"), Identified);
49  const int x = msg.readInt16("x");
50  const int y = msg.readInt16("y");
51  const int subX = CAST_S32(msg.readInt8("subx"));
52  const int subY = CAST_S32(msg.readInt8("suby"));
53  const int amount = msg.readInt16("count");
54  if (packets_zero)
55  {
56  msg.readUInt8("show drop effect");
57  msg.readInt16("show effect mode");
58  }
59 
60  if (actorManager != nullptr)
61  {
63  itemId,
64  x, y,
65  itemType,
66  amount,
67  0,
69  identified,
71  subX, subY,
72  nullptr);
73  }
74 }
75 
77 {
78  const BeingId id = msg.readBeingId("id");
79  const int itemId = msg.readInt16("item id");
80  const ItemTypeT itemType = static_cast<ItemTypeT>(msg.readUInt8("type"));
81  const Identified identified = fromInt(
82  msg.readUInt8("identify"), Identified);
83  const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
84  const uint8_t refine = msg.readUInt8("refine");
85  int cards[maxCards];
86  for (int f = 0; f < maxCards; f++)
87  cards[f] = msg.readUInt16("card");
88  const int x = msg.readInt16("x");
89  const int y = msg.readInt16("y");
90  const int amount = msg.readInt16("amount");
91  const int subX = CAST_S32(msg.readInt8("subx"));
92  const int subY = CAST_S32(msg.readInt8("suby"));
93 
94  if (actorManager != nullptr)
95  {
97  itemId,
98  x, y,
99  itemType,
100  amount,
101  refine,
103  identified,
104  damaged,
105  subX, subY,
106  &cards[0]);
107  }
108 }
109 
111 {
113  msg.readInt16("len");
114  msg.readUInt8("type");
115  msg.readInt16("item id");
116  msg.readUInt8("len");
117  msg.readString(24, "name");
118  msg.readUInt8("monster name len");
119  msg.readString(24, "monster name");
120 }
121 
123 {
124  const BeingId id = msg.readBeingId("item object id");
125  const int itemId = msg.readInt16("item id");
126  const Identified identified = fromInt(
127  msg.readUInt8("identify"), Identified);
128  const int x = msg.readInt16("x");
129  const int y = msg.readInt16("y");
130  const int amount = msg.readInt16("amount");
131  const int subX = CAST_S32(msg.readInt8("sub x"));
132  const int subY = CAST_S32(msg.readInt8("sub y"));
133 
134  if (actorManager != nullptr)
135  {
137  itemId,
138  x, y,
140  amount,
141  0,
143  identified,
145  subX, subY,
146  nullptr);
147  }
148 }
149 
151 {
152  const BeingId id = msg.readBeingId("item object id");
153  const int itemId = msg.readInt16("item id");
154  const ItemTypeT itemType = static_cast<ItemTypeT>(
155  msg.readUInt8("type"));
156  const Identified identified = fromInt(
157  msg.readUInt8("identify"), Identified);
158  const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
159  const uint8_t refine = msg.readUInt8("refine");
160  int cards[maxCards];
161  for (int f = 0; f < maxCards; f++)
162  cards[f] = msg.readUInt16("card");
163  const int x = msg.readInt16("x");
164  const int y = msg.readInt16("y");
165  const int amount = msg.readInt16("amount");
166  const int subX = CAST_S32(msg.readInt8("sub x"));
167  const int subY = CAST_S32(msg.readInt8("sub y"));
168 
169  if (actorManager != nullptr)
170  {
172  itemId,
173  x, y,
174  itemType,
175  amount,
176  refine,
178  identified,
179  damaged,
180  subX, subY,
181  &cards[0]);
182  }
183 }
184 
185 } // namespace EAthena
unsigned char readUInt8(const char *const str)
Definition: messagein.cpp:98
static ItemColor getColorFromCards(const int *const cards)
void processItemVisible(Net::MessageIn &msg)
Definition: itemrecv.cpp:122
uint16_t readUInt16(const char *const str)
Definition: messagein.cpp:147
void processItemVisible2(Net::MessageIn &msg)
Definition: itemrecv.cpp:150
BeingId readBeingId(const char *const str)
Definition: messagein.cpp:211
#define fromInt(val, name)
Definition: intdefines.h:45
bool Identified
Definition: identified.h:29
int BeingId
Definition: beingid.h:29
bool msg(InputEvent &event)
Definition: chat.cpp:38
const ItemColor ItemColor_one
Definition: itemcolor.h:29
signed char readInt8(const char *const str)
Definition: messagein.cpp:111
int16_t readInt16(const char *const str)
Definition: messagein.cpp:125
bool packets_zero
Definition: client.cpp:131
#define CAST_S32
Definition: cast.h:29
#define fromBool(val, name)
Definition: booldefines.h:48
FloorItem * createItem(const BeingId id, const int itemId, const int x, const int y, const ItemTypeT itemType, const int amount, const int refine, const ItemColor color, const Identified identified, const Damaged damaged, const int subX, const int subY, const int *const cards)
void processItemDropped(Net::MessageIn &msg)
Definition: itemrecv.cpp:40
unsigned int getVersion() const
Definition: messagein.h:131
ItemType ::T ItemTypeT
Definition: itemtype.h:42
bool Damaged
Definition: damaged.h:29
void processItemDropped2(Net::MessageIn &msg)
Definition: itemrecv.cpp:76
std::string readString(int length, const char *const dstr)
Definition: messagein.cpp:355
#define UNIMPLEMENTEDPACKET
Definition: logger.h:55
const bool Damaged_false
Definition: damaged.h:29
#define maxCards
Definition: cards.h:24
ActorManager * actorManager
void processItemMvpDropped(Net::MessageIn &msg)
Definition: itemrecv.cpp:110