summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-10-03 12:40:52 -0600
committerJared Adams <jaxad0127@gmail.com>2009-10-03 16:47:11 -0600
commit0269b1f766a4e9e8ded91505855cff58c18086e2 (patch)
treec557c4c189bb536ab5ef7b8642011fe4f1da4eff /src/net
parenteb22b66b0821e49ed550d30d20d9db5af535e6a3 (diff)
downloadmana-0269b1f766a4e9e8ded91505855cff58c18086e2.tar.gz
mana-0269b1f766a4e9e8ded91505855cff58c18086e2.tar.bz2
mana-0269b1f766a4e9e8ded91505855cff58c18086e2.tar.xz
mana-0269b1f766a4e9e8ded91505855cff58c18086e2.zip
Do some more post-merge cleanup
Fixes a few more bugs
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/generalhandler.cpp15
-rw-r--r--src/net/ea/generalhandler.h2
-rw-r--r--src/net/ea/loginhandler.cpp11
-rw-r--r--src/net/ea/loginhandler.h3
-rw-r--r--src/net/generalhandler.h2
-rw-r--r--src/net/loginhandler.h2
-rw-r--r--src/net/net.cpp19
-rw-r--r--src/net/tmwserv/generalhandler.cpp7
-rw-r--r--src/net/tmwserv/generalhandler.h2
-rw-r--r--src/net/tmwserv/loginhandler.cpp5
-rw-r--r--src/net/tmwserv/loginhandler.h2
11 files changed, 59 insertions, 11 deletions
diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp
index 692ebec0..8f02d629 100644
--- a/src/net/ea/generalhandler.cpp
+++ b/src/net/ea/generalhandler.cpp
@@ -60,14 +60,16 @@
#include "utils/gettext.h"
+#include <assert.h>
#include <list>
-Net::GeneralHandler *generalHandler;
+Net::GeneralHandler *generalHandler = NULL;
namespace EAthena {
Token netToken;
ServerInfo charServer;
ServerInfo mapServer;
+Worlds worlds;
GeneralHandler::GeneralHandler():
mAdminHandler(new AdminHandler),
@@ -86,6 +88,7 @@ GeneralHandler::GeneralHandler():
mSpecialHandler(new SpecialHandler),
mTradeHandler(new TradeHandler)
{
+ //assert(false);
static const Uint16 _messages[] = {
SMSG_CONNECTION_PROBLEM,
0
@@ -172,9 +175,17 @@ void GeneralHandler::load()
mNetwork->registerHandler(mPartyHandler.get());
}
+void GeneralHandler::reload()
+{
+ if (mNetwork)
+ mNetwork->disconnect();
+ worlds.clear();
+}
+
void GeneralHandler::unload()
{
- mNetwork->clearHandlers();
+ if (mNetwork)
+ mNetwork->clearHandlers();
}
void GeneralHandler::flushNetwork()
diff --git a/src/net/ea/generalhandler.h b/src/net/ea/generalhandler.h
index 099bed0b..b8ea8049 100644
--- a/src/net/ea/generalhandler.h
+++ b/src/net/ea/generalhandler.h
@@ -40,6 +40,8 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler
void load();
+ void reload();
+
void unload();
void flushNetwork();
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index d2e2adc0..de52bfa3 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -35,13 +35,12 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-Worlds worlds;
-
Net::LoginHandler *loginHandler;
namespace EAthena {
extern Token netToken;
extern ServerInfo charServer;
+extern Worlds worlds;
LoginHandler::LoginHandler()
{
@@ -212,10 +211,14 @@ void LoginHandler::disconnect()
void LoginHandler::loginAccount(LoginData *loginData)
{
- mLoginData = loginData;
sendLoginRegister(loginData->username, loginData->password);
}
+void LoginHandler::logout()
+{
+ // TODO
+}
+
void LoginHandler::changeEmail(const std::string &email)
{
// TODO
@@ -242,8 +245,6 @@ void LoginHandler::chooseServer(unsigned int server)
void LoginHandler::registerAccount(LoginData *loginData)
{
- mLoginData = loginData;
-
std::string username = loginData->username;
username.append((netToken.sex == GENDER_FEMALE) ? "_F" : "_M");
diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h
index 780aa832..c5ce975e 100644
--- a/src/net/ea/loginhandler.h
+++ b/src/net/ea/loginhandler.h
@@ -51,6 +51,8 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
void loginAccount(LoginData *loginData);
+ void logout();
+
void changeEmail(const std::string &email);
void changePassword(const std::string &username,
@@ -70,7 +72,6 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
void sendLoginRegister(const std::string &username,
const std::string &password);
- LoginData *mLoginData;
std::string mUpdateHost;
};
diff --git a/src/net/generalhandler.h b/src/net/generalhandler.h
index 3b081834..0a22d0fd 100644
--- a/src/net/generalhandler.h
+++ b/src/net/generalhandler.h
@@ -31,6 +31,8 @@ class GeneralHandler
public:
virtual void load() = 0;
+ virtual void reload() = 0;
+
virtual void unload() = 0;
virtual void flushNetwork() = 0;
diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h
index 5274bbea..e4f8c767 100644
--- a/src/net/loginhandler.h
+++ b/src/net/loginhandler.h
@@ -56,6 +56,8 @@ class LoginHandler
virtual void loginAccount(LoginData *loginData) = 0;
+ virtual void logout() = 0;
+
virtual void changeEmail(const std::string &email) = 0;
virtual void changePassword(const std::string &username,
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 6a9c072a..bce0844c 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -122,19 +122,34 @@ Net::TradeHandler *Net::getTradeHandler()
return tradeHandler;
}
+namespace Net
+{
+ bool networkLoaded = false;
+}
+
void Net::connectToServer(const ServerInfo &server)
{
// TODO: Actually query the server about itself and choose the netcode
// based on that
+ if (networkLoaded)
+ {
+ printf("Reload!\n");
+ Net::getGeneralHandler()->reload();
+ }
+ else
+ {
#ifdef TMWSERV_SUPPORT
- new TmwServ::GeneralHandler;
+ new TmwServ::GeneralHandler;
#else
- new EAthena::GeneralHandler;
+ new EAthena::GeneralHandler;
#endif
+ }
Net::getGeneralHandler()->load();
+ networkLoaded = true;
+
Net::getLoginHandler()->setServer(server);
Net::getLoginHandler()->connect();
diff --git a/src/net/tmwserv/generalhandler.cpp b/src/net/tmwserv/generalhandler.cpp
index 0f4b5109..7948953e 100644
--- a/src/net/tmwserv/generalhandler.cpp
+++ b/src/net/tmwserv/generalhandler.cpp
@@ -55,7 +55,7 @@
#include <list>
-Net::GeneralHandler *generalHandler;
+Net::GeneralHandler *generalHandler = NULL;
Net::Connection *gameServerConnection = 0;
Net::Connection *chatServerConnection = 0;
@@ -126,6 +126,11 @@ void GeneralHandler::load()
Net::registerHandler(mTradeHandler.get());
}
+void GeneralHandler::reload()
+{
+ // Nothing needed yet
+}
+
void GeneralHandler::unload()
{
Net::clearHandlers();
diff --git a/src/net/tmwserv/generalhandler.h b/src/net/tmwserv/generalhandler.h
index 6c1d849f..ef533489 100644
--- a/src/net/tmwserv/generalhandler.h
+++ b/src/net/tmwserv/generalhandler.h
@@ -35,6 +35,8 @@ class GeneralHandler : public Net::GeneralHandler
void load();
+ void reload();
+
void unload();
void flushNetwork();
diff --git a/src/net/tmwserv/loginhandler.cpp b/src/net/tmwserv/loginhandler.cpp
index 645d574c..dfe0e151 100644
--- a/src/net/tmwserv/loginhandler.cpp
+++ b/src/net/tmwserv/loginhandler.cpp
@@ -313,6 +313,11 @@ void LoginHandler::loginAccount(LoginData *loginData)
loginData->password);
}
+void LoginHandler::logout()
+{
+ // TODO
+}
+
void LoginHandler::changeEmail(const std::string &email)
{
Net::AccountServer::Account::changeEmail(email);
diff --git a/src/net/tmwserv/loginhandler.h b/src/net/tmwserv/loginhandler.h
index 754fa71b..66f243b7 100644
--- a/src/net/tmwserv/loginhandler.h
+++ b/src/net/tmwserv/loginhandler.h
@@ -49,6 +49,8 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
void loginAccount(LoginData *loginData);
+ void logout();
+
void changeEmail(const std::string &email);
void changePassword(const std::string &username,