From 92a1cb6bc5422e1f8282379c218e5b380fc7dee9 Mon Sep 17 00:00:00 2001 From: Sara Date: Sat, 16 Mar 2024 22:11:20 +0100 Subject: [PATCH] fix: set_game_mode will no longer attempt to spawn a player with id 0 every call --- game_root.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/game_root.cpp b/game_root.cpp index 4f2bf70..e0b5ce2 100644 --- a/game_root.cpp +++ b/game_root.cpp @@ -114,12 +114,12 @@ void GameRoot::set_game_mode(Ref prototype) { this->game_mode = prototype->duplicate(false); // copy the game state from the prototype this->game_mode->set_game_state(prototype->get_game_state()->duplicate(false)); - uint32_t new_player_id = 0; + uint32_t new_player_id = this->find_empty_player_slot(); do { - new_player_id = this->find_empty_player_slot(); IPlayer *player = this->spawn_player(new_player_id); if(player != nullptr) this->initialize_player(player, new_player_id); + new_player_id = this->find_empty_player_slot(); } while(new_player_id != 0); }