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/tmwa/itemrecv.h" |
25 |
|
|
|
26 |
|
|
#include "actormanager.h" |
27 |
|
|
|
28 |
|
|
#include "net/messagein.h" |
29 |
|
|
|
30 |
|
|
#include "debug.h" |
31 |
|
|
|
32 |
|
|
namespace TmwAthena |
33 |
|
|
{ |
34 |
|
|
|
35 |
|
|
void ItemRecv::processItemDropped(Net::MessageIn &msg) |
36 |
|
|
{ |
37 |
|
|
const BeingId id = msg.readBeingId("item object id"); |
38 |
|
|
const int itemId = msg.readInt16("item id"); |
39 |
|
|
const Identified identify = fromInt(msg.readUInt8("identify"), Identified); |
40 |
|
|
const int x = msg.readInt16("x"); |
41 |
|
|
const int y = msg.readInt16("y"); |
42 |
|
|
const int subX = CAST_S32(msg.readInt8("sub x")); |
43 |
|
|
const int subY = CAST_S32(msg.readInt8("sub y")); |
44 |
|
|
const int amount = msg.readInt16("amount"); |
45 |
|
|
|
46 |
|
|
if (actorManager != nullptr) |
47 |
|
|
{ |
48 |
|
|
actorManager->createItem(id, |
49 |
|
|
itemId, |
50 |
|
|
x, y, |
51 |
|
|
ItemType::Unknown, |
52 |
|
|
amount, |
53 |
|
|
0, |
54 |
|
|
ItemColor_one, |
55 |
|
|
identify, |
56 |
|
|
Damaged_false, |
57 |
|
|
subX, subY, |
58 |
|
|
nullptr); |
59 |
|
|
} |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
void ItemRecv::processItemVisible(Net::MessageIn &msg) |
63 |
|
|
{ |
64 |
|
|
const BeingId id = msg.readBeingId("item object id"); |
65 |
|
|
const int itemId = msg.readInt16("item id"); |
66 |
|
|
const Identified identified = fromInt( |
67 |
|
|
msg.readUInt8("identify"), Identified); |
68 |
|
|
const int x = msg.readInt16("x"); |
69 |
|
|
const int y = msg.readInt16("y"); |
70 |
|
|
const int amount = msg.readInt16("amount"); |
71 |
|
|
const int subX = CAST_S32(msg.readInt8("sub x")); |
72 |
|
|
const int subY = CAST_S32(msg.readInt8("sub y")); |
73 |
|
|
|
74 |
|
|
if (actorManager != nullptr) |
75 |
|
|
{ |
76 |
|
|
actorManager->createItem(id, |
77 |
|
|
itemId, |
78 |
|
|
x, y, |
79 |
|
|
ItemType::Unknown, |
80 |
|
|
amount, |
81 |
|
|
0, |
82 |
|
|
ItemColor_one, |
83 |
|
|
identified, |
84 |
|
|
Damaged_false, |
85 |
|
|
subX, subY, |
86 |
|
|
nullptr); |
87 |
|
|
} |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
} // namespace TmwAthena |