5757#include " utils/hit_processor.hpp"
5858#include " modes/capture_the_flag.hpp"
5959#include " utils/chat_manager.hpp"
60+ #include " network/protocols/game_events_protocol.hpp"
6061
6162namespace
6263{
@@ -205,7 +206,7 @@ void PlayingRoom::updateRoom(int ticks)
205206{
206207 World* w = World::getWorld ();
207208 bool world_started = m_play_state.load () >= WAIT_FOR_WORLD_LOADED &&
208- m_state .load () <= RACING && m_server_has_loaded_world.load ();
209+ m_play_state .load () <= RACING && m_server_has_loaded_world.load ();
209210 bool all_players_in_world_disconnected = (w != NULL && world_started);
210211 int sec = getSettings ()->getKickIdlePlayerSeconds ();
211212 if (world_started)
@@ -243,7 +244,7 @@ void PlayingRoom::updateRoom(int ticks)
243244 if (w && w->getKart (i)->hasFinishedRace ())
244245 continue ;
245246 // Don't kick in game GUI server host so he can idle in game
246- if (m_process_type == PT_CHILD && isClientServerHost (peer))
247+ if (getLobby ()-> isChildClientServerHost (peer))
247248 continue ;
248249 Log::info (" ServerLobby" , " %s %s has been idle ingame for more than"
249250 " %d seconds, kick." ,
@@ -282,7 +283,7 @@ void PlayingRoom::updateRoom(int ticks)
282283 getHitProcessor ()->punishSwatterHits ();
283284 }
284285 }
285- if (m_state .load () == WAITING_FOR_START_GAME) {
286+ if (m_play_state .load () == WAITING_FOR_START_GAME) {
286287 sec = getSettings ()->getKickIdleLobbyPlayerSeconds ();
287288 auto peers = STKHost::get ()->getPeers ();
288289 for (auto peer: peers)
@@ -292,7 +293,7 @@ void PlayingRoom::updateRoom(int ticks)
292293 !peer->isDisconnected () && NetworkConfig::get ()->isWAN ())
293294 {
294295 // Don't kick in game GUI server host so he can idle in the lobby
295- if (m_process_type == PT_CHILD && isClientServerHost (peer))
296+ if (getLobby ()-> isChildClientServerHost (peer))
296297 continue ;
297298 std::string peer_name = " " ;
298299 if (peer->hasPlayerProfiles ())
@@ -306,14 +307,14 @@ void PlayingRoom::updateRoom(int ticks)
306307 }
307308
308309 if (w)
309- m_game_progress = w->getGameStartedProgress ();
310+ setGameStartedProgress ( w->getGameStartedProgress () );
310311 else
311- m_game_progress = { std::numeric_limits< uint32_t >:: max (), std::numeric_limits< uint32_t >:: max () } ;
312+ resetGameStartedProgress () ;
312313
313314 if (w && w->getPhase () == World::RACE_PHASE)
314- m_playing_track = (RaceManager::get ()->getTrackName ());
315+ storePlayingTrack (RaceManager::get ()->getTrackName ());
315316 else
316- m_playing_track = " " ;
317+ storePlayingTrack ( " " ) ;
317318
318319 // Reset server to initial state if no more connected players
319320 if (m_rs_state.load () == RS_WAITING)
@@ -329,7 +330,7 @@ void PlayingRoom::updateRoom(int ticks)
329330
330331 STKHost::get ()->updatePlayers ();
331332 if (m_rs_state.load () == RS_NONE &&
332- (m_state .load () > WAITING_FOR_START_GAME/* ||
333+ (m_play_state .load () > WAITING_FOR_START_GAME/* ||
333334 m_game_setup->isGrandPrixStarted()*/ ) &&
334335 (STKHost::get ()->getPlayersInGame () == 0 ||
335336 all_players_in_world_disconnected))
@@ -372,7 +373,7 @@ void PlayingRoom::updateRoom(int ticks)
372373
373374 // Reset for ranked server if in kart / track selection has only 1 player
374375 if (getSettings ()->isRanked () &&
375- m_state .load () == SELECTING &&
376+ m_play_state .load () == SELECTING &&
376377 STKHost::get ()->getPlayersInGame () == 1 )
377378 {
378379 NetworkString* back_lobby = getNetworkString (2 );
@@ -391,8 +392,6 @@ void PlayingRoom::updateRoom(int ticks)
391392
392393 switch (m_play_state.load ())
393394 {
394- case SET_PUBLIC_ADDRESS:
395- case REGISTER_SELF_ADDRESS:
396395 case WAITING_FOR_START_GAME:
397396 case WAIT_FOR_WORLD_LOADED:
398397 case WAIT_FOR_RACE_STARTED:
@@ -450,9 +449,6 @@ void PlayingRoom::updateRoom(int ticks)
450449 m_rs_state.store (RS_ASYNC_RESET);
451450 }
452451 break ;
453- case ERROR_LEAVE:
454- case EXITING:
455- break ;
456452 }
457453} // updateRoom
458454// -----------------------------------------------------------------------------
@@ -769,7 +765,6 @@ void PlayingRoom::asynchronousUpdateRoom()
769765} // asynchronousUpdateRoom
770766// -----------------------------------------------------------------------------
771767
772-
773768/* * Calls the corresponding method from LobbyAssetManager
774769 * whenever server is reset or game mode is changed. */
775770[[deprecated(" Asset managers should be separate for different rooms." )]]
@@ -780,6 +775,7 @@ void PlayingRoom::updateMapsForMode()
780775 );
781776} // updateMapsForMode
782777// -----------------------------------------------------------------------------
778+
783779NetworkString* PlayingRoom::getLoadWorldMessage (
784780 std::vector<std::shared_ptr<NetworkPlayerProfile> >& players,
785781 bool live_join) const
@@ -1481,7 +1477,7 @@ void PlayingRoom::clientInGameWantsToBackLobby(Event* event)
14811477 return ;
14821478 }
14831479
1484- if (m_process_type == PT_CHILD && isClientServerHost (event->getPeer ()))
1480+ if (getLobby ()-> isChildClientServerHost (event->getPeer ()))
14851481 {
14861482 // For child server the remaining client cannot go on player when the
14871483 // server owner quited the game (because the world will be deleted), so
@@ -1569,7 +1565,7 @@ void PlayingRoom::clientSelectingAssetsWantsToBackLobby(Event* event)
15691565 return ;
15701566 }
15711567
1572- if (m_process_type == PT_CHILD && isClientServerHost ( event->getPeer ()))
1568+ if (getLobby ()-> isChildClientServerHost ( event->getPeerSP ()))
15731569 {
15741570 NetworkString* back_to_lobby = getNetworkString (2 );
15751571 back_to_lobby->setSynchronous (true );
0 commit comments