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