GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/itemrecv.cpp Lines: 0 66 0.0 %
Date: 2017-11-29 Branches: 0 18 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/eathena/itemrecv.h"
24
25
#include "actormanager.h"
26
#include "itemcolormanager.h"
27
#include "logger.h"
28
29
#include "const/resources/item/cards.h"
30
31
#include "net/messagein.h"
32
33
#include "debug.h"
34
35
namespace EAthena
36
{
37
38
void ItemRecv::processItemDropped(Net::MessageIn &msg)
39
{
40
    const BeingId id = msg.readBeingId("id");
41
    const int itemId = msg.readInt16("item id");
42
    ItemTypeT itemType = ItemType::Unknown;
43
    if (msg.getVersion() >= 20130000)
44
        itemType = static_cast<ItemTypeT>(msg.readInt16("type"));
45
    const Identified identified = fromInt(
46
        msg.readUInt8("identify"), Identified);
47
    const int x = msg.readInt16("x");
48
    const int y = msg.readInt16("y");
49
    const int subX = CAST_S32(msg.readInt8("subx"));
50
    const int subY = CAST_S32(msg.readInt8("suby"));
51
    const int amount = msg.readInt16("count");
52
53
    if (actorManager != nullptr)
54
    {
55
        actorManager->createItem(id,
56
            itemId,
57
            x, y,
58
            itemType,
59
            amount,
60
            0,
61
            ItemColor_one,
62
            identified,
63
            Damaged_false,
64
            subX, subY,
65
            nullptr);
66
    }
67
}
68
69
void ItemRecv::processItemDropped2(Net::MessageIn &msg)
70
{
71
    const BeingId id = msg.readBeingId("id");
72
    const int itemId = msg.readInt16("item id");
73
    const ItemTypeT itemType = static_cast<ItemTypeT>(msg.readUInt8("type"));
74
    const Identified identified = fromInt(
75
        msg.readUInt8("identify"), Identified);
76
    const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
77
    const uint8_t refine = msg.readUInt8("refine");
78
    int cards[maxCards];
79
    for (int f = 0; f < maxCards; f++)
80
        cards[f] = msg.readUInt16("card");
81
    const int x = msg.readInt16("x");
82
    const int y = msg.readInt16("y");
83
    const int amount = msg.readInt16("amount");
84
    const int subX = CAST_S32(msg.readInt8("subx"));
85
    const int subY = CAST_S32(msg.readInt8("suby"));
86
87
    if (actorManager != nullptr)
88
    {
89
        actorManager->createItem(id,
90
            itemId,
91
            x, y,
92
            itemType,
93
            amount,
94
            refine,
95
            ItemColorManager::getColorFromCards(&cards[0]),
96
            identified,
97
            damaged,
98
            subX, subY,
99
            &cards[0]);
100
    }
101
}
102
103
void ItemRecv::processItemMvpDropped(Net::MessageIn &msg)
104
{
105
    UNIMPLEMENTEDPACKET;
106
    msg.readInt16("len");
107
    msg.readUInt8("type");
108
    msg.readInt16("item id");
109
    msg.readUInt8("len");
110
    msg.readString(24, "name");
111
    msg.readUInt8("monster name len");
112
    msg.readString(24, "monster name");
113
}
114
115
void ItemRecv::processItemVisible(Net::MessageIn &msg)
116
{
117
    const BeingId id = msg.readBeingId("item object id");
118
    const int itemId = msg.readInt16("item id");
119
    const Identified identified = fromInt(
120
        msg.readUInt8("identify"), Identified);
121
    const int x = msg.readInt16("x");
122
    const int y = msg.readInt16("y");
123
    const int amount = msg.readInt16("amount");
124
    const int subX = CAST_S32(msg.readInt8("sub x"));
125
    const int subY = CAST_S32(msg.readInt8("sub y"));
126
127
    if (actorManager != nullptr)
128
    {
129
        actorManager->createItem(id,
130
            itemId,
131
            x, y,
132
            ItemType::Unknown,
133
            amount,
134
            0,
135
            ItemColor_one,
136
            identified,
137
            Damaged_false,
138
            subX, subY,
139
            nullptr);
140
    }
141
}
142
143
void ItemRecv::processItemVisible2(Net::MessageIn &msg)
144
{
145
    const BeingId id = msg.readBeingId("item object id");
146
    const int itemId = msg.readInt16("item id");
147
    const ItemTypeT itemType = static_cast<ItemTypeT>(
148
        msg.readUInt8("type"));
149
    const Identified identified = fromInt(
150
        msg.readUInt8("identify"), Identified);
151
    const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
152
    const uint8_t refine = msg.readUInt8("refine");
153
    int cards[maxCards];
154
    for (int f = 0; f < maxCards; f++)
155
        cards[f] = msg.readUInt16("card");
156
    const int x = msg.readInt16("x");
157
    const int y = msg.readInt16("y");
158
    const int amount = msg.readInt16("amount");
159
    const int subX = CAST_S32(msg.readInt8("sub x"));
160
    const int subY = CAST_S32(msg.readInt8("sub y"));
161
162
    if (actorManager != nullptr)
163
    {
164
        actorManager->createItem(id,
165
            itemId,
166
            x, y,
167
            itemType,
168
            amount,
169
            refine,
170
            ItemColorManager::getColorFromCards(&cards[0]),
171
            identified,
172
            damaged,
173
            subX, subY,
174
            &cards[0]);
175
    }
176
}
177
178
}  // namespace EAthena