GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/tmwa/itemrecv.cpp Lines: 0 22 0.0 %
Date: 2017-11-29 Branches: 0 4 0.0 %

Line Branch Exec Source
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-2017  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
34
void ItemRecv::processItemDropped(Net::MessageIn &msg)
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
    {
47
        actorManager->createItem(id,
48
            itemId,
49
            x, y,
50
            ItemType::Unknown,
51
            amount,
52
            0,
53
            ItemColor_one,
54
            identify,
55
            Damaged_false,
56
            subX, subY,
57
            nullptr);
58
    }
59
}
60
61
void ItemRecv::processItemVisible(Net::MessageIn &msg)
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
    {
75
        actorManager->createItem(id,
76
            itemId,
77
            x, y,
78
            ItemType::Unknown,
79
            amount,
80
            0,
81
            ItemColor_one,
82
            identified,
83
            Damaged_false,
84
            subX, subY,
85
            nullptr);
86
    }
87
}
88
89
}  // namespace TmwAthena