GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/eathena/adminhandler.cpp Lines: 2 153 1.3 %
Date: 2017-11-29 Branches: 2 252 0.8 %

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/adminhandler.h"
24
25
#include "being/being.h"
26
27
#include "net/eathena/messageout.h"
28
#include "net/eathena/protocolout.h"
29
30
#include "utils/gmfunctions.h"
31
#include "utils/stringutils.h"
32
33
#include "debug.h"
34
35
namespace EAthena
36
{
37
38
2
std::string AdminHandler::mStatsName;
39
40
AdminHandler::AdminHandler() :
41
    Ea::AdminHandler()
42
{
43
    adminHandler = this;
44
}
45
46
AdminHandler::~AdminHandler()
47
{
48
    adminHandler = nullptr;
49
}
50
51
void AdminHandler::announce(const std::string &text) const
52
{
53
    createOutPacket(CMSG_ADMIN_ANNOUNCE);
54
    outMsg.writeInt16(CAST_S16(text.length() + 4), "len");
55
    outMsg.writeString(text, CAST_S32(text.length()), "message");
56
}
57
58
void AdminHandler::localAnnounce(const std::string &text) const
59
{
60
    createOutPacket(CMSG_ADMIN_LOCAL_ANNOUNCE);
61
    outMsg.writeInt16(CAST_S16(text.length() + 4), "len");
62
    outMsg.writeString(text, CAST_S32(text.length()), "message");
63
}
64
65
void AdminHandler::hide(const bool h A_UNUSED) const
66
{
67
    createOutPacket(CMSG_ADMIN_HIDE);
68
    outMsg.writeInt32(0, "unused");
69
}
70
71
void AdminHandler::kick(const BeingId playerId) const
72
{
73
    createOutPacket(CMSG_ADMIN_KICK);
74
    outMsg.writeBeingId(playerId, "account id");
75
}
76
77
void AdminHandler::kickAll() const
78
{
79
    createOutPacket(CMSG_ADMIN_KICK_ALL);
80
}
81
82
void AdminHandler::warp(const std::string &map, const int x, const int y) const
83
{
84
    createOutPacket(CMSG_PLAYER_MAPMOVE);
85
    outMsg.writeString(map, 16, "map");
86
    outMsg.writeInt16(CAST_S16(x), "x");
87
    outMsg.writeInt16(CAST_S16(y), "y");
88
}
89
90
void AdminHandler::resetStats() const
91
{
92
    createOutPacket(CMSG_ADMIN_RESET_PLAYER);
93
    outMsg.writeInt16(0, "flag");
94
}
95
96
void AdminHandler::resetSkills() const
97
{
98
    createOutPacket(CMSG_ADMIN_RESET_PLAYER);
99
    outMsg.writeInt16(1, "flag");
100
}
101
102
void AdminHandler::gotoName(const std::string &name) const
103
{
104
    createOutPacket(CMSG_ADMIN_GOTO);
105
    outMsg.writeString(name, 24, "name");
106
}
107
108
void AdminHandler::recallName(const std::string &name) const
109
{
110
    createOutPacket(CMSG_ADMIN_RECALL);
111
    outMsg.writeString(name, 24, "name");
112
}
113
114
void AdminHandler::mute(const Being *const being,
115
                        const int type,
116
                        const int limit) const
117
{
118
    if (being == nullptr)
119
        return;
120
121
    createOutPacket(CMSG_ADMIN_MUTE);
122
    outMsg.writeBeingId(being->getId(), "account id");
123
    outMsg.writeInt8(CAST_S8(type), "type");
124
    outMsg.writeInt16(CAST_S16(limit), "value");
125
}
126
127
void AdminHandler::muteName(const std::string &name) const
128
{
129
    createOutPacket(CMSG_ADMIN_MUTE_NAME);
130
    outMsg.writeString(name, 24, "name");
131
}
132
133
void AdminHandler::requestLogin(const Being *const being) const
134
{
135
    if (being == nullptr)
136
        return;
137
138
    createOutPacket(CMSG_ADMIN_ID_TO_LOGIN);
139
    outMsg.writeBeingId(being->getId(), "account id");
140
}
141
142
void AdminHandler::setTileType(const int x, const int y,
143
                               const int type) const
144
{
145
    createOutPacket(CMSG_ADMIN_SET_TILE_TYPE);
146
    outMsg.writeInt16(CAST_S16(x), "x");
147
    outMsg.writeInt16(CAST_S16(y), "y");
148
    outMsg.writeInt16(CAST_S16(type), "type");
149
}
150
151
void AdminHandler::unequipAll(const Being *const being) const
152
{
153
    if (being == nullptr)
154
        return;
155
156
    createOutPacket(CMSG_ADMIN_UNEQUIP_ALL);
157
    outMsg.writeBeingId(being->getId(), "account id");
158
}
159
160
void AdminHandler::requestStats(const std::string &name) const
161
{
162
    mStatsName = name;
163
    createOutPacket(CMSG_ADMIN_REQUEST_STATS);
164
    outMsg.writeString(name, 24, "name");
165
}
166
167
void AdminHandler::monsterInfo(const std::string &name) const
168
{
169
    Gm::runCommand("monsterinfo", name);
170
}
171
172
void AdminHandler::itemInfo(const std::string &name) const
173
{
174
    Gm::runCommand("iteminfo", name);
175
}
176
177
void AdminHandler::whoDrops(const std::string &name) const
178
{
179
    Gm::runCommand("whodrops", name);
180
}
181
182
void AdminHandler::mobSearch(const std::string &name) const
183
{
184
    Gm::runCommand("mobsearch", name);
185
}
186
187
void AdminHandler::mobSpawnSearch(const std::string &name) const
188
{
189
    Gm::runCommand("whereis", name);
190
}
191
192
void AdminHandler::playerGmCommands(const std::string &name) const
193
{
194
    Gm::runCharCommand("commands", name);
195
}
196
197
void AdminHandler::playerCharGmCommands(const std::string &name) const
198
{
199
    Gm::runCharCommand("charcommands", name);
200
}
201
202
void AdminHandler::showLevel(const std::string &name) const
203
{
204
    Gm::runCharCommand("exp", name);
205
}
206
207
void AdminHandler::showStats(const std::string &name) const
208
{
209
    Gm::runCharCommand("stats", name);
210
}
211
212
void AdminHandler::showStorageList(const std::string &name) const
213
{
214
    Gm::runCharCommand("storagelist", name);
215
}
216
217
void AdminHandler::showCartList(const std::string &name) const
218
{
219
    Gm::runCharCommand("cartlist", name);
220
}
221
222
void AdminHandler::showInventoryList(const std::string &name) const
223
{
224
    Gm::runCharCommand("itemlist", name);
225
}
226
227
void AdminHandler::locatePlayer(const std::string &name) const
228
{
229
    Gm::runCommand("where", name);
230
}
231
232
void AdminHandler::showAccountInfo(const std::string &name) const
233
{
234
    Gm::runCommand("accinfo", name);
235
}
236
237
void AdminHandler::spawnSlave(const std::string &name) const
238
{
239
    Gm::runCommand("summon", name);
240
}
241
242
void AdminHandler::spawnClone(const std::string &name) const
243
{
244
    Gm::runCommand("clone", name);
245
}
246
247
void AdminHandler::spawnSlaveClone(const std::string &name) const
248
{
249
    Gm::runCommand("slaveclone", name);
250
}
251
252
void AdminHandler::spawnEvilClone(const std::string &name) const
253
{
254
    Gm::runCommand("evilclone", name);
255
}
256
257
void AdminHandler::savePosition(const std::string &name) const
258
{
259
    Gm::runCharCommand("save", name);
260
}
261
262
void AdminHandler::loadPosition(const std::string &name) const
263
{
264
    Gm::runCharCommand("load", name);
265
}
266
267
void AdminHandler::randomWarp(const std::string &name) const
268
{
269
    Gm::runCharCommand("jump", name);
270
}
271
272
void AdminHandler::gotoNpc(const std::string &name) const
273
{
274
    Gm::runCommand("tonpc", name);
275
}
276
277
void AdminHandler::killer(const std::string &name) const
278
{
279
    Gm::runCharCommand("killer", name);
280
}
281
282
void AdminHandler::killable(const std::string &name) const
283
{
284
    Gm::runCharCommand("killable", name);
285
}
286
287
void AdminHandler::heal(const std::string &name) const
288
{
289
    Gm::runCharCommand("heal", name);
290
}
291
292
void AdminHandler::alive(const std::string &name) const
293
{
294
    Gm::runCharCommand("alive", name);
295
}
296
297
void AdminHandler::disguise(const std::string &name) const
298
{
299
    Gm::runCommand("disguise", name);
300
}
301
302
void AdminHandler::immortal(const std::string &name) const
303
{
304
    Gm::runCharCommand("monsterignore", name);
305
}
306
307
void AdminHandler::hide(const std::string &name) const
308
{
309
    Gm::runCharCommand("hide", name);
310
}
311
312
void AdminHandler::nuke(const std::string &name) const
313
{
314
    Gm::runCommand("nuke", name);
315
}
316
317
void AdminHandler::kill(const std::string &name) const
318
{
319
    Gm::runCharCommand("kill", name);
320
}
321
322
void AdminHandler::jail(const std::string &name) const
323
{
324
    Gm::runCommand("jail", name);
325
}
326
327
void AdminHandler::unjail(const std::string &name) const
328
{
329
    Gm::runCommand("unjail", name);
330
}
331
332
void AdminHandler::npcMove(const std::string &name,
333
                           const int x,
334
                           const int y) const
335
{
336
    Gm::runCommand("npcmove",
337
        strprintf("%d %d %s",
338
        x,
339
        y,
340
        name.c_str()));
341
}
342
343
void AdminHandler::hideNpc(const std::string &name) const
344
{
345
    Gm::runCommand("hidenpc", name);
346
}
347
348
void AdminHandler::showNpc(const std::string &name) const
349
{
350
    Gm::runCommand("shownpc", name);
351
}
352
353
void AdminHandler::changePartyLeader(const std::string &name) const
354
{
355
    Gm::runCommand("changeleader", name);
356
}
357
358
void AdminHandler::partyRecall(const std::string &name) const
359
{
360
    Gm::runCommand("partyrecall", name);
361
}
362
363
void AdminHandler::breakGuild(const std::string &name) const
364
{
365
    Gm::runCharCommand("breakguild", name);
366
}
367
368
void AdminHandler::guildRecall(const std::string &name) const
369
{
370
    Gm::runCommand("guildrecall", name);
371
}
372
373
void AdminHandler::slide(const int x, const int y) const
374
{
375
    Gm::runCommand("slide",
376
        strprintf("%d %d", x, y));
377
}
378
379

6
}  // namespace EAthena