소스 검색

Fixed a bug that crashes the BattleManager at the second battle on the same map.

Iñigo Valentin 3 년 전
부모
커밋
ec6f8a69b0
2개의 변경된 파일7개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 1
      src/core/BattleManager.cpp
  2. 4 1
      src/core/EntityManager.cpp

+ 3 - 1
src/core/BattleManager.cpp

@@ -142,8 +142,10 @@ void BattleManager::EndBattle(){
     AudioManager::getSingleton().SetPreviousModule();
     CameraManager::getSingleton().SetPreviousModule();
     DialogsManager::getSingleton().SetPreviousModule();
-    EntityManager::getSingleton().SetPreviousModule();
+    ScriptManager::getSingleton().ClearBattle();
+    EntityManager::getSingleton().ClearBattle();
     EntityManager::getSingleton().GetBackground2D()->Show();
+    EntityManager::getSingleton().SetPreviousModule();
     InputManager::getSingleton().SetPreviousModule();
     ScriptManager::getSingleton().ClearBattle();
     ScriptManager::getSingleton().SetPreviousModule();

+ 4 - 1
src/core/EntityManager.cpp

@@ -346,7 +346,10 @@ void EntityManager::ClearBattle(){
         ScriptManager::getSingleton().RemoveEntity(
           ScriptManager::ENTITY, battle_entity_[i]->GetName()
         );
-        delete battle_entity_[i];
+        Ogre::Root::getSingleton().getSceneManager("Scene")->destroyEntity(
+          battle_entity_[i]->GetName()
+        );
+        scene_node_->removeAndDestroyChild("Model_" + battle_entity_[i]->GetName());
     }
     battle_entity_.clear();
 }