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/client.cpp | |
parent | cc5500b642f1cc5e16a44213c9b7423f8210ec66 (diff) | |
download | plus-eac7bf3541eea467246d816a76f6b2b6a2e1e18a.tar.gz plus-eac7bf3541eea467246d816a76f6b2b6a2e1e18a.tar.bz2 plus-eac7bf3541eea467246d816a76f6b2b6a2e1e18a.tar.xz plus-eac7bf3541eea467246d816a76f6b2b6a2e1e18a.zip |
Move state handler STATE_CONNECT_SERVER into separate function.
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 142 |
1 files changed, 74 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) { |