diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-07-25 16:57:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-07-25 16:57:26 +0300 |
commit | eac7bf3541eea467246d816a76f6b2b6a2e1e18a (patch) | |
tree | 27c57b5b9924ba098cec73a88d9cd60bd34bad74 /src | |
parent | cc5500b642f1cc5e16a44213c9b7423f8210ec66 (diff) | |
download | manaplus-eac7bf3541eea467246d816a76f6b2b6a2e1e18a.tar.gz manaplus-eac7bf3541eea467246d816a76f6b2b6a2e1e18a.tar.bz2 manaplus-eac7bf3541eea467246d816a76f6b2b6a2e1e18a.tar.xz manaplus-eac7bf3541eea467246d816a76f6b2b6a2e1e18a.zip |
Move state handler STATE_CONNECT_SERVER into separate function.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 142 | ||||
-rw-r--r-- | src/client.h | 2 |
2 files changed, 76 insertions, 68 deletions
diff --git a/src/client.cpp b/src/client.cpp index 598c95cc0..8358468fc 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -703,6 +703,78 @@ void Client::stateConnectGame1() loginHandler->disconnect(); } +void Client::stateConnectServer1() +{ + if (mOldState == STATE_CHOOSE_SERVER) + { + settings.serverName = mCurrentServer.hostname; + ConfigManager::initServerConfig(mCurrentServer.hostname); + PacketLimiter::initPacketLimiter(); + initTradeFilter(); + Dirs::initUsersDir(); + player_relations.init(); + + // Initialize the item and emote shortcuts. + for (unsigned f = 0; f < SHORTCUT_TABS; f ++) + { + delete itemShortcut[f]; + itemShortcut[f] = new ItemShortcut(f); + } + delete emoteShortcut; + emoteShortcut = new EmoteShortcut; + + // Initialize the drop shortcuts. + delete dropShortcut; + dropShortcut = new DropShortcut; + + initFeatures(); + PlayerInfo::loadData(); + loginData.registerUrl = mCurrentServer.registerUrl; + if (!mCurrentServer.onlineListUrl.empty()) + settings.onlineListUrl = mCurrentServer.onlineListUrl; + else + settings.onlineListUrl = settings.serverName; + settings.persistentIp = mCurrentServer.persistentIp; + settings.supportUrl = mCurrentServer.supportUrl; + settings.updateMirrors = mCurrentServer.updateMirrors; + + if (settings.options.username.empty()) + { + if (loginData.remember) + loginData.username = serverConfig.getValue("username", ""); + else + loginData.username.clear(); + } + else + { + loginData.username = settings.options.username; + } + + loginData.remember = serverConfig.getValue("remember", 1); + Net::connectToServer(mCurrentServer); + +#ifdef USE_MUMBLE + if (mumbleManager) + mumbleManager->setServer(mCurrentServer.hostname); +#endif + +#ifdef TMWA_SUPPORT + GuildManager::init(); +#endif + + if (!mConfigAutoSaved) + { + mConfigAutoSaved = true; + config.write(); + } + } + else if (mOldState != STATE_CHOOSE_SERVER && + loginHandler->isConnected()) + { + mState = STATE_PRE_LOGIN; + } +} + int Client::gameExec() { int lastTickTime = tick_time; @@ -769,75 +841,9 @@ int Client::gameExec() { stateConnectGame1(); } - else if (mState == STATE_CONNECT_SERVER && - mOldState == STATE_CHOOSE_SERVER) - { - settings.serverName = mCurrentServer.hostname; - ConfigManager::initServerConfig(mCurrentServer.hostname); - PacketLimiter::initPacketLimiter(); - initTradeFilter(); - Dirs::initUsersDir(); - player_relations.init(); - - // Initialize the item and emote shortcuts. - for (unsigned f = 0; f < SHORTCUT_TABS; f ++) - { - delete itemShortcut[f]; - itemShortcut[f] = new ItemShortcut(f); - } - delete emoteShortcut; - emoteShortcut = new EmoteShortcut; - - // Initialize the drop shortcuts. - delete dropShortcut; - dropShortcut = new DropShortcut; - - initFeatures(); - PlayerInfo::loadData(); - loginData.registerUrl = mCurrentServer.registerUrl; - if (!mCurrentServer.onlineListUrl.empty()) - settings.onlineListUrl = mCurrentServer.onlineListUrl; - else - settings.onlineListUrl = settings.serverName; - settings.persistentIp = mCurrentServer.persistentIp; - settings.supportUrl = mCurrentServer.supportUrl; - settings.updateMirrors = mCurrentServer.updateMirrors; - - if (settings.options.username.empty()) - { - if (loginData.remember) - loginData.username = serverConfig.getValue("username", ""); - else - loginData.username.clear(); - } - else - { - loginData.username = settings.options.username; - } - - loginData.remember = serverConfig.getValue("remember", 1); - Net::connectToServer(mCurrentServer); - -#ifdef USE_MUMBLE - if (mumbleManager) - mumbleManager->setServer(mCurrentServer.hostname); -#endif - -#ifdef TMWA_SUPPORT - GuildManager::init(); -#endif - - if (!mConfigAutoSaved) - { - mConfigAutoSaved = true; - config.write(); - } - } - else if (mState == STATE_CONNECT_SERVER && - mOldState != STATE_CHOOSE_SERVER && - loginHandler->isConnected()) + else if (mState == STATE_CONNECT_SERVER) { - mState = STATE_PRE_LOGIN; + stateConnectServer1(); } else if (mState == STATE_WORLD_SELECT && mOldState == STATE_UPDATE) { diff --git a/src/client.h b/src/client.h index 84329f54a..d3edf82e2 100644 --- a/src/client.h +++ b/src/client.h @@ -114,6 +114,8 @@ class Client final : public ConfigListener, void stateConnectGame1(); + void stateConnectServer1(); + ServerInfo mCurrentServer; Game *mGame; |