summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/gamehandler.cpp14
-rw-r--r--src/net/ea/gamehandler.h10
-rw-r--r--src/net/eathena/gamehandler.cpp13
-rw-r--r--src/net/eathena/gamehandler.h8
-rw-r--r--src/net/tmwa/gamehandler.cpp11
-rw-r--r--src/net/tmwa/gamehandler.h2
6 files changed, 36 insertions, 22 deletions
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp
index 64e952680..8d42cc220 100644
--- a/src/net/ea/gamehandler.cpp
+++ b/src/net/ea/gamehandler.cpp
@@ -41,10 +41,14 @@
namespace Ea
{
+std::string GameHandler::mMap;
+int GameHandler::mCharID = 0;
+
GameHandler::GameHandler() :
- mMap(),
- mCharID(0)
+ Net::GameHandler()
{
+ mMap.clear();
+ mCharID = 0;
}
void GameHandler::who() const
@@ -56,19 +60,19 @@ void GameHandler::setMap(const std::string &map)
mMap = map.substr(0, map.rfind("."));
}
-void GameHandler::processWhoAnswer(Net::MessageIn &msg) const
+void GameHandler::processWhoAnswer(Net::MessageIn &msg)
{
NotifyManager::notify(NotifyTypes::ONLINE_USERS,
msg.readInt32("users count"));
}
-void GameHandler::processCharSwitchResponse(Net::MessageIn &msg) const
+void GameHandler::processCharSwitchResponse(Net::MessageIn &msg)
{
if (msg.readUInt8("response"))
client->setState(STATE_SWITCH_CHARACTER);
}
-void GameHandler::processMapQuitResponse(Net::MessageIn &msg) const
+void GameHandler::processMapQuitResponse(Net::MessageIn &msg)
{
if (msg.readUInt8("response"))
{
diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h
index 68de36c70..09854b7a5 100644
--- a/src/net/ea/gamehandler.h
+++ b/src/net/ea/gamehandler.h
@@ -50,19 +50,19 @@ class GameHandler notfinal : public Net::GameHandler
virtual bool canUseMagicBar() const override final A_WARN_UNUSED
{ return true; }
- virtual void processWhoAnswer(Net::MessageIn &msg) const;
+ static void processWhoAnswer(Net::MessageIn &msg);
- virtual void processCharSwitchResponse(Net::MessageIn &msg) const;
+ static void processCharSwitchResponse(Net::MessageIn &msg);
- virtual void processMapQuitResponse(Net::MessageIn &msg) const;
+ static void processMapQuitResponse(Net::MessageIn &msg);
virtual void clear() override final;
virtual void initEngines() const override final;
protected:
- std::string mMap;
- int mCharID; // < Saved for map-server switching
+ static std::string mMap;
+ static int mCharID; // < Saved for map-server switching
};
} // namespace Ea
diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp
index b8d0ecd8e..6caf57c20 100644
--- a/src/net/eathena/gamehandler.cpp
+++ b/src/net/eathena/gamehandler.cpp
@@ -173,7 +173,7 @@ void GameHandler::processMapAccountId(Net::MessageIn &msg)
msg.readInt32("account id");
}
-void GameHandler::processMapLogin(Net::MessageIn &msg) const
+void GameHandler::processMapLogin(Net::MessageIn &msg)
{
unsigned char direction;
uint16_t x, y;
@@ -188,8 +188,13 @@ void GameHandler::processMapLogin(Net::MessageIn &msg) const
mLastHost &= 0xffffff;
- if (mNetwork)
- mNetwork->pauseDispatch();
+ GameHandler *const g = dynamic_cast<GameHandler*>(gameHandler);
+ if (g)
+ {
+ Network *const network = g->mNetwork;
+ if (network)
+ network->pauseDispatch();
+ }
// Switch now or we'll have problems
client->setState(STATE_GAME);
@@ -197,7 +202,7 @@ void GameHandler::processMapLogin(Net::MessageIn &msg) const
localPlayer->setTileCoords(x, y);
}
-void GameHandler::processServerTick(Net::MessageIn &msg) const
+void GameHandler::processServerTick(Net::MessageIn &msg)
{
msg.readInt32("tick");
}
diff --git a/src/net/eathena/gamehandler.h b/src/net/eathena/gamehandler.h
index 85314d117..ef257e016 100644
--- a/src/net/eathena/gamehandler.h
+++ b/src/net/eathena/gamehandler.h
@@ -53,15 +53,15 @@ class GameHandler final : public MessageHandler, public Ea::GameHandler
void mapLoadedEvent() const override final;
- static void processMapAccountId(Net::MessageIn &msg);
-
bool mustPing() const override final A_WARN_UNUSED
{ return true; }
protected:
- void processMapLogin(Net::MessageIn &msg) const;
+ static void processMapAccountId(Net::MessageIn &msg);
+
+ static void processMapLogin(Net::MessageIn &msg);
- void processServerTick(Net::MessageIn &msg) const;
+ static void processServerTick(Net::MessageIn &msg);
};
} // namespace EAthena
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index 4d6d1998f..65ff13fb8 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -168,7 +168,7 @@ void GameHandler::disconnect2() const
createOutPacket(CMSG_CLIENT_DISCONNECT);
}
-void GameHandler::processMapLogin(Net::MessageIn &msg) const
+void GameHandler::processMapLogin(Net::MessageIn &msg)
{
unsigned char direction;
uint16_t x, y;
@@ -180,8 +180,13 @@ void GameHandler::processMapLogin(Net::MessageIn &msg) const
mLastHost &= 0xffffff;
- if (mNetwork)
- mNetwork->pauseDispatch();
+ GameHandler *const g = dynamic_cast<GameHandler*>(gameHandler);
+ if (g)
+ {
+ Network *const network = g->mNetwork;
+ if (network)
+ network->pauseDispatch();
+ }
// Switch now or we'll have problems
client->setState(STATE_GAME);
diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h
index b3736289e..7629425a3 100644
--- a/src/net/tmwa/gamehandler.h
+++ b/src/net/tmwa/gamehandler.h
@@ -57,7 +57,7 @@ class GameHandler final : public MessageHandler, public Ea::GameHandler
{ return false; }
protected:
- void processMapLogin(Net::MessageIn &msg) const;
+ static void processMapLogin(Net::MessageIn &msg);
};
} // namespace TmwAthena