GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/skillhandler.cpp Lines: 0 75 0.0 %
Date: 2019-02-12 Branches: 0 112 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-2019  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
extern int packetVersionMain;
33
extern int packetVersionRe;
34
extern int packetVersionZero;
35
36
namespace EAthena
37
{
38
39
SkillHandler::SkillHandler() :
40
    Ea::SkillHandler()
41
{
42
    skillHandler = this;
43
}
44
45
SkillHandler::~SkillHandler()
46
{
47
    skillHandler = nullptr;
48
}
49
50
void SkillHandler::useBeing(const int id, const int level,
51
                            const BeingId beingId) const
52
{
53
    createOutPacket(CMSG_SKILL_USE_BEING);
54
    outMsg.writeInt16(CAST_S16(level), "skill level");
55
    outMsg.writeInt16(CAST_S16(id), "skill id");
56
    outMsg.writeInt32(toInt(beingId, int), "target id");
57
}
58
59
void SkillHandler::useBeingStart(const int id,
60
                                 const int level,
61
                                 const BeingId beingId) const
62
{
63
    if (packetVersionMain < 20181002 &&
64
        packetVersionRe < 20181002 &&
65
        packetVersionZero < 20181010)
66
    {
67
        return;
68
    }
69
70
    createOutPacket(CMSG_SKILL_USE_BEING_START);
71
    outMsg.writeInt16(CAST_S16(level), "skill level");
72
    outMsg.writeInt16(CAST_S16(id), "skill id");
73
    outMsg.writeInt32(toInt(beingId, int), "target id");
74
}
75
76
void SkillHandler::useStop(const int id) const
77
{
78
    if (packetVersionMain < 20181002 &&
79
        packetVersionRe < 20181002 &&
80
        packetVersionZero < 20181010)
81
    {
82
        return;
83
    }
84
85
    createOutPacket(CMSG_SKILL_USE_BEING_STOP);
86
    outMsg.writeInt16(CAST_S16(id), "skill id");
87
}
88
89
void SkillHandler::usePos(const int id, const int level,
90
                          const int x, const int y) const
91
{
92
    createOutPacket(CMSG_SKILL_USE_POSITION);
93
    if (packetVersion >= 20080827 && packetVersion < 20101124)
94
    {
95
        outMsg.writeInt32(0, "unused");
96
        outMsg.writeInt32(0, "unused");
97
        outMsg.writeInt16(CAST_S16(level), "skill level");
98
        outMsg.writeInt16(0, "unused");
99
        outMsg.writeInt16(CAST_S16(id), "skill id");
100
        outMsg.writeInt16(0, "unused");
101
        outMsg.writeInt16(CAST_S16(x), "x");
102
        outMsg.writeInt16(0, "unused");
103
        outMsg.writeInt8(0, "unused");
104
        outMsg.writeInt16(CAST_S16(y), "y");
105
    }
106
    else
107
    {
108
        outMsg.writeInt16(CAST_S16(level), "skill level");
109
        outMsg.writeInt16(CAST_S16(id), "skill id");
110
        outMsg.writeInt16(CAST_S16(x), "x");
111
        outMsg.writeInt16(CAST_S16(y), "y");
112
/*
113
        // disabled due priority from shuffle packets over normal.
114
        if (packetVersionZero >= 20180131 ||
115
            packetVersion >= 20180207)
116
        {
117
            outMsg.writeInt8(0, "unknown");
118
        }
119
*/
120
    }
121
}
122
123
void SkillHandler::usePos(const int id, const int level,
124
                          const int x, const int y,
125
                          const std::string &text) const
126
{
127
    createOutPacket(CMSG_SKILL_USE_POSITION_MORE);
128
    outMsg.writeInt16(CAST_S16(level), "level");
129
    outMsg.writeInt16(CAST_S16(id), "id");
130
    outMsg.writeInt16(CAST_S16(x), "x");
131
    outMsg.writeInt16(CAST_S16(y), "y");
132
    outMsg.writeString(text, 80, "text");
133
}
134
135
void SkillHandler::useMap(const int id, const std::string &map) const
136
{
137
    createOutPacket(CMSG_SKILL_USE_MAP);
138
    outMsg.writeInt16(CAST_S16(id), "skill id");
139
    outMsg.writeString(map, 16, "map name");
140
}
141
142
void SkillHandler::getAlchemistRanks() const
143
{
144
    if (packetVersion >= 20041108)
145
    {
146
        createOutPacket(CMSG_ALCHEMIST_RANKS);
147
    }
148
}
149
150
void SkillHandler::getBlacksmithRanks() const
151
{
152
    if (packetVersion >= 20041108)
153
    {
154
        createOutPacket(CMSG_BLACKSMITH_RANKS);
155
    }
156
}
157
158
void SkillHandler::getPkRanks() const
159
{
160
    if (packetVersion >= 20050530)
161
    {
162
        createOutPacket(CMSG_PK_RANKS);
163
    }
164
}
165
166
void SkillHandler::getTaekwonRanks() const
167
{
168
    if (packetVersion >= 20050328)
169
    {
170
        createOutPacket(CMSG_TAEKWON_RANKS);
171
    }
172
}
173
174
void SkillHandler::feelSaveOk(const int which) const
175
{
176
    if (packetVersion >= 20050817)
177
    {
178
        createOutPacket(CMSG_SKILL_FEEL_SAVE_OK);
179
        outMsg.writeInt8(CAST_S8(which), "which");
180
        menu = MenuType::Unknown;
181
    }
182
}
183
184
void SkillHandler::lessEffects(const bool isLess) const
185
{
186
    if (packetVersion >= 20041115)
187
    {
188
        createOutPacket(CMSG_PLAYER_LESS_EFFECTS);
189
        outMsg.writeInt32(isLess ? 1 : 0, "state");
190
    }
191
}
192
193
}  // namespace EAthena