diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-07-28 23:30:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-07-29 04:26:04 +0300 |
commit | c8b18b47abbb325b6cc4b34abbad52b03825e4f9 (patch) | |
tree | 3fbca23dda0c1c1ec31c54373e4faa74c998bb76 /src/net/tmwa/gamehandler.cpp | |
parent | 0cc6167c407c1cf18158ca0e154a3b1cab48853d (diff) | |
download | plus-c8b18b47abbb325b6cc4b34abbad52b03825e4f9.tar.gz plus-c8b18b47abbb325b6cc4b34abbad52b03825e4f9.tar.bz2 plus-c8b18b47abbb325b6cc4b34abbad52b03825e4f9.tar.xz plus-c8b18b47abbb325b6cc4b34abbad52b03825e4f9.zip |
Extract shared logic from chathandler and gamehandler netcode to ea namespace.
Diffstat (limited to 'src/net/tmwa/gamehandler.cpp')
-rw-r--r-- | src/net/tmwa/gamehandler.cpp | 49 |
1 files changed, 6 insertions, 43 deletions
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index 99d4841b2..cc0a37c57 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -28,8 +28,6 @@ #include "localplayer.h" #include "log.h" -#include "gui/okdialog.h" - #include "net/messagein.h" #include "net/messageout.h" @@ -37,9 +35,6 @@ #include "net/tmwa/network.h" #include "net/tmwa/protocol.h" -#include "utils/gettext.h" -#include "utils/stringutils.h" - #include "debug.h" extern Net::GameHandler *gameHandler; @@ -62,9 +57,6 @@ GameHandler::GameHandler() }; handledMessages = _messages; gameHandler = this; - mCharID = 0; - - listen(Mana::CHANNEL_GAME); } void GameHandler::handleMessage(Net::MessageIn &msg) @@ -72,20 +64,8 @@ void GameHandler::handleMessage(Net::MessageIn &msg) switch (msg.getId()) { case SMSG_MAP_LOGIN_SUCCESS: - { - unsigned char direction; - Uint16 x, y; - msg.readInt32(); // server tick - msg.readCoordinates(x, y, direction); - msg.skip(2); // unknown - logger->log("Protocol: Player start position: (%d, %d)," - " Direction: %d", x, y, direction); - // Switch now or we'll have problems - Client::setState(STATE_GAME); - if (player_node) - player_node->setTileCoords(x, y); + processMapLogin(msg); break; - } case SMSG_SERVER_PING: // We ignore this for now @@ -93,17 +73,15 @@ void GameHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_WHO_ANSWER: - SERVER_NOTICE(strprintf(_("Online users: %d"), msg.readInt32())) + processWhoAnswer(msg); break; case SMSG_CHAR_SWITCH_RESPONSE: - if (msg.readInt8()) - Client::setState(STATE_SWITCH_CHARACTER); + processCharSwitchResponse(msg); break; case SMSG_MAP_QUIT_RESPONSE: - if (msg.readInt8()) - new OkDialog(_("Game"), _("Request to quit denied!"), NULL); + processMapQuitResponse(msg); break; default: @@ -111,15 +89,9 @@ void GameHandler::handleMessage(Net::MessageIn &msg) } } -void GameHandler::event(Mana::Channels channel, const Mana::Event &event) +void GameHandler::mapLoadedEvent() { - if (channel == Mana::CHANNEL_GAME) - { - if (event.getName() == Mana::EVENT_ENGINESINITALIZED) - Game::instance()->changeMap(mMap); - else if (event.getName() == Mana::EVENT_MAPLOADED) - MessageOut outMsg(CMSG_MAP_LOADED); - } + MessageOut outMsg(CMSG_MAP_LOADED); } void GameHandler::connect() @@ -172,10 +144,6 @@ void GameHandler::disconnect() mNetwork->disconnect(); } -void GameHandler::who() -{ -} - void GameHandler::quit() { MessageOut outMsg(CMSG_CLIENT_QUIT); @@ -187,11 +155,6 @@ void GameHandler::ping(int tick) msg.writeInt32(tick); } -void GameHandler::setMap(const std::string map) -{ - mMap = map.substr(0, map.rfind(".")); -} - void GameHandler::disconnect2() { MessageOut outMsg(CMSG_CLIENT_DISCONNECT); |