Reset extra server info each game for live changing

This commit is contained in:
Benau 2018-12-06 14:52:28 +08:00
parent 6be39f7ef8
commit a69db65c71
4 changed files with 19 additions and 12 deletions

View File

@ -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)
{

View File

@ -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<uint32_t> 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; }
// ------------------------------------------------------------------------

View File

@ -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:

View File

@ -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);