GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/skillhandler.cpp Lines: 0 62 0.0 %
Date: 2018-05-24 20:11:55 Branches: 0 94 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
        if (packetVersionZero >= 20180131 ||
81
            packetVersion >= 20180207)
82
        {
83
            outMsg.writeInt8(0, "unknown");
84
        }
85
    }
86
}
87
88
void SkillHandler::usePos(const int id, const int level,
89
                          const int x, const int y,
90
                          const std::string &text) const
91
{
92
    createOutPacket(CMSG_SKILL_USE_POSITION_MORE);
93
    outMsg.writeInt16(CAST_S16(level), "level");
94
    outMsg.writeInt16(CAST_S16(id), "id");
95
    outMsg.writeInt16(CAST_S16(x), "x");
96
    outMsg.writeInt16(CAST_S16(y), "y");
97
    outMsg.writeString(text, 80, "text");
98
}
99
100
void SkillHandler::useMap(const int id, const std::string &map) const
101
{
102
    createOutPacket(CMSG_SKILL_USE_MAP);
103
    outMsg.writeInt16(CAST_S16(id), "skill id");
104
    outMsg.writeString(map, 16, "map name");
105
}
106
107
void SkillHandler::getAlchemistRanks() const
108
{
109
    if (packetVersion >= 20041108)
110
    {
111
        createOutPacket(CMSG_ALCHEMIST_RANKS);
112
    }
113
}
114
115
void SkillHandler::getBlacksmithRanks() const
116
{
117
    if (packetVersion >= 20041108)
118
    {
119
        createOutPacket(CMSG_BLACKSMITH_RANKS);
120
    }
121
}
122
123
void SkillHandler::getPkRanks() const
124
{
125
    if (packetVersion >= 20050530)
126
    {
127
        createOutPacket(CMSG_PK_RANKS);
128
    }
129
}
130
131
void SkillHandler::getTaekwonRanks() const
132
{
133
    if (packetVersion >= 20050328)
134
    {
135
        createOutPacket(CMSG_TAEKWON_RANKS);
136
    }
137
}
138
139
void SkillHandler::feelSaveOk(const int which) const
140
{
141
    if (packetVersion >= 20050817)
142
    {
143
        createOutPacket(CMSG_SKILL_FEEL_SAVE_OK);
144
        outMsg.writeInt8(CAST_S8(which), "which");
145
        menu = MenuType::Unknown;
146
    }
147
}
148
149
void SkillHandler::lessEffects(const bool isLess) const
150
{
151
    if (packetVersion >= 20041115)
152
    {
153
        createOutPacket(CMSG_PLAYER_LESS_EFFECTS);
154
        outMsg.writeInt32(isLess ? 1 : 0, "state");
155
    }
156
}
157
158
}  // namespace EAthena