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/tmwa/itemrecv.h"
24 
25 #include "actormanager.h"
26 
27 #include "net/messagein.h"
28 
29 #include "debug.h"
30 
31 namespace TmwAthena
32 {
33 
35 {
36  const BeingId id = msg.readBeingId("item object id");
37  const int itemId = msg.readInt16("item id");
38  const Identified identify = fromInt(msg.readUInt8("identify"), Identified);
39  const int x = msg.readInt16("x");
40  const int y = msg.readInt16("y");
41  const int subX = CAST_S32(msg.readInt8("sub x"));
42  const int subY = CAST_S32(msg.readInt8("sub y"));
43  const int amount = msg.readInt16("amount");
44 
45  if (actorManager != nullptr)
46  {
48  itemId,
49  x, y,
51  amount,
52  0,
54  identify,
56  subX, subY,
57  nullptr);
58  }
59 }
60 
62 {
63  const BeingId id = msg.readBeingId("item object id");
64  const int itemId = msg.readInt16("item id");
65  const Identified identified = fromInt(
66  msg.readUInt8("identify"), Identified);
67  const int x = msg.readInt16("x");
68  const int y = msg.readInt16("y");
69  const int amount = msg.readInt16("amount");
70  const int subX = CAST_S32(msg.readInt8("sub x"));
71  const int subY = CAST_S32(msg.readInt8("sub y"));
72 
73  if (actorManager != nullptr)
74  {
76  itemId,
77  x, y,
79  amount,
80  0,
82  identified,
84  subX, subY,
85  nullptr);
86  }
87 }
88 
89 } // namespace TmwAthena
void processItemDropped(Net::MessageIn &msg)
Definition: itemrecv.cpp:34
unsigned char readUInt8(const char *const str)
Definition: messagein.cpp:103
void processItemVisible(Net::MessageIn &msg)
Definition: itemrecv.cpp:61
BeingId readBeingId(const char *const str)
Definition: messagein.cpp:223
#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:116
int16_t readInt16(const char *const str)
Definition: messagein.cpp:130
#define CAST_S32
Definition: cast.h:29
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)
const bool Damaged_false
Definition: damaged.h:29
ActorManager * actorManager