From 51f18f45b8eaf3ec5e71d062e38179f09cf20b5c Mon Sep 17 00:00:00 2001 From: Sara Date: Tue, 21 May 2024 11:57:21 +0200 Subject: [PATCH] fix: game root now only spawns player if scene is assigned in game mode --- game_root.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/game_root.cpp b/game_root.cpp index 94bae3f..2c4015d 100644 --- a/game_root.cpp +++ b/game_root.cpp @@ -171,13 +171,15 @@ void GameRoot3D::set_game_mode(Ref prototype) { // .. except for the game state, which should be cloned as well this->game_mode->set_game_state(prototype->get_game_state()->duplicate(false)); this->game_mode->_begin(); - uint32_t new_player_id = this->find_empty_player_slot(); - do { - 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); + if(this->game_mode->get_player_scene().is_valid()) { + uint32_t new_player_id = this->find_empty_player_slot(); + do { + 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); + } } Ref GameRoot3D::get_game_mode() const {