diff --git a/game_root.cpp b/game_root.cpp index c44e23f..5525752 100644 --- a/game_root.cpp +++ b/game_root.cpp @@ -120,7 +120,7 @@ Level3D *GameRoot3D::load_level_at(gd::Ref level, gd::Transform // store and add to tree at desired transform // if this is the first level containing a game mode currently active use it's gamemode as a prototype gd::Ref game_mode_prototype{instance->get_game_mode_prototype()}; - bool const switch_game_mode{!this->game_mode || this->game_mode->get_scene_file_path() != game_mode_prototype->get_path()}; + bool const switch_game_mode{!this->game_mode || (this->game_mode == nullptr) != game_mode_prototype.is_null() || this->game_mode->get_scene_file_path() != game_mode_prototype->get_path()}; if(switch_game_mode) { this->set_game_mode(instance->get_game_mode_prototype()); } @@ -139,7 +139,8 @@ void GameRoot3D::unload_all_levels() { gd::HashMap levels = this->get_levels(); for(gd::KeyValue &kvp : levels) kvp.value->call_deferred("queue_free"); - this->get_levels().clear(); + this->levels.clear(); + this->spawn_points.clear(); this->reset_game_mode(); }