summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-07-18 12:11:39 -0600
committerJared Adams <jaxad0127@gmail.com>2010-07-18 12:25:37 -0600
commit060b5d24f824de45342c8ea1bab8fc98c08b369d (patch)
tree57b304d388277310990775ee5c9bb0f67b7bb7e6 /src/net/manaserv
parent81d8168bb5796ccb1704bcce9f5327c35e55d281 (diff)
downloadmana-client-060b5d24f824de45342c8ea1bab8fc98c08b369d.tar.gz
mana-client-060b5d24f824de45342c8ea1bab8fc98c08b369d.tar.bz2
mana-client-060b5d24f824de45342c8ea1bab8fc98c08b369d.tar.xz
mana-client-060b5d24f824de45342c8ea1bab8fc98c08b369d.zip
Replace some state-related netcode methods with events
Also move the virtual destructors of the Net handler base classes to the top of their method lists. Reviewed-by: Chuck Miller
Diffstat (limited to 'src/net/manaserv')
-rw-r--r--src/net/manaserv/gamehandler.cpp10
-rw-r--r--src/net/manaserv/gamehandler.h7
-rw-r--r--src/net/manaserv/generalhandler.cpp51
-rw-r--r--src/net/manaserv/generalhandler.h10
4 files changed, 34 insertions, 44 deletions
diff --git a/src/net/manaserv/gamehandler.cpp b/src/net/manaserv/gamehandler.cpp
index 271fff15..65010ad3 100644
--- a/src/net/manaserv/gamehandler.cpp
+++ b/src/net/manaserv/gamehandler.cpp
@@ -109,16 +109,6 @@ void GameHandler::disconnect()
chatHandler->disconnect();
}
-void GameHandler::inGame()
-{
- // TODO
-}
-
-void GameHandler::mapLoaded(const std::string &mapName)
-{
- // TODO
-}
-
void GameHandler::who()
{
// TODO
diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h
index 912b308e..2e9f37fe 100644
--- a/src/net/manaserv/gamehandler.h
+++ b/src/net/manaserv/gamehandler.h
@@ -42,10 +42,6 @@ class GameHandler : public MessageHandler, public Net::GameHandler
void disconnect();
- void inGame();
-
- void mapLoaded(const std::string &mapName);
-
void who();
void quit(bool reconnectAccount);
@@ -60,9 +56,8 @@ class GameHandler : public MessageHandler, public Net::GameHandler
void gameLoading();
- /** The ManaServ protocol doesn't use the Mp Main status bar. */
+ /** The ManaServ protocol doesn't use the MP status bar. */
bool canUseMagicBar() const { return false; }
-
};
} // namespace ManaServ
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index e1559d16..6fbbb954 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -22,6 +22,7 @@
#include "net/manaserv/generalhandler.h"
#include "client.h"
+#include "event.h"
#include "gui/changeemaildialog.h"
#include "gui/charselectdialog.h"
@@ -90,6 +91,9 @@ GeneralHandler::GeneralHandler():
chatServerConnection = getConnection();
generalHandler = this;
+
+ listen("Client");
+ listen("Game");
}
void GeneralHandler::load()
@@ -163,37 +167,40 @@ void GeneralHandler::flushNetwork()
}
}
-void GeneralHandler::guiWindowsLoaded()
-{
- inventoryWindow->setSplitAllowed(true);
- skillDialog->loadSkills("mana-skills.xml");
-
- PlayerInfo::setAttribute(EXP_NEEDED, 100);
-
- Stats::informStatusWindow();
-}
-
-void GeneralHandler::guiWindowsUnloaded()
-{
- // TODO
-}
-
void GeneralHandler::clearHandlers()
{
clearNetworkHandlers();
}
-void GeneralHandler::stateChanged(State oldState, State newState)
+void GeneralHandler::event(const std::string &channel,
+ const Mana::Event &event)
{
- if (newState == STATE_GAME)
+ if (channel == "Client")
{
- GameHandler *game = static_cast<GameHandler*>(Net::getGameHandler());
- game->gameLoading();
+ int newState = event.getInt("newState");
+
+ if (newState == STATE_GAME)
+ {
+ GameHandler *game = static_cast<GameHandler*>(Net::getGameHandler());
+ game->gameLoading();
+ }
+ else if (newState == STATE_LOAD_DATA)
+ {
+ Stats::load();
+ Stats::informItemDB();
+ }
}
- else if (newState == STATE_LOAD_DATA)
+ else if (channel == "Game")
{
- Stats::load();
- Stats::informItemDB();
+ if (event.getName() == "GuiWindowsLoaded")
+ {
+ inventoryWindow->setSplitAllowed(true);
+ skillDialog->loadSkills("mana-skills.xml");
+
+ PlayerInfo::setAttribute(EXP_NEEDED, 100);
+
+ Stats::informStatusWindow();
+ }
}
}
diff --git a/src/net/manaserv/generalhandler.h b/src/net/manaserv/generalhandler.h
index 58b95529..2a203e8c 100644
--- a/src/net/manaserv/generalhandler.h
+++ b/src/net/manaserv/generalhandler.h
@@ -22,6 +22,8 @@
#ifndef NET_MANASERV_GENERALHANDLER_H
#define NET_MANASERV_GENERALHANDLER_H
+#include "listener.h"
+
#include "net/generalhandler.h"
#include "net/net.h"
@@ -29,7 +31,7 @@
namespace ManaServ {
-class GeneralHandler : public Net::GeneralHandler
+class GeneralHandler : public Net::GeneralHandler, public Mana::Listener
{
public:
GeneralHandler();
@@ -42,13 +44,9 @@ class GeneralHandler : public Net::GeneralHandler
void flushNetwork();
- void guiWindowsLoaded();
-
- void guiWindowsUnloaded();
-
void clearHandlers();
- void stateChanged(State oldState, State newState);
+ void event(const std::string &channel, const Mana::Event &event);
protected:
MessageHandlerPtr mBeingHandler;