GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/skillhandler.cpp Lines: 0 59 0.0 %
Date: 2017-11-29 Branches: 0 88 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/skillhandler.h"
24
25
#include "net/eathena/menu.h"
26
#include "net/eathena/messageout.h"
27
#include "net/eathena/protocolout.h"
28
29
#include "debug.h"
30
31
extern int packetVersion;
32
33
namespace EAthena
34
{
35
36
SkillHandler::SkillHandler() :
37
    Ea::SkillHandler()
38
{
39
    skillHandler = this;
40
}
41
42
SkillHandler::~SkillHandler()
43
{
44
    skillHandler = nullptr;
45
}
46
47
void SkillHandler::useBeing(const int id, const int level,
48
                            const BeingId beingId) const
49
{
50
    createOutPacket(CMSG_SKILL_USE_BEING);
51
    outMsg.writeInt16(CAST_S16(level), "skill level");
52
    outMsg.writeInt16(CAST_S16(id), "skill id");
53
    outMsg.writeInt32(toInt(beingId, int), "target id");
54
}
55
56
void SkillHandler::usePos(const int id, const int level,
57
                          const int x, const int y) const
58
{
59
    createOutPacket(CMSG_SKILL_USE_POSITION);
60
    if (packetVersion >= 20080827 && packetVersion < 20101124)
61
    {
62
        outMsg.writeInt32(0, "unused");
63
        outMsg.writeInt32(0, "unused");
64
        outMsg.writeInt16(CAST_S16(level), "skill level");
65
        outMsg.writeInt16(0, "unused");
66
        outMsg.writeInt16(CAST_S16(id), "skill id");
67
        outMsg.writeInt16(0, "unused");
68
        outMsg.writeInt16(CAST_S16(x), "x");
69
        outMsg.writeInt16(0, "unused");
70
        outMsg.writeInt8(0, "unused");
71
        outMsg.writeInt16(CAST_S16(y), "y");
72
    }
73
    else
74
    {
75
        outMsg.writeInt16(CAST_S16(level), "skill level");
76
        outMsg.writeInt16(CAST_S16(id), "skill id");
77
        outMsg.writeInt16(CAST_S16(x), "x");
78
        outMsg.writeInt16(CAST_S16(y), "y");
79
    }
80
}
81
82
void SkillHandler::usePos(const int id, const int level,
83
                          const int x, const int y,
84
                          const std::string &text) const
85
{
86
    createOutPacket(CMSG_SKILL_USE_POSITION_MORE);
87
    outMsg.writeInt16(CAST_S16(level), "level");
88
    outMsg.writeInt16(CAST_S16(id), "id");
89
    outMsg.writeInt16(CAST_S16(x), "x");
90
    outMsg.writeInt16(CAST_S16(y), "y");
91
    outMsg.writeString(text, 80, "text");
92
}
93
94
void SkillHandler::useMap(const int id, const std::string &map) const
95
{
96
    createOutPacket(CMSG_SKILL_USE_MAP);
97
    outMsg.writeInt16(CAST_S16(id), "skill id");
98
    outMsg.writeString(map, 16, "map name");
99
}
100
101
void SkillHandler::getAlchemistRanks() const
102
{
103
    if (packetVersion >= 20041108)
104
    {
105
        createOutPacket(CMSG_ALCHEMIST_RANKS);
106
    }
107
}
108
109
void SkillHandler::getBlacksmithRanks() const
110
{
111
    if (packetVersion >= 20041108)
112
    {
113
        createOutPacket(CMSG_BLACKSMITH_RANKS);
114
    }
115
}
116
117
void SkillHandler::getPkRanks() const
118
{
119
    if (packetVersion >= 20050530)
120
    {
121
        createOutPacket(CMSG_PK_RANKS);
122
    }
123
}
124
125
void SkillHandler::getTaekwonRanks() const
126
{
127
    if (packetVersion >= 20050328)
128
    {
129
        createOutPacket(CMSG_TAEKWON_RANKS);
130
    }
131
}
132
133
void SkillHandler::feelSaveOk(const int which) const
134
{
135
    if (packetVersion >= 20050817)
136
    {
137
        createOutPacket(CMSG_SKILL_FEEL_SAVE_OK);
138
        outMsg.writeInt8(CAST_S8(which), "which");
139
        menu = MenuType::Unknown;
140
    }
141
}
142
143
void SkillHandler::lessEffects(const bool isLess) const
144
{
145
    if (packetVersion >= 20041115)
146
    {
147
        createOutPacket(CMSG_PLAYER_LESS_EFFECTS);
148
        outMsg.writeInt32(isLess ? 1 : 0, "state");
149
    }
150
}
151
152
}  // namespace EAthena