fix: set_game_mode will no longer attempt to spawn a player with id 0 every call

main
Sara 2024-03-16 22:11:20 +01:00
parent 7d7e1ac584
commit 92a1cb6bc5
1 changed files with 2 additions and 2 deletions

View File

@ -114,12 +114,12 @@ void GameRoot::set_game_mode(Ref<GameMode> 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);
}