diff --git a/game_root.cpp b/game_root.cpp index 210bd2d..0e66495 100644 --- a/game_root.cpp +++ b/game_root.cpp @@ -122,6 +122,7 @@ void GameRoot::set_game_mode(Ref prototype) { // allow "unsetting" the gamemode by passing an invalid gamemode // shorthand for this behaviour is reset_game_mode if(prototype.is_null() || !prototype.is_valid()) { + this->game_mode->_end(); this->game_mode.unref(); return; } @@ -129,6 +130,7 @@ void GameRoot::set_game_mode(Ref prototype) { this->game_mode = prototype->duplicate(false); // .. 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);