diff --git a/src/network/game_setup.cpp b/src/network/game_setup.cpp index 72a2798bc..6bba6ae16 100644 --- a/src/network/game_setup.cpp +++ b/src/network/game_setup.cpp @@ -63,6 +63,7 @@ GameSetup::GameSetup() (StringUtils::xmlDecode(server_name)); m_connected_players_count.store(0); m_extra_server_info = -1; + m_is_grand_prix.store(false); reset(); } // GameSetup @@ -183,14 +184,6 @@ void GameSetup::loadWorld() } } // loadWorld -//----------------------------------------------------------------------------- -bool GameSetup::isGrandPrix() const -{ - return m_extra_server_info != -1 && - ServerConfig::getLocalGameModeFromConfig().second == - RaceManager::MAJOR_MODE_GRAND_PRIX; -} // isGrandPrix - //----------------------------------------------------------------------------- void GameSetup::addServerInfo(NetworkString* ns) { diff --git a/src/network/game_setup.hpp b/src/network/game_setup.hpp index 14362e167..d81e380c6 100644 --- a/src/network/game_setup.hpp +++ b/src/network/game_setup.hpp @@ -52,14 +52,16 @@ private: unsigned m_laps; - bool m_reverse; - int m_extra_server_info; int m_hit_capture_limit; float m_battle_time_limit; + bool m_reverse; + + std::atomic_bool m_is_grand_prix; + std::atomic m_connected_players_count; irr::core::stringw m_message_of_today; @@ -123,13 +125,23 @@ public: m_battle_time_limit = 0.0f; } // ------------------------------------------------------------------------ - void setGrandPrixTrack(int tracks_no) { m_extra_server_info = tracks_no; } + void resetExtraServerInfo() + { + m_is_grand_prix.store(false); + m_extra_server_info = -1; + } + // ------------------------------------------------------------------------ + void setGrandPrixTrack(int tracks_no) + { + m_is_grand_prix.store(true); + m_extra_server_info = tracks_no; + } // ------------------------------------------------------------------------ void addServerInfo(NetworkString* ns); // ------------------------------------------------------------------------ void loadWorld(); // ------------------------------------------------------------------------ - bool isGrandPrix() const; + bool isGrandPrix() const { return m_is_grand_prix.load(); } // ------------------------------------------------------------------------ bool hasExtraSeverInfo() const { return m_extra_server_info != -1; } // ------------------------------------------------------------------------ diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index 07e237aa3..47fbcfb50 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -615,6 +615,7 @@ void ClientLobby::handleServerInfo(Event* event) uint8_t extra_server_info = data.getUInt8(); bool grand_prix_started = false; + m_game_setup->resetExtraServerInfo(); switch (extra_server_info) { case 0: diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp index 0037a147b..1ac1a1511 100644 --- a/src/network/protocols/server_lobby.cpp +++ b/src/network/protocols/server_lobby.cpp @@ -2660,6 +2660,7 @@ void ServerLobby::handleServerConfiguration(Event* event) race_manager->setMinorMode(modes.first); race_manager->setMajorMode(modes.second); race_manager->setDifficulty(RaceManager::Difficulty(new_difficulty)); + m_game_setup->resetExtraServerInfo(); if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) m_game_setup->setSoccerGoalTarget(new_soccer_goal_target); m_difficulty.store(new_difficulty);