GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/beinghandler.cpp Lines: 1 45 2.2 %
Date: 2017-11-29 Branches: 0 34 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/beinghandler.h"
24
25
#include "net/eathena/messageout.h"
26
#include "net/eathena/protocolout.h"
27
#include "net/eathena/sprite.h"
28
29
#include "debug.h"
30
31
extern int packetVersion;
32
extern int serverVersion;
33
34
namespace EAthena
35
{
36
37
BeingHandler::BeingHandler(const bool enableSync) :
38
    Ea::BeingHandler(enableSync)
39
{
40
    beingHandler = this;
41
}
42
43
BeingHandler::~BeingHandler()
44
{
45
    beingHandler = nullptr;
46
}
47
48
void BeingHandler::requestNameById(const BeingId id) const
49
{
50
    createOutPacket(CMSG_NAME_REQUEST);
51
    if (packetVersion >= 20080827 && packetVersion < 20101124)
52
    {
53
        outMsg.writeInt32(0, "unused");
54
        outMsg.writeInt32(0, "unused");
55
    }
56
    outMsg.writeBeingId(id, "being id");
57
}
58
59
void BeingHandler::undress(Being *const being) const
60
{
61
    if (being == nullptr)
62
        return;
63
    being->unSetSprite(SPRITE_WEAPON);
64
    being->unSetSprite(SPRITE_HEAD_BOTTOM);
65
    being->unSetSprite(SPRITE_HEAD_TOP);
66
    being->unSetSprite(SPRITE_HEAD_MID);
67
    being->unSetSprite(SPRITE_CLOTHES_COLOR);
68
    being->unSetSprite(SPRITE_SHIELD);
69
    being->unSetSprite(SPRITE_FLOOR);
70
    being->unSetSprite(SPRITE_ROBE);
71
    being->unSetSprite(SPRITE_EVOL2);
72
    being->unSetSprite(SPRITE_EVOL3);
73
    being->unSetSprite(SPRITE_EVOL4);
74
    being->unSetSprite(SPRITE_EVOL5);
75
    being->unSetSprite(SPRITE_EVOL6);
76
    being->unSetSprite(SPRITE_HAIR);
77
    being->unSetSprite(SPRITE_SHOES);
78
}
79
80
void BeingHandler::requestRanks(const RankT rank) const
81
{
82
    if (packetVersion < 20130605)
83
        return;
84
85
    createOutPacket(CMSG_REQUEST_RANKS);
86
    outMsg.writeInt16(CAST_S16(rank), "type");
87
}
88
89
void BeingHandler::viewPlayerEquipment(const Being *const being) const
90
{
91
    if (being == nullptr)
92
        return;
93
94
    createOutPacket(CMSG_PLAYER_VIEW_EQUIPMENT);
95
    outMsg.writeBeingId(being->getId(), "account id");
96
}
97
98
void BeingHandler::requestNameByCharId(const int id) const
99
{
100
    createOutPacket(CMSG_SOLVE_CHAR_NAME);
101
    if (packetVersion >= 20080827 && packetVersion < 20101124)
102
    {
103
        outMsg.writeInt32(9, "unused");
104
        outMsg.writeInt32(9, "unused");
105
    }
106
    outMsg.writeInt32(id, "character id");
107
}
108
109
4
}  // namespace EAthena