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 |
|
|
|
30 |
|
|
#include "const/resources/item/cards.h" |
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 |
|
|
|
42 |
|
|
void ItemRecv::processItemDropped(Net::MessageIn &msg) |
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 |
|
|
{ |
64 |
|
|
actorManager->createItem(id, |
65 |
|
|
itemId, |
66 |
|
|
x, y, |
67 |
|
|
itemType, |
68 |
|
|
amount, |
69 |
|
|
0, |
70 |
|
|
ItemColor_one, |
71 |
|
|
identified, |
72 |
|
|
Damaged_false, |
73 |
|
|
subX, subY, |
74 |
|
|
nullptr); |
75 |
|
|
} |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
void ItemRecv::processItemDropped2(Net::MessageIn &msg) |
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 |
|
|
{ |
99 |
|
|
actorManager->createItem(id, |
100 |
|
|
itemId, |
101 |
|
|
x, y, |
102 |
|
|
itemType, |
103 |
|
|
amount, |
104 |
|
|
refine, |
105 |
|
|
ItemColorManager::getColorFromCards(&cards[0]), |
106 |
|
|
identified, |
107 |
|
|
damaged, |
108 |
|
|
subX, subY, |
109 |
|
|
&cards[0]); |
110 |
|
|
} |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
void ItemRecv::processItemMvpDropped(Net::MessageIn &msg) |
114 |
|
|
{ |
115 |
|
|
UNIMPLEMENTEDPACKET; |
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 |
|
|
|
125 |
|
|
void ItemRecv::processItemVisible(Net::MessageIn &msg) |
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 |
|
|
{ |
139 |
|
|
actorManager->createItem(id, |
140 |
|
|
itemId, |
141 |
|
|
x, y, |
142 |
|
|
ItemType::Unknown, |
143 |
|
|
amount, |
144 |
|
|
0, |
145 |
|
|
ItemColor_one, |
146 |
|
|
identified, |
147 |
|
|
Damaged_false, |
148 |
|
|
subX, subY, |
149 |
|
|
nullptr); |
150 |
|
|
} |
151 |
|
|
} |
152 |
|
|
|
153 |
|
|
void ItemRecv::processItemVisible2(Net::MessageIn &msg) |
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 |
|
|
{ |
174 |
|
|
actorManager->createItem(id, |
175 |
|
|
itemId, |
176 |
|
|
x, y, |
177 |
|
|
itemType, |
178 |
|
|
amount, |
179 |
|
|
refine, |
180 |
|
|
ItemColorManager::getColorFromCards(&cards[0]), |
181 |
|
|
identified, |
182 |
|
|
damaged, |
183 |
|
|
subX, subY, |
184 |
|
|
&cards[0]); |
185 |
|
|
} |
186 |
|
|
} |
187 |
|
|
|
188 |
|
|
} // namespace EAthena |