[colobot] 81/100: Fix delete() in CBot not destroying PowerCells properly

Didier Raboud odyx at moszumanska.debian.org
Thu Jun 1 18:10:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 2d7911f1553a2511c144460e37a45447a32e69d3
Author: krzys-h <krzys_h at interia.pl>
Date:   Tue May 23 20:19:47 2017 +0200

    Fix delete() in CBot not destroying PowerCells properly
---
 src/graphics/engine/pyro.cpp |  3 +++
 src/script/scriptfunc.cpp    | 10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp
index 6f3961a..5bc9f76 100644
--- a/src/graphics/engine/pyro.cpp
+++ b/src/graphics/engine/pyro.cpp
@@ -2157,6 +2157,9 @@ bool CPyro::BurnIsKeepPart(int part)
 
 void CPyro::BurnTerminate()
 {
+    if (m_object == nullptr)
+        return;
+
     if (m_type == PT_BURNO)  // organic object is burning?
     {
         DeleteObject(true, true);  // removes the insect
diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp
index c0b639d..5fc9756 100644
--- a/src/script/scriptfunc.cpp
+++ b/src/script/scriptfunc.cpp
@@ -682,6 +682,16 @@ bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, vo
         }
         else
         {
+            if (obj->Implements(ObjectInterfaceType::Old))
+            {
+                COldObject* oldobj = dynamic_cast<COldObject*>(obj);
+                if (oldobj->GetPower() != nullptr)
+                    CObjectManager::GetInstancePointer()->DeleteObject(oldobj->GetPower());
+                if (oldobj->GetCargo() != nullptr)
+                    CObjectManager::GetInstancePointer()->DeleteObject(oldobj->GetCargo());
+                oldobj->SetPower(nullptr);
+                oldobj->SetCargo(nullptr);
+            }
             CObjectManager::GetInstancePointer()->DeleteObject(obj);
         }
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list