summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/gamehandler.cpp34
-rw-r--r--src/net/ea/gamehandler.h25
-rw-r--r--src/net/eathena/gamehandler.cpp10
-rw-r--r--src/net/eathena/gamehandler.h18
-rw-r--r--src/net/gamehandler.h17
-rw-r--r--src/net/tmwa/gamehandler.cpp16
-rw-r--r--src/net/tmwa/gamehandler.h18
7 files changed, 60 insertions, 78 deletions
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp
index 19978979b..4a011c6a8 100644
--- a/src/net/ea/gamehandler.cpp
+++ b/src/net/ea/gamehandler.cpp
@@ -37,27 +37,9 @@ namespace Ea
GameHandler::GameHandler() :
mCharID(0)
{
- listen(CHANNEL_GAME);
}
-void GameHandler::processEvent(Channels channel,
- const DepricatedEvent &event)
-{
- if (channel == CHANNEL_GAME)
- {
- if (event.getName() == EVENT_ENGINESINITALIZED)
- {
- if (!mMap.empty())
- Game::instance()->changeMap(mMap);
- }
- else if (event.getName() == EVENT_MAPLOADED)
- {
- mapLoadedEvent();
- }
- }
-}
-
-void GameHandler::who()
+void GameHandler::who() const
{
}
@@ -66,7 +48,7 @@ void GameHandler::setMap(const std::string &map)
mMap = map.substr(0, map.rfind("."));
}
-void GameHandler::processMapLogin(Net::MessageIn &msg)
+void GameHandler::processMapLogin(Net::MessageIn &msg) const
{
unsigned char direction;
uint16_t x, y;
@@ -81,18 +63,18 @@ void GameHandler::processMapLogin(Net::MessageIn &msg)
player_node->setTileCoords(x, y);
}
-void GameHandler::processWhoAnswer(Net::MessageIn &msg)
+void GameHandler::processWhoAnswer(Net::MessageIn &msg) const
{
NotifyManager::notify(NotifyManager::ONLINE_USERS, msg.readInt32());
}
-void GameHandler::processCharSwitchResponse(Net::MessageIn &msg)
+void GameHandler::processCharSwitchResponse(Net::MessageIn &msg) const
{
if (msg.readInt8())
Client::setState(STATE_SWITCH_CHARACTER);
}
-void GameHandler::processMapQuitResponse(Net::MessageIn &msg)
+void GameHandler::processMapQuitResponse(Net::MessageIn &msg) const
{
if (msg.readInt8())
new OkDialog(_("Game"), _("Request to quit denied!"), DIALOG_ERROR);
@@ -104,4 +86,10 @@ void GameHandler::clear()
mCharID = 0;
}
+void GameHandler::initEngines() const
+{
+ if (!mMap.empty())
+ Game::instance()->changeMap(mMap);
+}
+
} // namespace Ea
diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h
index c0b4286ce..d6c9cebdc 100644
--- a/src/net/ea/gamehandler.h
+++ b/src/net/ea/gamehandler.h
@@ -23,8 +23,6 @@
#ifndef NET_EA_GAMEHANDLER_H
#define NET_EA_GAMEHANDLER_H
-#include "listener.h"
-
#include "net/gamehandler.h"
#include "net/messagein.h"
#include "net/net.h"
@@ -32,37 +30,34 @@
namespace Ea
{
-class GameHandler : public Net::GameHandler, public Listener
+class GameHandler : public Net::GameHandler
{
public:
GameHandler();
A_DELETE_COPY(GameHandler)
- virtual void processEvent(Channels channel,
- const DepricatedEvent &event) override;
-
- virtual void who();
+ virtual void who() const override;
- virtual bool removeDeadBeings() const A_WARN_UNUSED
+ virtual bool removeDeadBeings() const override A_WARN_UNUSED
{ return true; }
virtual void setMap(const std::string &map);
- virtual bool canUseMagicBar() const A_WARN_UNUSED
+ virtual bool canUseMagicBar() const override A_WARN_UNUSED
{ return true; }
- virtual void mapLoadedEvent() = 0;
+ virtual void processMapLogin(Net::MessageIn &msg) const;
- virtual void processMapLogin(Net::MessageIn &msg);
+ virtual void processWhoAnswer(Net::MessageIn &msg) const;
- virtual void processWhoAnswer(Net::MessageIn &msg);
+ virtual void processCharSwitchResponse(Net::MessageIn &msg) const;
- virtual void processCharSwitchResponse(Net::MessageIn &msg);
+ virtual void processMapQuitResponse(Net::MessageIn &msg) const;
- virtual void processMapQuitResponse(Net::MessageIn &msg);
+ virtual void clear() override;
- virtual void clear();
+ virtual void initEngines() const override;
protected:
std::string mMap;
diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp
index d98523828..fbce4d943 100644
--- a/src/net/eathena/gamehandler.cpp
+++ b/src/net/eathena/gamehandler.cpp
@@ -89,7 +89,7 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
}
}
-void GameHandler::mapLoadedEvent()
+void GameHandler::mapLoadedEvent() const
{
MessageOut outMsg(CMSG_MAP_LOADED);
}
@@ -138,7 +138,7 @@ void GameHandler::connect()
// mNetwork->skip(4);
}
-bool GameHandler::isConnected()
+bool GameHandler::isConnected() const
{
if (!mNetwork)
return false;
@@ -151,18 +151,18 @@ void GameHandler::disconnect()
mNetwork->disconnect();
}
-void GameHandler::quit()
+void GameHandler::quit() const
{
MessageOut outMsg(CMSG_CLIENT_QUIT);
}
-void GameHandler::ping(int tick)
+void GameHandler::ping(const int tick) const
{
MessageOut msg(CMSG_CLIENT_PING);
msg.writeInt32(tick);
}
-void GameHandler::disconnect2()
+void GameHandler::disconnect2() const
{
MessageOut outMsg(CMSG_CLIENT_DISCONNECT);
}
diff --git a/src/net/eathena/gamehandler.h b/src/net/eathena/gamehandler.h
index 425285f91..4e3ef861b 100644
--- a/src/net/eathena/gamehandler.h
+++ b/src/net/eathena/gamehandler.h
@@ -40,25 +40,25 @@ class GameHandler final : public MessageHandler, public Ea::GameHandler
A_DELETE_COPY(GameHandler)
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg) override;
- void connect();
+ void connect() override;
- bool isConnected() A_WARN_UNUSED;
+ bool isConnected() const override A_WARN_UNUSED;
- void disconnect();
+ void disconnect() override;
- void quit();
+ void quit() const override;
- void ping(int tick);
+ void ping(const int tick) const override;
- void disconnect2();
+ void disconnect2() const override;
- void mapLoadedEvent();
+ void mapLoadedEvent() const override;
void processMapCharId(Net::MessageIn &msg);
- bool mustPing() const A_WARN_UNUSED
+ bool mustPing() const override A_WARN_UNUSED
{ return true; }
};
diff --git a/src/net/gamehandler.h b/src/net/gamehandler.h
index 5826ae09d..89111d241 100644
--- a/src/net/gamehandler.h
+++ b/src/net/gamehandler.h
@@ -38,27 +38,28 @@ class GameHandler
virtual void connect() = 0;
- virtual bool isConnected() = 0;
+ virtual bool isConnected() const = 0;
virtual void disconnect() = 0;
- virtual void who() = 0;
+ virtual void who() const = 0;
- virtual void quit() = 0;
+ virtual void quit() const = 0;
- virtual void ping(int tick) = 0;
+ virtual void ping(const int tick) const = 0;
virtual bool removeDeadBeings() const = 0;
- virtual void disconnect2() = 0;
+ virtual void disconnect2() const = 0;
- /**
- * Tells whether the protocol is using the MP status bar
- */
virtual bool canUseMagicBar() const A_WARN_UNUSED = 0;
virtual bool mustPing() const A_WARN_UNUSED = 0;
+ virtual void mapLoadedEvent() const = 0;
+
+ virtual void initEngines() const = 0;
+
virtual void clear() = 0;
};
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index 80dc461f5..ce6fa0e14 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -88,7 +88,7 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
BLOCK_END("GameHandler::handleMessage")
}
-void GameHandler::mapLoadedEvent()
+void GameHandler::mapLoadedEvent() const
{
MessageOut outMsg(CMSG_MAP_LOADED);
}
@@ -99,10 +99,8 @@ void GameHandler::connect()
return;
mNetwork->connect(mapServer);
-
- const Token &token =
- static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
-
+ const Token &token = static_cast<LoginHandler*>(
+ Net::getLoginHandler())->getToken();
if (Client::getState() == STATE_CONNECT_GAME)
{
@@ -137,7 +135,7 @@ void GameHandler::connect()
mNetwork->skip(4);
}
-bool GameHandler::isConnected()
+bool GameHandler::isConnected() const
{
if (!mNetwork)
return false;
@@ -150,18 +148,18 @@ void GameHandler::disconnect()
mNetwork->disconnect();
}
-void GameHandler::quit()
+void GameHandler::quit() const
{
MessageOut outMsg(CMSG_CLIENT_QUIT);
}
-void GameHandler::ping(int tick)
+void GameHandler::ping(const int tick) const
{
MessageOut msg(CMSG_CLIENT_PING);
msg.writeInt32(tick);
}
-void GameHandler::disconnect2()
+void GameHandler::disconnect2() const
{
MessageOut outMsg(CMSG_CLIENT_DISCONNECT);
}
diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h
index 5ce70fbca..9a63ddaf4 100644
--- a/src/net/tmwa/gamehandler.h
+++ b/src/net/tmwa/gamehandler.h
@@ -40,23 +40,23 @@ class GameHandler final : public MessageHandler, public Ea::GameHandler
A_DELETE_COPY(GameHandler)
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg) override;
- void connect();
+ void connect() override;
- bool isConnected() A_WARN_UNUSED;
+ bool isConnected() const override A_WARN_UNUSED;
- void disconnect();
+ void disconnect() override;
- void quit();
+ void quit() const override;
- void ping(int tick);
+ void ping(const int tick) const override;
- void disconnect2();
+ void disconnect2() const override;
- void mapLoadedEvent();
+ void mapLoadedEvent() const override;
- bool mustPing() const A_WARN_UNUSED
+ bool mustPing() const override A_WARN_UNUSED
{ return false; }
};