diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-10-03 12:40:52 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-10-03 16:47:11 -0600 |
commit | 0269b1f766a4e9e8ded91505855cff58c18086e2 (patch) | |
tree | c557c4c189bb536ab5ef7b8642011fe4f1da4eff /src | |
parent | eb22b66b0821e49ed550d30d20d9db5af535e6a3 (diff) | |
download | mana-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')
-rw-r--r-- | src/gui/charselectdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/quitdialog.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 21 | ||||
-rw-r--r-- | src/main.h | 9 | ||||
-rw-r--r-- | src/net/ea/generalhandler.cpp | 15 | ||||
-rw-r--r-- | src/net/ea/generalhandler.h | 2 | ||||
-rw-r--r-- | src/net/ea/loginhandler.cpp | 11 | ||||
-rw-r--r-- | src/net/ea/loginhandler.h | 3 | ||||
-rw-r--r-- | src/net/generalhandler.h | 2 | ||||
-rw-r--r-- | src/net/loginhandler.h | 2 | ||||
-rw-r--r-- | src/net/net.cpp | 19 | ||||
-rw-r--r-- | src/net/tmwserv/generalhandler.cpp | 7 | ||||
-rw-r--r-- | src/net/tmwserv/generalhandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwserv/loginhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/tmwserv/loginhandler.h | 2 |
15 files changed, 74 insertions, 30 deletions
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 13dc8dd6..12980e7b 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -182,7 +182,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) else if (event.getId() == "switch") { mCharInfo->clear(); - state = STATE_SWITCH_SERVER_ATTEMPT; + state = STATE_SWITCH_LOGIN; } else if (event.getId() == "new") { diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index b2faa618..8003cb2c 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -118,7 +118,7 @@ void QuitDialog::action(const gcn::ActionEvent &event) *mQuitGame = true; } - state = STATE_SWITCH_SERVER_ATTEMPT; + state = STATE_SWITCH_SERVER; } else if (mSwitchCharacter->isSelected()) { diff --git a/src/main.cpp b/src/main.cpp index 2a76f759..90e31f5a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -924,6 +924,8 @@ int main(int argc, char *argv[]) loadUpdates(); } + //printf("State change: %d to %d\n", oldstate, state); + oldstate = state; // Get rid of the dialog of the previous state @@ -963,11 +965,8 @@ int main(int argc, char *argv[]) break; case STATE_CONNECT_SERVER: - Net::connectToServer(currentServer); - logger->log("State: CONNECT_SERVER"); - currentDialog = new ConnectionDialog( - STATE_SWITCH_SERVER_ATTEMPT); + currentDialog = new ConnectionDialog(STATE_SWITCH_SERVER); break; case STATE_UPDATE: @@ -1039,6 +1038,7 @@ int main(int argc, char *argv[]) logger->log("State: WORLD SELECT"); { Worlds worlds = Net::getLoginHandler()->getWorlds(); + if (worlds.size() == 0) { state = STATE_UPDATE; @@ -1074,7 +1074,7 @@ int main(int argc, char *argv[]) break; case STATE_SWITCH_SERVER: - logger->log("State: SWITCH_SERVER"); + logger->log("State: SWITCH SERVER"); #ifdef TMWSERV_SUPPORT gameServerConnection->disconnect(); @@ -1085,12 +1085,12 @@ int main(int argc, char *argv[]) state = STATE_CHOOSE_SERVER; break; - case STATE_SWITCH_SERVER_ATTEMPT: - logger->log("State: SWITCH_SERVER_ATTEMPT"); + case STATE_SWITCH_LOGIN: + logger->log("State: SWITCH LOGIN"); - // TODO + Net::getLoginHandler()->logout(); - state = STATE_SWITCH_SERVER; + state = STATE_LOGIN; break; case STATE_REGISTER: @@ -1194,8 +1194,7 @@ int main(int argc, char *argv[]) case STATE_CONNECT_GAME: logger->log("State: CONNECT_GAME"); Net::getGameHandler()->connect(); - currentDialog = new ConnectionDialog( - STATE_SWITCH_SERVER_ATTEMPT); + currentDialog = new ConnectionDialog(STATE_SWITCH_CHARACTER); break; case STATE_GAME: @@ -107,15 +107,12 @@ enum State { STATE_UNREGISTER_ATTEMPT, STATE_UNREGISTER, STATE_SWITCH_SERVER, - STATE_SWITCH_SERVER_ATTEMPT, // 25 - STATE_SWITCH_LOGIN, - STATE_SWITCH_LOGIN_ATTEMPT, + STATE_SWITCH_LOGIN, // 25 STATE_SWITCH_CHARACTER, - STATE_SWITCH_CHARACTER_ATTEMPT, - STATE_LOGOUT_ATTEMPT, // 30 + STATE_LOGOUT_ATTEMPT, STATE_WAIT, STATE_EXIT, - STATE_FORCE_QUIT + STATE_FORCE_QUIT // 30 }; /* length definitions for several char[]s in order 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, |