diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-11-16 22:35:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-11-16 22:35:17 +0300 |
commit | b3d17866a3c5700b52c2b0b954fce132a52c1dbf (patch) | |
tree | 7ba07c98a1842eb766de35e172f559dcf5ac6fb4 | |
parent | 5e8e53f6e795a84ab5ca6cfe0d08672878044707 (diff) | |
download | mv-b3d17866a3c5700b52c2b0b954fce132a52c1dbf.tar.gz mv-b3d17866a3c5700b52c2b0b954fce132a52c1dbf.tar.bz2 mv-b3d17866a3c5700b52c2b0b954fce132a52c1dbf.tar.xz mv-b3d17866a3c5700b52c2b0b954fce132a52c1dbf.zip |
Convert State enum into strong typed.
35 files changed, 290 insertions, 293 deletions
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp index a665001ce..d7298587d 100644 --- a/src/being/playerinfo.cpp +++ b/src/being/playerinfo.cpp @@ -462,7 +462,7 @@ void gameDestroyed() void stateChange(const State state) { - if (state == STATE_GAME) + if (state == State::GAME) { if (!mInventory) { diff --git a/src/client.cpp b/src/client.cpp index f26ea5fd9..b37639375 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -188,7 +188,7 @@ namespace public: void action(const ActionEvent &) override final { - client->setState(STATE_CHAR_SELECT); + client->setState(State::CHAR_SELECT); } } accountListener; @@ -197,7 +197,7 @@ namespace public: void action(const ActionEvent &) override final { - client->setState(STATE_PRE_LOGIN); + client->setState(State::PRE_LOGIN); } } loginListener; } // namespace @@ -217,8 +217,8 @@ Client::Client() : #ifdef ANDROID mCloseButton(nullptr), #endif - mState(STATE_CHOOSE_SERVER), - mOldState(STATE_START), + mState(State::CHOOSE_SERVER), + mOldState(State::START), mSkin(nullptr), mButtonPadding(1), mButtonSpacing(3), @@ -436,8 +436,8 @@ void Client::gameInit() if (loginData.username.empty() && loginData.remember) loginData.username = serverConfig.getValue("username", ""); - if (mState != STATE_ERROR) - mState = STATE_CHOOSE_SERVER; + if (mState != State::ERROR) + mState = State::CHOOSE_SERVER; startTimers(); @@ -509,7 +509,7 @@ void Client::initSoundManager() } catch (const char *const err) { - mState = STATE_ERROR; + mState = State::ERROR; errorMessage = err; logger->log("Warning: %s", err); } @@ -717,7 +717,7 @@ void Client::stateConnectGame1() void Client::stateConnectServer1() { - if (mOldState == STATE_CHOOSE_SERVER) + if (mOldState == State::CHOOSE_SERVER) { settings.serverName = mCurrentServer.hostname; ConfigManager::initServerConfig(mCurrentServer.hostname); @@ -780,20 +780,20 @@ void Client::stateConnectServer1() config.write(); } } - else if (mOldState != STATE_CHOOSE_SERVER && + else if (mOldState != State::CHOOSE_SERVER && loginHandler && loginHandler->isConnected()) { - mState = STATE_PRE_LOGIN; + mState = State::PRE_LOGIN; } } void Client::stateWorldSelect1() { - if (mOldState == STATE_UPDATE && loginHandler) + if (mOldState == State::UPDATE && loginHandler) { if (loginHandler->getWorlds().size() < 2) - mState = STATE_PRE_LOGIN; + mState = State::PRE_LOGIN; } } @@ -840,7 +840,7 @@ void Client::stateGame1() void Client::stateSwitchLogin1() { - if (mOldState == STATE_GAME && gameHandler) + if (mOldState == State::GAME && gameHandler) gameHandler->disconnect(); } @@ -848,7 +848,7 @@ int Client::gameExec() { int lastTickTime = tick_time; - while (mState != STATE_EXIT) + while (mState != State::EXIT) { PROFILER_START(); if (eventsManager.handleEvents()) @@ -906,24 +906,24 @@ int Client::gameExec() BLOCK_END("~Client::SDL_framerateDelay") BLOCK_START("Client::gameExec 6") - if (mState == STATE_CONNECT_GAME) + if (mState == State::CONNECT_GAME) { stateConnectGame1(); } - else if (mState == STATE_CONNECT_SERVER) + else if (mState == State::CONNECT_SERVER) { stateConnectServer1(); } - else if (mState == STATE_WORLD_SELECT) + else if (mState == State::WORLD_SELECT) { stateWorldSelect1(); } - else if (mOldState == STATE_START || - (mOldState == STATE_GAME && mState != STATE_GAME)) + else if (mOldState == State::START || + (mOldState == State::GAME && mState != State::GAME)) { stateGame1(); } - else if (mState == STATE_SWITCH_LOGIN) + else if (mState == State::SWITCH_LOGIN) { stateSwitchLogin1(); } @@ -934,7 +934,7 @@ int Client::gameExec() BLOCK_START("Client::gameExec 7") PlayerInfo::stateChange(mState); - if (mOldState == STATE_GAME) + if (mOldState == State::GAME) { delete2(mGame); Game::clearInstance(); @@ -955,9 +955,9 @@ int Client::gameExec() if (!settings.options.skipUpdate) UpdaterWindow::unloadMods(settings.oldUpdates + "/fix/"); } - else if (mOldState == STATE_CHAR_SELECT) + else if (mOldState == State::CHAR_SELECT) { - if (mState != STATE_CHANGEPASSWORD && charServerHandler) + if (mState != State::CHANGEPASSWORD && charServerHandler) charServerHandler->clear(); } @@ -978,7 +978,7 @@ int Client::gameExec() BLOCK_START("Client::gameExec 8") switch (mState) { - case STATE_CHOOSE_SERVER: + case State::CHOOSE_SERVER: { BLOCK_START("Client::gameExec STATE_CHOOSE_SERVER") logger->log1("State: CHOOSE SERVER"); @@ -1036,7 +1036,7 @@ int Client::gameExec() } else { - mState = STATE_CONNECT_SERVER; + mState = State::CONNECT_SERVER; // Reset options so that cancelling or connect // timeout will show the server dialog. @@ -1047,24 +1047,24 @@ int Client::gameExec() break; } - case STATE_CONNECT_SERVER: - BLOCK_START("Client::gameExec STATE_CONNECT_SERVER") + case State::CONNECT_SERVER: + BLOCK_START("Client::gameExec State::CONNECT_SERVER") logger->log1("State: CONNECT SERVER"); loginData.updateHosts.clear(); CREATEWIDGETV(mCurrentDialog, ConnectionDialog, // TRANSLATORS: connection dialog header _("Connecting to server"), - STATE_SWITCH_SERVER); + State::SWITCH_SERVER); TranslationManager::loadCurrentLang(); - BLOCK_END("Client::gameExec STATE_CONNECT_SERVER") + BLOCK_END("Client::gameExec State::CONNECT_SERVER") break; - case STATE_PRE_LOGIN: + case State::PRE_LOGIN: logger->log1("State: PRE_LOGIN"); break; - case STATE_LOGIN: - BLOCK_START("Client::gameExec STATE_LOGIN") + case State::LOGIN: + BLOCK_START("Client::gameExec State::LOGIN") logger->log1("State: LOGIN"); // Don't allow an alpha opacity // lower than the default value @@ -1086,34 +1086,34 @@ int Client::gameExec() } else { - mState = STATE_LOGIN_ATTEMPT; + mState = State::LOGIN_ATTEMPT; // Clear the password so that when login fails, the // dialog will show up next time. settings.options.password.clear(); } - BLOCK_END("Client::gameExec STATE_LOGIN") + BLOCK_END("Client::gameExec State::LOGIN") break; - case STATE_LOGIN_ATTEMPT: - BLOCK_START("Client::gameExec STATE_LOGIN_ATTEMPT") + case State::LOGIN_ATTEMPT: + BLOCK_START("Client::gameExec State::LOGIN_ATTEMPT") logger->log1("State: LOGIN ATTEMPT"); CREATEWIDGETV(mCurrentDialog, ConnectionDialog, // TRANSLATORS: connection dialog header _("Logging in"), - STATE_SWITCH_SERVER); + State::SWITCH_SERVER); if (loginHandler) loginHandler->loginOrRegister(&loginData); - BLOCK_END("Client::gameExec STATE_LOGIN_ATTEMPT") + BLOCK_END("Client::gameExec State::LOGIN_ATTEMPT") break; - case STATE_WORLD_SELECT: - BLOCK_START("Client::gameExec STATE_WORLD_SELECT") + case State::WORLD_SELECT: + BLOCK_START("Client::gameExec State::WORLD_SELECT") logger->log1("State: WORLD SELECT"); { TranslationManager::loadCurrentLang(); if (!loginHandler) { - BLOCK_END("Client::gameExec STATE_WORLD_SELECT") + BLOCK_END("Client::gameExec State::WORLD_SELECT") break; } Worlds worlds = loginHandler->getWorlds(); @@ -1121,13 +1121,13 @@ int Client::gameExec() if (worlds.empty()) { // Trust that the netcode knows what it's doing - mState = STATE_UPDATE; + mState = State::UPDATE; } else if (worlds.size() == 1) { loginHandler->chooseServer( 0, mCurrentServer.persistentIp); - mState = STATE_UPDATE; + mState = State::UPDATE; } else { @@ -1140,21 +1140,21 @@ int Client::gameExec() } } } - BLOCK_END("Client::gameExec STATE_WORLD_SELECT") + BLOCK_END("Client::gameExec State::WORLD_SELECT") break; - case STATE_WORLD_SELECT_ATTEMPT: - BLOCK_START("Client::gameExec STATE_WORLD_SELECT_ATTEMPT") + case State::WORLD_SELECT_ATTEMPT: + BLOCK_START("Client::gameExec State::WORLD_SELECT_ATTEMPT") logger->log1("State: WORLD SELECT ATTEMPT"); CREATEWIDGETV(mCurrentDialog, ConnectionDialog, // TRANSLATORS: connection dialog header _("Entering game world"), - STATE_WORLD_SELECT); - BLOCK_END("Client::gameExec STATE_WORLD_SELECT_ATTEMPT") + State::WORLD_SELECT); + BLOCK_END("Client::gameExec State::WORLD_SELECT_ATTEMPT") break; - case STATE_UPDATE: - BLOCK_START("Client::gameExec STATE_UPDATE") + case State::UPDATE: + BLOCK_START("Client::gameExec State::UPDATE") logger->log1("State: UPDATE"); // Determine which source to use for the update host @@ -1169,7 +1169,7 @@ int Client::gameExec() if (settings.options.skipUpdate) { - mState = STATE_LOAD_DATA; + mState = State::LOAD_DATA; settings.oldUpdates.clear(); UpdaterWindow::loadDirMods(settings.options.dataPath); } @@ -1178,7 +1178,7 @@ int Client::gameExec() settings.oldUpdates = settings.localDataDir + dirSeparator + settings.updatesDir; UpdaterWindow::loadLocalUpdates(settings.oldUpdates); - mState = STATE_LOAD_DATA; + mState = State::LOAD_DATA; } else { @@ -1190,12 +1190,12 @@ int Client::gameExec() settings.options.dataPath.empty(), loginData.updateType); } - BLOCK_END("Client::gameExec STATE_UPDATE") + BLOCK_END("Client::gameExec State::UPDATE") break; - case STATE_LOAD_DATA: + case State::LOAD_DATA: { - BLOCK_START("Client::gameExec STATE_LOAD_DATA") + BLOCK_START("Client::gameExec State::LOAD_DATA") logger->log1("State: LOAD DATA"); // If another data path has been set, @@ -1273,24 +1273,24 @@ int Client::gameExec() if (desktop) desktop->reloadWallpaper(); - mState = STATE_GET_CHARACTERS; - BLOCK_END("Client::gameExec STATE_LOAD_DATA") + mState = State::GET_CHARACTERS; + BLOCK_END("Client::gameExec State::LOAD_DATA") break; } - case STATE_GET_CHARACTERS: - BLOCK_START("Client::gameExec STATE_GET_CHARACTERS") + case State::GET_CHARACTERS: + BLOCK_START("Client::gameExec State::GET_CHARACTERS") logger->log1("State: GET CHARACTERS"); CREATEWIDGETV(mCurrentDialog, ConnectionDialog, // TRANSLATORS: connection dialog header _("Requesting characters"), - STATE_SWITCH_SERVER); + State::SWITCH_SERVER); if (charServerHandler) charServerHandler->requestCharacters(); - BLOCK_END("Client::gameExec STATE_GET_CHARACTERS") + BLOCK_END("Client::gameExec State::GET_CHARACTERS") break; - case STATE_CHAR_SELECT: - BLOCK_START("Client::gameExec STATE_CHAR_SELECT") + case State::CHAR_SELECT: + BLOCK_START("Client::gameExec State::CHAR_SELECT") logger->log1("State: CHAR SELECT"); // Don't allow an alpha opacity // lower than the default value @@ -1314,35 +1314,35 @@ int Client::gameExec() // Choosing character on the command line should work only // once, clear it so that 'switch character' works. settings.options.character.clear(); - BLOCK_END("Client::gameExec STATE_CHAR_SELECT") + BLOCK_END("Client::gameExec State::CHAR_SELECT") break; - case STATE_CONNECT_GAME: - BLOCK_START("Client::gameExec STATE_CONNECT_GAME") + case State::CONNECT_GAME: + BLOCK_START("Client::gameExec State::CONNECT_GAME") logger->log1("State: CONNECT GAME"); CREATEWIDGETV(mCurrentDialog, ConnectionDialog, // TRANSLATORS: connection dialog header _("Connecting to the game server"), - STATE_CHOOSE_SERVER); + State::CHOOSE_SERVER); if (gameHandler) gameHandler->connect(); - BLOCK_END("Client::gameExec STATE_CONNECT_GAME") + BLOCK_END("Client::gameExec State::CONNECT_GAME") break; - case STATE_CHANGE_MAP: - BLOCK_START("Client::gameExec STATE_CHANGE_MAP") + case State::CHANGE_MAP: + BLOCK_START("Client::gameExec State::CHANGE_MAP") logger->log1("State: CHANGE_MAP"); CREATEWIDGETV(mCurrentDialog, ConnectionDialog, // TRANSLATORS: connection dialog header _("Changing game servers"), - STATE_SWITCH_CHARACTER); + State::SWITCH_CHARACTER); if (gameHandler) gameHandler->connect(); - BLOCK_END("Client::gameExec STATE_CHANGE_MAP") + BLOCK_END("Client::gameExec State::CHANGE_MAP") break; - case STATE_GAME: - BLOCK_START("Client::gameExec STATE_GAME") + case State::GAME: + BLOCK_START("Client::gameExec State::GAME") if (localPlayer) { logger->log("Memorizing selected character %s", @@ -1382,11 +1382,11 @@ int Client::gameExec() if (generalHandler) generalHandler->reloadPartially(); mGame = new Game; - BLOCK_END("Client::gameExec STATE_GAME") + BLOCK_END("Client::gameExec State::GAME") break; - case STATE_LOGIN_ERROR: - BLOCK_START("Client::gameExec STATE_LOGIN_ERROR") + case State::LOGIN_ERROR: + BLOCK_START("Client::gameExec State::LOGIN_ERROR") logger->log1("State: LOGIN ERROR"); CREATEWIDGETV(mCurrentDialog, OkDialog, // TRANSLATORS: error dialog header @@ -1401,11 +1401,11 @@ int Client::gameExec() 260); mCurrentDialog->addActionListener(&loginListener); mCurrentDialog = nullptr; // OkDialog deletes itself - BLOCK_END("Client::gameExec STATE_LOGIN_ERROR") + BLOCK_END("Client::gameExec State::LOGIN_ERROR") break; - case STATE_ACCOUNTCHANGE_ERROR: - BLOCK_START("Client::gameExec STATE_ACCOUNTCHANGE_ERROR") + case State::ACCOUNTCHANGE_ERROR: + BLOCK_START("Client::gameExec State::ACCOUNTCHANGE_ERROR") logger->log1("State: ACCOUNT CHANGE ERROR"); CREATEWIDGETV(mCurrentDialog, OkDialog, // TRANSLATORS: error dialog header @@ -1420,58 +1420,58 @@ int Client::gameExec() 260); mCurrentDialog->addActionListener(&accountListener); mCurrentDialog = nullptr; // OkDialog deletes itself - BLOCK_END("Client::gameExec STATE_ACCOUNTCHANGE_ERROR") + BLOCK_END("Client::gameExec State::ACCOUNTCHANGE_ERROR") break; - case STATE_REGISTER_PREP: - BLOCK_START("Client::gameExec STATE_REGISTER_PREP") + case State::REGISTER_PREP: + BLOCK_START("Client::gameExec State::REGISTER_PREP") logger->log1("State: REGISTER_PREP"); CREATEWIDGETV(mCurrentDialog, ConnectionDialog, // TRANSLATORS: connection dialog header _("Requesting registration details"), - STATE_LOGIN); + State::LOGIN); loginHandler->getRegistrationDetails(); - BLOCK_END("Client::gameExec STATE_REGISTER_PREP") + BLOCK_END("Client::gameExec State::REGISTER_PREP") break; - case STATE_REGISTER: + case State::REGISTER: logger->log1("State: REGISTER"); CREATEWIDGETV(mCurrentDialog, RegisterDialog, loginData); break; - case STATE_REGISTER_ATTEMPT: - BLOCK_START("Client::gameExec STATE_REGISTER_ATTEMPT") + case State::REGISTER_ATTEMPT: + BLOCK_START("Client::gameExec State::REGISTER_ATTEMPT") logger->log("Username is %s", loginData.username.c_str()); if (loginHandler) loginHandler->registerAccount(&loginData); - BLOCK_END("Client::gameExec STATE_REGISTER_ATTEMPT") + BLOCK_END("Client::gameExec State::REGISTER_ATTEMPT") break; - case STATE_CHANGEPASSWORD: - BLOCK_START("Client::gameExec STATE_CHANGEPASSWORD") + case State::CHANGEPASSWORD: + BLOCK_START("Client::gameExec State::CHANGEPASSWORD") logger->log1("State: CHANGE PASSWORD"); CREATEWIDGETV(mCurrentDialog, ChangePasswordDialog, loginData); mCurrentDialog->setVisible(Visible_true); - BLOCK_END("Client::gameExec STATE_CHANGEPASSWORD") + BLOCK_END("Client::gameExec State::CHANGEPASSWORD") break; - case STATE_CHANGEPASSWORD_ATTEMPT: + case State::CHANGEPASSWORD_ATTEMPT: BLOCK_START("Client::gameExec " - "STATE_CHANGEPASSWORD_ATTEMPT") + "State::CHANGEPASSWORD_ATTEMPT") logger->log1("State: CHANGE PASSWORD ATTEMPT"); if (loginHandler) { loginHandler->changePassword(loginData.password, loginData.newPassword); } - BLOCK_END("Client::gameExec STATE_CHANGEPASSWORD_ATTEMPT") + BLOCK_END("Client::gameExec State::CHANGEPASSWORD_ATTEMPT") break; - case STATE_CHANGEPASSWORD_SUCCESS: + case State::CHANGEPASSWORD_SUCCESS: BLOCK_START("Client::gameExec " - "STATE_CHANGEPASSWORD_SUCCESS") + "State::CHANGEPASSWORD_SUCCESS") logger->log1("State: CHANGE PASSWORD SUCCESS"); CREATEWIDGETV(mCurrentDialog, OkDialog, // TRANSLATORS: password change message header @@ -1489,23 +1489,23 @@ int Client::gameExec() mCurrentDialog = nullptr; // OkDialog deletes itself loginData.password = loginData.newPassword; loginData.newPassword.clear(); - BLOCK_END("Client::gameExec STATE_CHANGEPASSWORD_SUCCESS") + BLOCK_END("Client::gameExec State::CHANGEPASSWORD_SUCCESS") break; - case STATE_CHANGEEMAIL: + case State::CHANGEEMAIL: logger->log1("State: CHANGE EMAIL"); CREATEWIDGETV(mCurrentDialog, ChangeEmailDialog, loginData); mCurrentDialog->setVisible(Visible_true); break; - case STATE_CHANGEEMAIL_ATTEMPT: + case State::CHANGEEMAIL_ATTEMPT: logger->log1("State: CHANGE EMAIL ATTEMPT"); if (loginHandler) loginHandler->changeEmail(loginData.email); break; - case STATE_CHANGEEMAIL_SUCCESS: + case State::CHANGEEMAIL_SUCCESS: logger->log1("State: CHANGE EMAIL SUCCESS"); CREATEWIDGETV(mCurrentDialog, OkDialog, // TRANSLATORS: email change message header @@ -1523,13 +1523,13 @@ int Client::gameExec() mCurrentDialog = nullptr; // OkDialog deletes itself break; - case STATE_UNREGISTER: + case State::UNREGISTER: logger->log1("State: UNREGISTER"); CREATEWIDGETV(mCurrentDialog, UnRegisterDialog, loginData); break; - case STATE_UNREGISTER_ATTEMPT: + case State::UNREGISTER_ATTEMPT: logger->log1("State: UNREGISTER ATTEMPT"); if (loginHandler) { @@ -1538,7 +1538,7 @@ int Client::gameExec() } break; - case STATE_UNREGISTER_SUCCESS: + case State::UNREGISTER_SUCCESS: logger->log1("State: UNREGISTER SUCCESS"); if (loginHandler) loginHandler->disconnect(); @@ -1550,13 +1550,13 @@ int Client::gameExec() _("Farewell, come back any time..."), Modal_true); loginData.clear(); - // The errorlistener sets the state to STATE_CHOOSE_SERVER + // The errorlistener sets the state to State::CHOOSE_SERVER mCurrentDialog->addActionListener(&errorListener); mCurrentDialog = nullptr; // OkDialog deletes itself break; - case STATE_SWITCH_SERVER: - BLOCK_START("Client::gameExec STATE_SWITCH_SERVER") + case State::SWITCH_SERVER: + BLOCK_START("Client::gameExec State::SWITCH_SERVER") logger->log1("State: SWITCH SERVER"); if (loginHandler) @@ -1572,12 +1572,12 @@ int Client::gameExec() if (setupWindow) setupWindow->externalUnload(); - mState = STATE_CHOOSE_SERVER; - BLOCK_END("Client::gameExec STATE_SWITCH_SERVER") + mState = State::CHOOSE_SERVER; + BLOCK_END("Client::gameExec State::SWITCH_SERVER") break; - case STATE_SWITCH_LOGIN: - BLOCK_START("Client::gameExec STATE_SWITCH_LOGIN") + case State::SWITCH_LOGIN: + BLOCK_START("Client::gameExec State::SWITCH_LOGIN") logger->log1("State: SWITCH LOGIN"); if (loginHandler) @@ -1590,50 +1590,50 @@ int Client::gameExec() if (loginHandler) loginHandler->connect(); - mState = STATE_LOGIN; - BLOCK_END("Client::gameExec STATE_SWITCH_LOGIN") + mState = State::LOGIN; + BLOCK_END("Client::gameExec State::SWITCH_LOGIN") break; - case STATE_SWITCH_CHARACTER: - BLOCK_START("Client::gameExec STATE_SWITCH_CHARACTER") + case State::SWITCH_CHARACTER: + BLOCK_START("Client::gameExec State::SWITCH_CHARACTER") logger->log1("State: SWITCH CHARACTER"); // Done with game if (gameHandler) gameHandler->disconnect(); - mState = STATE_GET_CHARACTERS; - BLOCK_END("Client::gameExec STATE_SWITCH_CHARACTER") + mState = State::GET_CHARACTERS; + BLOCK_END("Client::gameExec State::SWITCH_CHARACTER") break; - case STATE_LOGOUT_ATTEMPT: + case State::LOGOUT_ATTEMPT: logger->log1("State: LOGOUT ATTEMPT"); break; - case STATE_WAIT: + case State::WAIT: logger->log1("State: WAIT"); break; - case STATE_EXIT: - BLOCK_START("Client::gameExec STATE_EXIT") + case State::EXIT: + BLOCK_START("Client::gameExec State::EXIT") logger->log1("State: EXIT"); Net::unload(); - BLOCK_END("Client::gameExec STATE_EXIT") + BLOCK_END("Client::gameExec State::EXIT") break; - case STATE_FORCE_QUIT: - BLOCK_START("Client::gameExec STATE_FORCE_QUIT") + case State::FORCE_QUIT: + BLOCK_START("Client::gameExec State::FORCE_QUIT") logger->log1("State: FORCE QUIT"); if (generalHandler) generalHandler->unload(); - mState = STATE_EXIT; - BLOCK_END("Client::gameExec STATE_FORCE_QUIT") + mState = State::EXIT; + BLOCK_END("Client::gameExec State::FORCE_QUIT") break; - case STATE_ERROR: - BLOCK_START("Client::gameExec STATE_ERROR") + case State::ERROR: + BLOCK_START("Client::gameExec State::ERROR") config.write(); - if (mOldState == STATE_GAME) + if (mOldState == State::GAME) serverConfig.write(); logger->log1("State: ERROR"); logger->log("Error: %s\n", errorMessage.c_str()); @@ -1645,16 +1645,16 @@ int Client::gameExec() mCurrentDialog->addActionListener(&errorListener); mCurrentDialog = nullptr; // OkDialog deletes itself gameHandler->disconnect(); - BLOCK_END("Client::gameExec STATE_ERROR") + BLOCK_END("Client::gameExec State::ERROR") break; - case STATE_AUTORECONNECT_SERVER: + case State::AUTORECONNECT_SERVER: // ++++++ break; - case STATE_START: + case State::START: default: - mState = STATE_FORCE_QUIT; + mState = State::FORCE_QUIT; break; } BLOCK_END("Client::gameExec 8") @@ -1705,7 +1705,7 @@ void Client::action(const ActionEvent &event) if (eventId == "close") { - setState(STATE_FORCE_QUIT); + setState(State::FORCE_QUIT); return; } if (eventId == "Setup") @@ -1855,16 +1855,16 @@ void Client::slowLogic() if (get_elapsed_time1(mPing) > 1500) { mPing = tick_time; - if (mState == STATE_UPDATE || - mState == STATE_LOGIN || - mState == STATE_LOGIN_ATTEMPT) + if (mState == State::UPDATE || + mState == State::LOGIN || + mState == State::LOGIN_ATTEMPT) { if (loginHandler) loginHandler->ping(); if (generalHandler) generalHandler->flushSend(); } - else if (mState == STATE_CHAR_SELECT) + else if (mState == State::CHAR_SELECT) { if (charServerHandler) charServerHandler->ping(); diff --git a/src/dirs.cpp b/src/dirs.cpp index 4e9c5fbd9..051c00c40 100644 --- a/src/dirs.cpp +++ b/src/dirs.cpp @@ -462,7 +462,7 @@ void Dirs::initUpdatesDir() // TRANSLATORS: update server initialisation error errorMessage = strprintf(_("Invalid update host: %s."), settings.updateHost.c_str()); - client->setState(STATE_ERROR); + client->setState(State::ERROR); } } else @@ -502,14 +502,14 @@ void Dirs::initUpdatesDir() newDir.c_str()); // TRANSLATORS: update server initialisation error errorMessage = _("Error creating updates directory!"); - client->setState(STATE_ERROR); + client->setState(State::ERROR); } #else logger->log("Error: %s/%s can't be made, but doesn't exist!", settings.localDataDir.c_str(), settings.updatesDir.c_str()); // TRANSLATORS: update server initialisation error errorMessage = _("Error creating updates directory!"); - client->setState(STATE_ERROR); + client->setState(State::ERROR); #endif } } diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp index 91a2cbe88..fcd978d12 100644 --- a/src/dyetool/client.cpp +++ b/src/dyetool/client.cpp @@ -113,8 +113,8 @@ Client::Client() : #ifdef ANDROID mCloseButton(nullptr), #endif - mState(STATE_GAME), - mOldState(STATE_START), + mState(State::GAME), + mOldState(State::START), mSkin(nullptr), mButtonPadding(1), mButtonSpacing(3) @@ -286,8 +286,8 @@ void Client::gameInit() if (joystick) joystick->update(); -// if (mState != STATE_ERROR) -// mState = STATE_CHOOSE_SERVER; +// if (mState != State::ERROR) +// mState = State::CHOOSE_SERVER; startTimers(); @@ -336,7 +336,7 @@ void Client::initSoundManager() } catch (const char *const err) { - mState = STATE_ERROR; + mState = State::ERROR; errorMessage = err; logger->log("Warning: %s", err); } @@ -497,7 +497,7 @@ int Client::gameExec() { int lastTickTime = tick_time; - while (mState != STATE_EXIT) + while (mState != State::EXIT) { PROFILER_START(); if (eventsManager.handleEvents()) @@ -551,7 +551,7 @@ int Client::gameExec() BLOCK_END("~Client::SDL_framerateDelay") BLOCK_START("Client::gameExec 6") -// if (mState == STATE_CONNECT_GAME) +// if (mState == State::CONNECT_GAME) // { // stateConnectGame1(); // } @@ -578,13 +578,13 @@ int Client::gameExec() BLOCK_START("Client::gameExec 8") switch (mState) { - case STATE_GAME: + case State::GAME: stateGame(); break; - case STATE_LOAD_DATA: + case State::LOAD_DATA: { - BLOCK_START("Client::gameExec STATE_LOAD_DATA") + BLOCK_START("Client::gameExec State::LOAD_DATA") logger->log1("State: LOAD DATA"); // If another data path has been set, @@ -618,13 +618,13 @@ int Client::gameExec() if (desktop) desktop->reloadWallpaper(); - mState = STATE_GET_CHARACTERS; - BLOCK_END("Client::gameExec STATE_LOAD_DATA") + mState = State::GET_CHARACTERS; + BLOCK_END("Client::gameExec State::LOAD_DATA") break; } - case STATE_START: + case State::START: default: - mState = STATE_FORCE_QUIT; + mState = State::FORCE_QUIT; break; } BLOCK_END("Client::gameExec 8") @@ -642,7 +642,7 @@ void Client::action(const ActionEvent &event) if (eventId == "close") { - setState(STATE_FORCE_QUIT); + setState(State::FORCE_QUIT); return; } if (eventId == "Setup") diff --git a/src/enums/state.h b/src/enums/state.h index ed16cf4f2..581f6a352 100644 --- a/src/enums/state.h +++ b/src/enums/state.h @@ -23,49 +23,49 @@ #ifndef ENUMS_STATE_H #define ENUMS_STATE_H -/** - * All client states. - */ -enum State +#include "enums/simpletypes/enumdefines.h" + +enumStart(State) { - STATE_ERROR = -1, - STATE_START = 0, - STATE_CHOOSE_SERVER, - STATE_CONNECT_SERVER, - STATE_PRE_LOGIN, - STATE_LOGIN, - STATE_LOGIN_ATTEMPT, - STATE_WORLD_SELECT, // 5 - STATE_WORLD_SELECT_ATTEMPT, - STATE_UPDATE, - STATE_LOAD_DATA, - STATE_GET_CHARACTERS, - STATE_CHAR_SELECT, // 10 - STATE_CONNECT_GAME, - STATE_GAME, - STATE_CHANGE_MAP, // Switch map-server/gameserver - STATE_LOGIN_ERROR, - STATE_ACCOUNTCHANGE_ERROR, // 15 - STATE_REGISTER_PREP, - STATE_REGISTER, - STATE_REGISTER_ATTEMPT, - STATE_CHANGEPASSWORD, - STATE_CHANGEPASSWORD_ATTEMPT, // 20 - STATE_CHANGEPASSWORD_SUCCESS, - STATE_CHANGEEMAIL, - STATE_CHANGEEMAIL_ATTEMPT, - STATE_CHANGEEMAIL_SUCCESS, - STATE_UNREGISTER, // 25 - STATE_UNREGISTER_ATTEMPT, - STATE_UNREGISTER_SUCCESS, - STATE_SWITCH_SERVER, - STATE_SWITCH_LOGIN, - STATE_SWITCH_CHARACTER, // 30 - STATE_LOGOUT_ATTEMPT, - STATE_WAIT, - STATE_EXIT, - STATE_FORCE_QUIT, - STATE_AUTORECONNECT_SERVER = 1000 -}; + ERROR = -1, + START = 0, + CHOOSE_SERVER, + CONNECT_SERVER, + PRE_LOGIN, + LOGIN, + LOGIN_ATTEMPT, + WORLD_SELECT, // 5 + WORLD_SELECT_ATTEMPT, + UPDATE, + LOAD_DATA, + GET_CHARACTERS, + CHAR_SELECT, // 10 + CONNECT_GAME, + GAME, + CHANGE_MAP, // Switch map-server/gameserver + LOGIN_ERROR, + ACCOUNTCHANGE_ERROR, // 15 + REGISTER_PREP, + REGISTER, + REGISTER_ATTEMPT, + CHANGEPASSWORD, + CHANGEPASSWORD_ATTEMPT, // 20 + CHANGEPASSWORD_SUCCESS, + CHANGEEMAIL, + CHANGEEMAIL_ATTEMPT, + CHANGEEMAIL_SUCCESS, + UNREGISTER, // 25 + UNREGISTER_ATTEMPT, + UNREGISTER_SUCCESS, + SWITCH_SERVER, + SWITCH_LOGIN, + SWITCH_CHARACTER, // 30 + LOGOUT_ATTEMPT, + WAIT, + EXIT, + FORCE_QUIT, + AUTORECONNECT_SERVER = 1000 +} +enumEnd(State); #endif // ENUMS_STATE_H diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp index 3125e398b..157860515 100644 --- a/src/eventsmanager.cpp +++ b/src/eventsmanager.cpp @@ -78,7 +78,7 @@ bool EventsManager::handleCommonEvents(const SDL_Event &event) const switch (event.type) { case SDL_QUIT: - client->setState(STATE_EXIT); + client->setState(State::EXIT); logger->log1("force exit"); BLOCK_END("EventsManager::handleCommonEvents") return true; @@ -147,7 +147,7 @@ bool EventsManager::handleEvents() const if ((event.active.state & SDL_APPACTIVE) && !event.active.gain) { - client->setState(STATE_EXIT); + client->setState(State::EXIT); logger->log1("exit on lost focus"); } break; @@ -170,7 +170,7 @@ bool EventsManager::handleEvents() const } #endif } - if (client->getState() == STATE_EXIT) + if (client->getState() == State::EXIT) { BLOCK_END("EventsManager::handleEvents") return true; @@ -431,7 +431,7 @@ void EventsManager::handleSDL2WindowEvent(const SDL_Event &event) int fpsLimit = 0; #endif const int eventType = event.window.event; - const bool inGame = (client->getState() == STATE_GAME); + const bool inGame = (client->getState() == State::GAME); switch (eventType) { case SDL_WINDOWEVENT_RESIZED: @@ -507,7 +507,7 @@ void EventsManager::handleActive(const SDL_Event &event) { #ifndef DYECMD int fpsLimit = 0; - const bool inGame = (client->getState() == STATE_GAME); + const bool inGame = (client->getState() == State::GAME); #endif if (event.active.state & SDL_APPACTIVE) { @@ -527,7 +527,7 @@ void EventsManager::handleActive(const SDL_Event &event) else { // window minimization #ifdef ANDROID - client->setState(STATE_EXIT); + client->setState(State::EXIT); #else WindowManager::setIsMinimized(true); #ifndef DYECMD diff --git a/src/game.cpp b/src/game.cpp index 776dd8621..df1527a14 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -437,7 +437,7 @@ Game::~Game() AnimatedSprite::setEnableCache(false); delete2(actorManager) - if (client->getState() != STATE_CHANGE_MAP) + if (client->getState() != State::CHANGE_MAP) delete2(localPlayer) if (effectManager) effectManager->clear(); @@ -647,10 +647,10 @@ void Game::slowLogic() // Handle network stuff if (!gameHandler->isConnected()) { - if (client->getState() == STATE_CHANGE_MAP) + if (client->getState() == State::CHANGE_MAP) return; // Not a problem here - if (client->getState() != STATE_ERROR) + if (client->getState() != State::ERROR) { if (!disconnectedDialog) { @@ -670,15 +670,12 @@ void Game::slowLogic() { const Map *const map = viewport->getMap(); if (map) - { - logger->log("state: %d", client->getState()); map->saveExtraLayer(); - } } DialogsManager::closeDialogs(); WindowManager::setFramerate(config.getIntValue("fpslimit")); mNextAdjustTime = cur_time + adjustDelay; - if (client->getState() != STATE_ERROR) + if (client->getState() != State::ERROR) errorMessage.clear(); } else diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp index 1e069e6eb..c4ae533e2 100644 --- a/src/gui/windows/changeemaildialog.cpp +++ b/src/gui/windows/changeemaildialog.cpp @@ -114,7 +114,7 @@ void ChangeEmailDialog::action(const ActionEvent &event) const std::string &eventId = event.getId(); if (eventId == "cancel") { - client->setState(STATE_CHAR_SELECT); + client->setState(State::CHAR_SELECT); } else if (eventId == "change_email") { @@ -180,7 +180,7 @@ void ChangeEmailDialog::action(const ActionEvent &event) mChangeEmailButton->setEnabled(false); // Set the new email address mLoginData->email = newFirstEmail; - client->setState(STATE_CHANGEEMAIL_ATTEMPT); + client->setState(State::CHANGEEMAIL_ATTEMPT); } } } diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp index 051448e6f..e0750b8bf 100644 --- a/src/gui/windows/changepassworddialog.cpp +++ b/src/gui/windows/changepassworddialog.cpp @@ -93,7 +93,7 @@ void ChangePasswordDialog::action(const ActionEvent &event) const std::string &eventId = event.getId(); if (eventId == "cancel") { - client->setState(STATE_CHAR_SELECT); + client->setState(State::CHAR_SELECT); } else if (eventId == "change_password") { @@ -171,7 +171,7 @@ void ChangePasswordDialog::action(const ActionEvent &event) // Set the new password mLoginData->password = oldPassword; mLoginData->newPassword = newFirstPass; - client->setState(STATE_CHANGEPASSWORD_ATTEMPT); + client->setState(State::CHANGEPASSWORD_ATTEMPT); } } } diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index ca15caf97..8f7c44d66 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -268,16 +268,16 @@ void CharSelectDialog::action(const ActionEvent &event) } else if (eventId == "change_password") { - client->setState(STATE_CHANGEPASSWORD); + client->setState(State::CHANGEPASSWORD); } else if (eventId == "change_email") { - client->setState(STATE_CHANGEEMAIL); + client->setState(State::CHANGEEMAIL); } else if (eventId == "unregister") { charServerHandler->clear(); - client->setState(STATE_UNREGISTER); + client->setState(State::UNREGISTER); } else if (eventId == "try delete character") { @@ -572,7 +572,7 @@ bool CharSelectDialog::selectByName(const std::string &name, void CharSelectDialog::close() { - client->setState(STATE_SWITCH_LOGIN); + client->setState(State::SWITCH_LOGIN); Window::close(); } diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 93bf10bc3..aebe962cb 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -216,7 +216,7 @@ void LoginDialog::action(const ActionEvent &event) { prepareUpdate(); mLoginData->registerLogin = false; - client->setState(STATE_LOGIN_ATTEMPT); + client->setState(State::LOGIN_ATTEMPT); } else if (eventId == "server") { @@ -227,7 +227,7 @@ void LoginDialog::action(const ActionEvent &event) if (loginHandler->isRegistrationEnabled()) { prepareUpdate(); - client->setState(STATE_REGISTER_PREP); + client->setState(State::REGISTER_PREP); } else if (!mLoginData->registerUrl.empty()) { @@ -283,7 +283,7 @@ bool LoginDialog::canSubmit() const { return !mUserField->getText().empty() && !mPassField->getText().empty() && - client->getState() == STATE_LOGIN; + client->getState() == State::LOGIN; } void LoginDialog::prepareUpdate() @@ -354,6 +354,6 @@ void LoginDialog::prepareUpdate() void LoginDialog::close() { - client->setState(STATE_SWITCH_SERVER); + client->setState(State::SWITCH_SERVER); Window::close(); } diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp index 9c5a2dee1..1f876e731 100644 --- a/src/gui/windows/quitdialog.cpp +++ b/src/gui/windows/quitdialog.cpp @@ -73,10 +73,10 @@ QuitDialog::QuitDialog(QuitDialog **const pointerToMe) : ContainerPlacer placer = getPlacer(0, 0); const State state = client->getState(); - mNeedForceQuit = (state == STATE_CHOOSE_SERVER - || state == STATE_CONNECT_SERVER || state == STATE_LOGIN - || state == STATE_PRE_LOGIN || state == STATE_LOGIN_ATTEMPT - || state == STATE_UPDATE || state == STATE_LOAD_DATA); + mNeedForceQuit = (state == State::CHOOSE_SERVER + || state == State::CONNECT_SERVER || state == State::LOGIN + || state == State::PRE_LOGIN || state == State::LOGIN_ATTEMPT + || state == State::UPDATE || state == State::LOAD_DATA); // All states, when we're not logged in to someone. if (mNeedForceQuit) @@ -90,7 +90,7 @@ QuitDialog::QuitDialog(QuitDialog **const pointerToMe) : placeOption(placer, mSwitchAccountServer); // Only added if we are connected to a gameserver - if (state == STATE_GAME) + if (state == State::GAME) placeOption(placer, mSwitchCharacter); } @@ -157,12 +157,12 @@ void QuitDialog::action(const ActionEvent &event) if (mForceQuit->isSelected()) { - client->setState(STATE_FORCE_QUIT); + client->setState(State::FORCE_QUIT); } else if (mLogoutQuit->isSelected()) { DialogsManager::closeDialogs(); - client->setState(STATE_EXIT); + client->setState(State::EXIT); } else if (mRate && mRate->isSelected()) { @@ -171,23 +171,23 @@ void QuitDialog::action(const ActionEvent &event) config.setValue("rated", true); if (mNeedForceQuit) { - client->setState(STATE_FORCE_QUIT); + client->setState(State::FORCE_QUIT); } else { DialogsManager::closeDialogs(); - client->setState(STATE_EXIT); + client->setState(State::EXIT); } } else if (gameHandler->isConnected() && mSwitchAccountServer->isSelected()) { DialogsManager::closeDialogs(); - client->setState(STATE_SWITCH_SERVER); + client->setState(State::SWITCH_SERVER); } else if (mSwitchCharacter->isSelected()) { - if (client->getState() == STATE_GAME) + if (client->getState() == State::GAME) { charServerHandler->switchCharacter(); DialogsManager::closeDialogs(); diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index 373a0f118..4c19ce01d 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -286,7 +286,7 @@ void RegisterDialog::action(const ActionEvent &event) mLoginData->email = mEmailField->getText(); mLoginData->registerLogin = true; - client->setState(STATE_REGISTER_ATTEMPT); + client->setState(State::REGISTER_ATTEMPT); } } } @@ -319,12 +319,12 @@ bool RegisterDialog::canSubmit() const return !mUserField->getText().empty() && !mPasswordField->getText().empty() && !mConfirmField->getText().empty() && - client->getState() == STATE_REGISTER && + client->getState() == State::REGISTER && (!mEmailField || !mEmailField->getText().empty()); } void RegisterDialog::close() { - client->setState(STATE_LOGIN); + client->setState(State::LOGIN); Window::close(); } diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 135172f35..e35c3c8de 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -214,7 +214,7 @@ ServerDialog::~ServerDialog() void ServerDialog::connectToSelectedServer() { - if (client->getState() == STATE_CONNECT_SERVER) + if (client->getState() == State::CONNECT_SERVER) return; const int index = mServersList->getSelected(); @@ -263,7 +263,7 @@ void ServerDialog::connectToSelectedServer() config.setValue("usePersistentIP", mPersistentIPCheckBox->isSelected()); - client->setState(STATE_CONNECT_SERVER); + client->setState(State::CONNECT_SERVER); } void ServerDialog::action(const ActionEvent &event) @@ -314,7 +314,7 @@ void ServerDialog::keyPressed(KeyEvent &event) { case InputAction::GUI_CANCEL: event.consume(); - client->setState(STATE_EXIT); + client->setState(State::EXIT); return; case InputAction::GUI_SELECT: @@ -770,6 +770,6 @@ void ServerDialog::close() { if (mDownload) mDownload->cancel(); - client->setState(STATE_FORCE_QUIT); + client->setState(State::FORCE_QUIT); Window::close(); } diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp index 80a02a952..69a3d2310 100644 --- a/src/gui/windows/unregisterdialog.cpp +++ b/src/gui/windows/unregisterdialog.cpp @@ -107,7 +107,7 @@ void UnRegisterDialog::action(const ActionEvent &event) const std::string &eventId = event.getId(); if (eventId == "cancel") { - client->setState(STATE_CHAR_SELECT); + client->setState(State::CHAR_SELECT); } else if (eventId == "unregister") { @@ -159,7 +159,7 @@ void UnRegisterDialog::action(const ActionEvent &event) // No errors detected, unregister the new user. mUnRegisterButton->setEnabled(false); mLoginData->password = password; - client->setState(STATE_UNREGISTER_ATTEMPT); + client->setState(State::UNREGISTER_ATTEMPT); } } } diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 79dfe29aa..784fd2ad5 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -291,10 +291,10 @@ void UpdaterWindow::enable() mPlayButton->setEnabled(true); mPlayButton->requestFocus(); - if (client->getState() != STATE_GAME) + if (client->getState() != State::GAME) { if (mUpdateType & UpdateType::Close) - client->setState(STATE_LOAD_DATA); + client->setState(State::LOAD_DATA); } else { @@ -318,8 +318,8 @@ void UpdaterWindow::action(const ActionEvent &event) } else if (eventId == "play") { - if (client->getState() != STATE_GAME) - client->setState(STATE_LOAD_DATA); + if (client->getState() != State::GAME) + client->setState(State::LOAD_DATA); else deleteSelf(); } @@ -331,8 +331,8 @@ void UpdaterWindow::keyPressed(KeyEvent &event) if (actionId == InputAction::GUI_CANCEL) { action(ActionEvent(nullptr, mCancelButton->getActionEventId())); - if (client->getState() != STATE_GAME) - client->setState(STATE_LOGIN); + if (client->getState() != State::GAME) + client->setState(State::LOGIN); else deleteSelf(); } @@ -534,8 +534,8 @@ int UpdaterWindow::updateProgress(void *ptr, uw->setProgress(progress); - if ((client->getState() != STATE_UPDATE - && client->getState() != STATE_GAME) + if ((client->getState() != State::UPDATE + && client->getState() != State::GAME) || uw->mDownloadStatus == UPDATE_ERROR) { // If the action was canceled return an error code to stop the mThread diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 58078dfbc..2a20c9a02 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -107,12 +107,12 @@ void WorldSelectDialog::action(const ActionEvent &event) settings.persistentIp); // Check in case netcode moves us forward - if (client->getState() == STATE_WORLD_SELECT) - client->setState(STATE_WORLD_SELECT_ATTEMPT); + if (client->getState() == State::WORLD_SELECT) + client->setState(State::WORLD_SELECT_ATTEMPT); } else if (eventId == "login") { - client->setState(STATE_PRE_LOGIN); + client->setState(State::PRE_LOGIN); } } diff --git a/src/listeners/errorlistener.cpp b/src/listeners/errorlistener.cpp index 61d688231..e683fd206 100644 --- a/src/listeners/errorlistener.cpp +++ b/src/listeners/errorlistener.cpp @@ -35,5 +35,5 @@ void ErrorListener::action(const ActionEvent &event) { if (event.getId() == "yes") openBrowser(settings.supportUrl); - client->setState(STATE_CHOOSE_SERVER); + client->setState(State::CHOOSE_SERVER); } diff --git a/src/net/ea/charserverrecv.cpp b/src/net/ea/charserverrecv.cpp index 7b04c05b0..e3b0a0ffd 100644 --- a/src/net/ea/charserverrecv.cpp +++ b/src/net/ea/charserverrecv.cpp @@ -59,7 +59,7 @@ void CharServerRecv::processCharLoginError(Net::MessageIn &msg) errorMessage = _("Unknown char-server failure."); break; } - client->setState(STATE_ERROR); + client->setState(State::ERROR); BLOCK_END("CharServerRecv::processCharLoginError") } diff --git a/src/net/ea/gamerecv.cpp b/src/net/ea/gamerecv.cpp index 3a85e54a9..8689345e9 100644 --- a/src/net/ea/gamerecv.cpp +++ b/src/net/ea/gamerecv.cpp @@ -55,7 +55,7 @@ void GameRecv::processWhoAnswer(Net::MessageIn &msg) void GameRecv::processCharSwitchResponse(Net::MessageIn &msg) { if (msg.readUInt8("response")) - client->setState(STATE_SWITCH_CHARACTER); + client->setState(State::SWITCH_CHARACTER); } void GameRecv::processMapQuitResponse(Net::MessageIn &msg) diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index bf3621c53..581cb6713 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -61,7 +61,7 @@ bool LoginHandler::isRegistrationEnabled() const void LoginHandler::getRegistrationDetails() const { // Not supported, so move on - client->setState(STATE_REGISTER); + client->setState(State::REGISTER); } void LoginHandler::loginAccount(LoginData *const loginData1) const @@ -97,7 +97,7 @@ void LoginHandler::chooseServer(const unsigned int server, charServer->port = LoginRecv::mWorlds[server]->port; } - client->setState(STATE_UPDATE); + client->setState(State::UPDATE); } void LoginHandler::registerAccount(const LoginData *const loginData1) const diff --git a/src/net/ea/loginrecv.cpp b/src/net/ea/loginrecv.cpp index 37cc96b8b..7a0cff90b 100644 --- a/src/net/ea/loginrecv.cpp +++ b/src/net/ea/loginrecv.cpp @@ -103,7 +103,7 @@ void LoginRecv::processLoginData(Net::MessageIn &msg) mWorlds.push_back(world); } - client->setState(STATE_WORLD_SELECT); + client->setState(State::WORLD_SELECT); } void LoginRecv::processLoginError(Net::MessageIn &msg) @@ -171,7 +171,7 @@ void LoginRecv::processLoginError(Net::MessageIn &msg) errorMessage = _("Unknown error."); break; } - client->setState(STATE_ERROR); + client->setState(State::ERROR); } } // namespace Ea diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp index aed472207..d09d98768 100644 --- a/src/net/eathena/charserverrecv.cpp +++ b/src/net/eathena/charserverrecv.cpp @@ -200,7 +200,7 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg) } } - client->setState(STATE_CHAR_SELECT); + client->setState(State::CHAR_SELECT); } void CharServerRecv::processCharLogin2(Net::MessageIn &msg) @@ -247,7 +247,7 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg) if (network) network->disconnect(); - client->setState(STATE_CONNECT_GAME); + client->setState(State::CONNECT_GAME); BLOCK_END("CharServerRecv::processCharMapInfo") } @@ -277,7 +277,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) server.port = msg.readInt16("port"); network->disconnect(); - client->setState(STATE_CHANGE_MAP); + client->setState(State::CHANGE_MAP); if (localPlayer) { localPlayer->setTileCoords(x, y); @@ -499,7 +499,7 @@ void CharServerRecv::processCharCharacters(Net::MessageIn &msg) } } - client->setState(STATE_CHAR_SELECT); + client->setState(State::CHAR_SELECT); } void CharServerRecv::processCharBanCharList(Net::MessageIn &msg) diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp index 1b5b1bc3a..0fa7a44fe 100644 --- a/src/net/eathena/gamehandler.cpp +++ b/src/net/eathena/gamehandler.cpp @@ -67,7 +67,7 @@ void GameHandler::connect() const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken(); - if (client->getState() == STATE_CONNECT_GAME) + if (client->getState() == State::CONNECT_GAME) { // Change the player's ID to the account ID to match what eAthena uses if (localPlayer) diff --git a/src/net/eathena/gamerecv.cpp b/src/net/eathena/gamerecv.cpp index 43c52ba61..e7dd0b589 100644 --- a/src/net/eathena/gamerecv.cpp +++ b/src/net/eathena/gamerecv.cpp @@ -65,7 +65,7 @@ void GameRecv::processMapLogin(Net::MessageIn &msg) network->pauseDispatch(); // Switch now or we'll have problems - client->setState(STATE_GAME); + client->setState(State::GAME); if (localPlayer) localPlayer->setTileCoords(x, y); } diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp index ecfa7eeda..7ee608088 100644 --- a/src/net/eathena/generalhandler.cpp +++ b/src/net/eathena/generalhandler.cpp @@ -186,7 +186,7 @@ void GeneralHandler::flushNetwork() else errorMessage = _("Got disconnected from server!"); - client->setState(STATE_ERROR); + client->setState(State::ERROR); } } diff --git a/src/net/eathena/generalrecv.cpp b/src/net/eathena/generalrecv.cpp index ff5809028..6e6ece029 100644 --- a/src/net/eathena/generalrecv.cpp +++ b/src/net/eathena/generalrecv.cpp @@ -51,7 +51,7 @@ void GeneralRecv::processConnectionProblem(Net::MessageIn &msg) errorMessage = _("No servers available."); break; case 2: - if (client->getState() == STATE_GAME) + if (client->getState() == State::GAME) { errorMessage = _("Someone else is trying to use " "this account."); @@ -136,7 +136,7 @@ void GeneralRecv::processConnectionProblem(Net::MessageIn &msg) errorMessage = _("Unknown connection error."); break; } - client->setState(STATE_ERROR); + client->setState(State::ERROR); } void GeneralRecv::processMapNotFound(Net::MessageIn &msg) @@ -144,7 +144,7 @@ void GeneralRecv::processMapNotFound(Net::MessageIn &msg) const int sz = msg.readInt16("len") - 4; msg.readString(sz, "map name?"); errorMessage = _("Map not found"); - client->setState(STATE_ERROR); + client->setState(State::ERROR); } } // namespace EAthena diff --git a/src/net/eathena/loginhandler.cpp b/src/net/eathena/loginhandler.cpp index a50b0dc4a..07314cf64 100644 --- a/src/net/eathena/loginhandler.cpp +++ b/src/net/eathena/loginhandler.cpp @@ -62,8 +62,8 @@ void LoginHandler::connect() } else { - if (client->getState() != STATE_LOGIN) - client->setState(STATE_LOGIN); + if (client->getState() != State::LOGIN) + client->setState(State::LOGIN); } } diff --git a/src/net/eathena/loginrecv.cpp b/src/net/eathena/loginrecv.cpp index af9592b7a..6324689b5 100644 --- a/src/net/eathena/loginrecv.cpp +++ b/src/net/eathena/loginrecv.cpp @@ -117,7 +117,7 @@ void LoginRecv::processLoginError2(Net::MessageIn &msg) UNIMPLIMENTEDPACKET; break; } - client->setState(STATE_ERROR); + client->setState(State::ERROR); } void LoginRecv::processUpdateHost2(Net::MessageIn &msg) @@ -139,8 +139,8 @@ void LoginRecv::processUpdateHost2(Net::MessageIn &msg) logger->log("Received update hosts \"%s\" from login server.", updateHost.c_str()); - if (client->getState() == STATE_PRE_LOGIN) - client->setState(STATE_LOGIN); + if (client->getState() == State::PRE_LOGIN) + client->setState(State::LOGIN); } void LoginRecv::processServerVersion(Net::MessageIn &msg) @@ -167,7 +167,7 @@ void LoginRecv::processServerVersion(Net::MessageIn &msg) logger->log("Hercules without version"); } updateProtocol(); - client->setState(STATE_LOGIN); + client->setState(State::LOGIN); } void LoginRecv::processCondingKey(Net::MessageIn &msg) @@ -184,7 +184,7 @@ void LoginRecv::processCharPasswordResponse(Net::MessageIn &msg) // Successful pass change if (errMsg == 1) { - client->setState(STATE_CHANGEPASSWORD_SUCCESS); + client->setState(State::CHANGEPASSWORD_SUCCESS); } // pass change failed else @@ -209,7 +209,7 @@ void LoginRecv::processCharPasswordResponse(Net::MessageIn &msg) errorMessage = _("Unknown error."); break; } - client->setState(STATE_ACCOUNTCHANGE_ERROR); + client->setState(State::ACCOUNTCHANGE_ERROR); } } diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp index f2e1b0943..6c47f5e05 100644 --- a/src/net/tmwa/charserverrecv.cpp +++ b/src/net/tmwa/charserverrecv.cpp @@ -177,7 +177,7 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg) } } - client->setState(STATE_CHAR_SELECT); + client->setState(State::CHAR_SELECT); BLOCK_END("CharServerRecv::processCharLogin") } @@ -211,7 +211,7 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg) if (network) network->disconnect(); - client->setState(STATE_CONNECT_GAME); + client->setState(State::CONNECT_GAME); BLOCK_END("CharServerRecv::processCharMapInfo") } @@ -241,7 +241,7 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) server.port = msg.readInt16("port"); network->disconnect(); - client->setState(STATE_CHANGE_MAP); + client->setState(State::CHANGE_MAP); if (localPlayer) { localPlayer->setTileCoords(x, y); diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index 7a8628df5..3b6e9bd7e 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -64,7 +64,7 @@ void GameHandler::connect() Network::mInstance->connect(mapServer); const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken(); - if (client->getState() == STATE_CONNECT_GAME) + if (client->getState() == State::CONNECT_GAME) { // Change the player's ID to the account ID to match what eAthena uses if (localPlayer) diff --git a/src/net/tmwa/gamerecv.cpp b/src/net/tmwa/gamerecv.cpp index ba68d9391..f6db8b616 100644 --- a/src/net/tmwa/gamerecv.cpp +++ b/src/net/tmwa/gamerecv.cpp @@ -55,7 +55,7 @@ void GameRecv::processMapLogin(Net::MessageIn &msg) network->pauseDispatch(); // Switch now or we'll have problems - client->setState(STATE_GAME); + client->setState(State::GAME); if (localPlayer) localPlayer->setTileCoords(x, y); } diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 818e2d7a2..8dfdccfbc 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -207,7 +207,7 @@ void GeneralHandler::flushNetwork() errorMessage = _("Got disconnected from server!"); } - client->setState(STATE_ERROR); + client->setState(State::ERROR); } BLOCK_END("GeneralHandler::flushNetwork 3") } diff --git a/src/net/tmwa/generalrecv.cpp b/src/net/tmwa/generalrecv.cpp index 42fc75350..9a87f1446 100644 --- a/src/net/tmwa/generalrecv.cpp +++ b/src/net/tmwa/generalrecv.cpp @@ -53,7 +53,7 @@ void GeneralRecv::processConnectionProblem(Net::MessageIn &msg) errorMessage = _("No servers available."); break; case 2: - if (client->getState() == STATE_GAME) + if (client->getState() == State::GAME) { // TRANSLATORS: error message errorMessage = _("Someone else is trying to use this " @@ -78,7 +78,7 @@ void GeneralRecv::processConnectionProblem(Net::MessageIn &msg) errorMessage = _("Unknown connection error."); break; } - client->setState(STATE_ERROR); + client->setState(State::ERROR); } } // namespace TmwAthena diff --git a/src/net/tmwa/loginrecv.cpp b/src/net/tmwa/loginrecv.cpp index c6aa48b83..783e5d55c 100644 --- a/src/net/tmwa/loginrecv.cpp +++ b/src/net/tmwa/loginrecv.cpp @@ -86,8 +86,8 @@ void LoginRecv::processServerVersion(Net::MessageIn &msg) if (serverVersion < 5) { - if (client->getState() != STATE_LOGIN) - client->setState(STATE_LOGIN); + if (client->getState() != State::LOGIN) + client->setState(State::LOGIN); } // Leave this last @@ -101,7 +101,7 @@ void LoginRecv::processCharPasswordResponse(Net::MessageIn &msg) // Successful pass change if (errMsg == 1) { - client->setState(STATE_CHANGEPASSWORD_SUCCESS); + client->setState(State::CHANGEPASSWORD_SUCCESS); } // pass change failed else @@ -126,7 +126,7 @@ void LoginRecv::processCharPasswordResponse(Net::MessageIn &msg) errorMessage = _("Unknown error."); break; } - client->setState(STATE_ACCOUNTCHANGE_ERROR); + client->setState(State::ACCOUNTCHANGE_ERROR); } } |