GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/skillhandler.cpp Lines: 0 75 0.0 %
Date: 2021-03-17 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
 *  Copyright (C) 2019-2021  Andrei Karas
7
 *
8
 *  This file is part of The ManaPlus Client.
9
 *
10
 *  This program is free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  any later version.
14
 *
15
 *  This program is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU General Public License for more details.
19
 *
20
 *  You should have received a copy of the GNU General Public License
21
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
24
#include "net/eathena/skillhandler.h"
25
26
#include "net/eathena/menu.h"
27
#include "net/eathena/messageout.h"
28
#include "net/eathena/protocolout.h"
29
30
#include "debug.h"
31
32
extern int packetVersion;
33
extern int packetVersionMain;
34
extern int packetVersionRe;
35
extern int packetVersionZero;
36
37
namespace EAthena
38
{
39
40
SkillHandler::SkillHandler() :
41
    Ea::SkillHandler()
42
{
43
    skillHandler = this;
44
}
45
46
SkillHandler::~SkillHandler()
47
{
48
    skillHandler = nullptr;
49
}
50
51
void SkillHandler::useBeing(const int id, const int level,
52
                            const BeingId beingId) const
53
{
54
    createOutPacket(CMSG_SKILL_USE_BEING);
55
    outMsg.writeInt16(CAST_S16(level), "skill level");
56
    outMsg.writeInt16(CAST_S16(id), "skill id");
57
    outMsg.writeInt32(toInt(beingId, int), "target id");
58
}
59
60
void SkillHandler::useBeingStart(const int id,
61
                                 const int level,
62
                                 const BeingId beingId) const
63
{
64
    if (packetVersionMain < 20181002 &&
65
        packetVersionRe < 20181002 &&
66
        packetVersionZero < 20181010)
67
    {
68
        return;
69
    }
70
71
    createOutPacket(CMSG_SKILL_USE_BEING_START);
72
    outMsg.writeInt16(CAST_S16(level), "skill level");
73
    outMsg.writeInt16(CAST_S16(id), "skill id");
74
    outMsg.writeInt32(toInt(beingId, int), "target id");
75
}
76
77
void SkillHandler::useStop(const int id) const
78
{
79
    if (packetVersionMain < 20181002 &&
80
        packetVersionRe < 20181002 &&
81
        packetVersionZero < 20181010)
82
    {
83
        return;
84
    }
85
86
    createOutPacket(CMSG_SKILL_USE_BEING_STOP);
87
    outMsg.writeInt16(CAST_S16(id), "skill id");
88
}
89
90
void SkillHandler::usePos(const int id, const int level,
91
                          const int x, const int y) const
92
{
93
    createOutPacket(CMSG_SKILL_USE_POSITION);
94
    if (packetVersion >= 20080827 && packetVersion < 20101124)
95
    {
96
        outMsg.writeInt32(0, "unused");
97
        outMsg.writeInt32(0, "unused");
98
        outMsg.writeInt16(CAST_S16(level), "skill level");
99
        outMsg.writeInt16(0, "unused");
100
        outMsg.writeInt16(CAST_S16(id), "skill id");
101
        outMsg.writeInt16(0, "unused");
102
        outMsg.writeInt16(CAST_S16(x), "x");
103
        outMsg.writeInt16(0, "unused");
104
        outMsg.writeInt8(0, "unused");
105
        outMsg.writeInt16(CAST_S16(y), "y");
106
    }
107
    else
108
    {
109
        outMsg.writeInt16(CAST_S16(level), "skill level");
110
        outMsg.writeInt16(CAST_S16(id), "skill id");
111
        outMsg.writeInt16(CAST_S16(x), "x");
112
        outMsg.writeInt16(CAST_S16(y), "y");
113
/*
114
        // disabled due priority from shuffle packets over normal.
115
        if (packetVersionZero >= 20180131 ||
116
            packetVersion >= 20180207)
117
        {
118
            outMsg.writeInt8(0, "unknown");
119
        }
120
*/
121
    }
122
}
123
124
void SkillHandler::usePos(const int id, const int level,
125
                          const int x, const int y,
126
                          const std::string &text) const
127
{
128
    createOutPacket(CMSG_SKILL_USE_POSITION_MORE);
129
    outMsg.writeInt16(CAST_S16(level), "level");
130
    outMsg.writeInt16(CAST_S16(id), "id");
131
    outMsg.writeInt16(CAST_S16(x), "x");
132
    outMsg.writeInt16(CAST_S16(y), "y");
133
    outMsg.writeString(text, 80, "text");
134
}
135
136
void SkillHandler::useMap(const int id, const std::string &map) const
137
{
138
    createOutPacket(CMSG_SKILL_USE_MAP);
139
    outMsg.writeInt16(CAST_S16(id), "skill id");
140
    outMsg.writeString(map, 16, "map name");
141
}
142
143
void SkillHandler::getAlchemistRanks() const
144
{
145
    if (packetVersion >= 20041108)
146
    {
147
        createOutPacket(CMSG_ALCHEMIST_RANKS);
148
    }
149
}
150
151
void SkillHandler::getBlacksmithRanks() const
152
{
153
    if (packetVersion >= 20041108)
154
    {
155
        createOutPacket(CMSG_BLACKSMITH_RANKS);
156
    }
157
}
158
159
void SkillHandler::getPkRanks() const
160
{
161
    if (packetVersion >= 20050530)
162
    {
163
        createOutPacket(CMSG_PK_RANKS);
164
    }
165
}
166
167
void SkillHandler::getTaekwonRanks() const
168
{
169
    if (packetVersion >= 20050328)
170
    {
171
        createOutPacket(CMSG_TAEKWON_RANKS);
172
    }
173
}
174
175
void SkillHandler::feelSaveOk(const int which) const
176
{
177
    if (packetVersion >= 20050817)
178
    {
179
        createOutPacket(CMSG_SKILL_FEEL_SAVE_OK);
180
        outMsg.writeInt8(CAST_S8(which), "which");
181
        menu = MenuType::Unknown;
182
    }
183
}
184
185
void SkillHandler::lessEffects(const bool isLess) const
186
{
187
    if (packetVersion >= 20041115)
188
    {
189
        createOutPacket(CMSG_PLAYER_LESS_EFFECTS);
190
        outMsg.writeInt32(isLess ? 1 : 0, "state");
191
    }
192
}
193
194
}  // namespace EAthena