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