Mana
Loading...
Searching...
No Matches
adminhandler.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
23
24#include "actorspritemanager.h"
25#include "being.h"
26#include "event.h"
27#include "playerrelations.h"
28
29#include "net/chathandler.h"
30#include "net/net.h"
31
32#include "net/tmwa/messagein.h"
33#include "net/tmwa/protocol.h"
34
35#include "utils/gettext.h"
36
37#include <string>
38
40
41namespace TmwAthena {
42
44{
45 static const uint16_t _messages[] =
46 {
49 0
50 };
51 handledMessages = _messages;
52 adminHandler = this;
53}
54
56{
57 int id;
58 switch (msg.getId())
59 {
61 id = msg.readInt32();
62 if (id == 0)
63 serverNotice(_("Kick failed!"));
64 else
65 serverNotice(_("Kick succeeded!"));
66 break;
68 id = msg.readInt32();
69 int ip = msg.readInt32();
70 if (Being *player = actorSpriteManager->findBeing(id))
71 player->setIp(ip);
72 break;
73 }
74}
75
76void AdminHandler::kick(const std::string &name)
77{
78 Net::getChatHandler()->talk("@kick " + name);
79}
80
81void AdminHandler::ban(const std::string &name)
82{
83 Net::getChatHandler()->talk("@ban " + name);
84}
85
86void AdminHandler::unban(const std::string &name)
87{
88 Net::getChatHandler()->talk("@unban " + name);
89}
90
91} // namespace TmwAthena
ActorSpriteManager * actorSpriteManager
Definition game.cpp:110
Being * findBeing(int id) const
Returns a specific Being, by id;.
Definition being.h:65
virtual void talk(const std::string &text)=0
const uint16_t * handledMessages
void unban(const std::string &name) override
void ban(const std::string &name) override
void kick(const std::string &name) override
void handleMessage(MessageIn &msg) override
Used for parsing an incoming message from eAthena.
Definition messagein.h:35
uint16_t getId() const
Returns the message ID.
Definition messagein.h:42
uint32_t readInt32()
Reads an unsigned 32-bit integer from the message.
Definition messagein.cpp:69
void serverNotice(const std::string &message)
Definition event.h:319
#define _(s)
Definition gettext.h:38
Net::AdminHandler * adminHandler
Definition net.cpp:46
ChatHandler * getChatHandler()
Definition net.cpp:70
Warning: buffers and other variables are shared, so there can be only one connection active at a time...
@ SMSG_BEING_IP_RESPONSE
Definition protocol.h:295
@ SMSG_ADMIN_KICK_ACK
Definition protocol.h:226