From fef6ebca9c454f99d44e950c4628270b124c445f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 1 May 2015 16:16:37 +0300 Subject: eathena: add support for send chat command from server. Changed client net version to 8. --- src/net/eathena/network.h | 2 +- src/net/eathena/packets.h | 2 +- src/net/eathena/playerhandler.cpp | 24 ++++++++++++++++++++++++ src/net/eathena/playerhandler.h | 2 ++ src/net/eathena/protocol.h | 2 ++ 5 files changed, 30 insertions(+), 2 deletions(-) (limited to 'src/net/eathena') diff --git a/src/net/eathena/network.h b/src/net/eathena/network.h index 05d5f0cb4..89bd5f816 100644 --- a/src/net/eathena/network.h +++ b/src/net/eathena/network.h @@ -29,7 +29,7 @@ * Protocol version, reported to the eAthena char and mapserver who can adjust * the protocol accordingly. */ -#define CLIENT_PROTOCOL_VERSION 7 +#define CLIENT_PROTOCOL_VERSION 8 namespace EAthena { diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h index 30e3d86f7..51639545d 100644 --- a/src/net/eathena/packets.h +++ b/src/net/eathena/packets.h @@ -282,7 +282,7 @@ int16_t packet_lengths[] = //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // #0x0B00 16, -1, 10, -1, -1, -1, -1, 0, 27, 0, -1, -1, 0, 0, 0, 0, - -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // #0x0B40 diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index 2a087ee6a..b866dcb5c 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -28,10 +28,14 @@ #include "gui/windows/statuswindow.h" +#include "input/inputmanager.h" + #include "net/eathena/messageout.h" #include "net/eathena/protocol.h" #include "net/eathena/inventoryhandler.h" +#include "utils/stringutils.h" + #include "debug.h" extern Net::PlayerHandler *playerHandler; @@ -72,6 +76,7 @@ PlayerHandler::PlayerHandler() : SMSG_PLAYER_EQUIP_TICK_ACK, SMSG_AUTOSHADOW_SPELL_LIST, SMSG_PLAYER_RANK_POINTS, + SMSG_PLAYER_CLIENT_COMMAND, 0 }; handledMessages = _messages; @@ -191,6 +196,10 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) processPlayerRankPoints(msg); break; + case SMSG_PLAYER_CLIENT_COMMAND: + processPlayerClientCommand(msg); + break; + default: break; } @@ -637,4 +646,19 @@ void PlayerHandler::processPlayerRankPoints(Net::MessageIn &msg) msg.readInt32("fame"); } +void PlayerHandler::processPlayerClientCommand(Net::MessageIn &msg) +{ + const int sz = msg.readInt16("len") - 4; + std::string command = msg.readString(sz, "command"); + std::string cmd; + std::string args; + + if (!parse2Str(command, cmd, args)) + { + cmd = command; + args.clear(); + } + inputManager.executeChatCommand(cmd, args, nullptr); +} + } // namespace EAthena diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h index 22a2cd56e..bc2dab173 100644 --- a/src/net/eathena/playerhandler.h +++ b/src/net/eathena/playerhandler.h @@ -109,6 +109,8 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler static void processPlayerAutoShadowSpellList(Net::MessageIn &msg); static void processPlayerRankPoints(Net::MessageIn &msg); + + static void processPlayerClientCommand(Net::MessageIn &msg); }; } // namespace EAthena diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h index 156597505..4c8e67b5b 100644 --- a/src/net/eathena/protocol.h +++ b/src/net/eathena/protocol.h @@ -437,6 +437,8 @@ #define SMSG_MAP_MUSIC 0x0b05 +#define SMSG_PLAYER_CLIENT_COMMAND 0x0b16 + #define SMSG_CART_INFO 0x0121 #define SMSG_CART_REMOVE 0x012b -- cgit v1.2.3-70-g09d2