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