ManaPlus
adminhandler.cpp
Go to the documentation of this file.
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 
24 
25 #include "being/being.h"
26 
27 #include "net/eathena/messageout.h"
29 
30 #include "utils/gmfunctions.h"
31 #include "utils/stringutils.h"
32 
33 #include "debug.h"
34 
35 namespace EAthena
36 {
37 
38 std::string AdminHandler::mStatsName;
39 
41  Ea::AdminHandler()
42 {
43  adminHandler = this;
44 }
45 
47 {
48  adminHandler = nullptr;
49 }
50 
51 void AdminHandler::announce(const std::string &text) const
52 {
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 {
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 {
68  outMsg.writeInt32(0, "unused");
69 }
70 
71 void AdminHandler::kick(const BeingId playerId) const
72 {
74  outMsg.writeBeingId(playerId, "account id");
75 }
76 
78 {
80 }
81 
82 void AdminHandler::warp(const std::string &map, const int x, const int y) const
83 {
85  outMsg.writeString(map, 16, "map");
86  outMsg.writeInt16(CAST_S16(x), "x");
87  outMsg.writeInt16(CAST_S16(y), "y");
88 }
89 
91 {
93  outMsg.writeInt16(0, "flag");
94 }
95 
97 {
99  outMsg.writeInt16(1, "flag");
100 }
101 
102 void AdminHandler::gotoName(const std::string &name) const
103 {
105  outMsg.writeString(name, 24, "name");
106 }
107 
108 void AdminHandler::recallName(const std::string &name) const
109 {
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 
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 {
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 
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 {
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 
157  outMsg.writeBeingId(being->getId(), "account id");
158 }
159 
160 void AdminHandler::requestStats(const std::string &name) const
161 {
162  mStatsName = name;
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 } // namespace EAthena
int CMSG_ADMIN_ANNOUNCE
int CMSG_ADMIN_ID_TO_LOGIN
void disguise(const std::string &name) const
void mute(const Being *const being, const int type, const int limit) const
void killable(const std::string &name) const
void heal(const std::string &name) const
int CMSG_ADMIN_KICK_ALL
void hide(const bool h) const
BeingId getId() const
Definition: actorsprite.h:63
void changePartyLeader(const std::string &name) const
void warp(const std::string &map, const int x, const int y) const
void gotoName(const std::string &name) const
int CMSG_PLAYER_MAPMOVE
int BeingId
Definition: beingid.h:29
void showLevel(const std::string &name) const
void guildRecall(const std::string &name) const
void spawnSlave(const std::string &name) const
int CMSG_ADMIN_RESET_PLAYER
int CMSG_ADMIN_GOTO
void setTileType(const int x, const int y, const int type) const
int CMSG_ADMIN_REQUEST_STATS
void gotoNpc(const std::string &name) const
void localAnnounce(const std::string &text) const
void savePosition(const std::string &name) const
void runCommand(const std::string &command, const std::string &params)
Definition: gmfunctions.cpp:34
void locatePlayer(const std::string &name) const
#define CAST_S32
Definition: cast.h:29
int CMSG_ADMIN_RECALL
int CMSG_ADMIN_LOCAL_ANNOUNCE
void killer(const std::string &name) const
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
void hideNpc(const std::string &name) const
void monsterInfo(const std::string &name) const
void showStorageList(const std::string &name) const
void showStats(const std::string &name) const
void recallName(const std::string &name) const
void alive(const std::string &name) const
void runCharCommand(const std::string &command, const std::string &name, const std::string &params)
Definition: gmfunctions.cpp:60
#define CAST_S8
Definition: cast.h:25
void nuke(const std::string &name) const
void playerGmCommands(const std::string &name) const
void resetSkills() const
#define createOutPacket(name)
Definition: messageout.h:36
void showAccountInfo(const std::string &name) const
void immortal(const std::string &name) const
Net::AdminHandler * adminHandler
Definition: net.cpp:80
void muteName(const std::string &name) const
void partyRecall(const std::string &name) const
void breakGuild(const std::string &name) const
int CMSG_ADMIN_HIDE
void whoDrops(const std::string &name) const
#define A_UNUSED
Definition: localconsts.h:151
void spawnClone(const std::string &name) const
void randomWarp(const std::string &name) const
int CMSG_ADMIN_MUTE_NAME
void showCartList(const std::string &name) const
void announce(const std::string &text) const
void loadPosition(const std::string &name) const
int CMSG_ADMIN_UNEQUIP_ALL
int CMSG_ADMIN_SET_TILE_TYPE
void playerCharGmCommands(const std::string &name) const
void mobSearch(const std::string &name) const
void showInventoryList(const std::string &name) const
void itemInfo(const std::string &name) const
void unjail(const std::string &name) const
void kill(const std::string &name) const
#define CAST_S16
Definition: cast.h:27
void mobSpawnSearch(const std::string &name) const
void jail(const std::string &name) const
void requestStats(const std::string &name) const
void resetStats() const
void slide(const int x, const int y) const
void spawnEvilClone(const std::string &name) const
void showNpc(const std::string &name) const
int CMSG_ADMIN_MUTE
void unequipAll(const Being *const being) const
static std::string mStatsName
Definition: adminhandler.h:162
Definition: being.h:93
void npcMove(const std::string &name, const int x, const int y) const
int CMSG_ADMIN_KICK
void requestLogin(const Being *const being) const
void kick(const BeingId playerId) const
void spawnSlaveClone(const std::string &name) const