[colobot] 83/100: Fix handling of particle 'father' objects when they are destroyed

Didier Raboud odyx at moszumanska.debian.org
Thu Jun 1 18:10:22 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 648dfd75c43666c667662afe7cb412de1ae029f4
Author: krzys-h <krzys_h at interia.pl>
Date:   Tue May 23 20:31:55 2017 +0200

    Fix handling of particle 'father' objects when they are destroyed
---
 src/graphics/engine/particle.cpp | 20 ++++++++++++++++++++
 src/graphics/engine/particle.h   |  3 +++
 src/object/old_object.cpp        |  1 +
 3 files changed, 24 insertions(+)

diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp
index e63a8c6..f5c254e 100644
--- a/src/graphics/engine/particle.cpp
+++ b/src/graphics/engine/particle.cpp
@@ -3740,4 +3740,24 @@ Color CParticle::GetFogColor(Math::Vector pos)
     return result;
 }
 
+void CParticle::CutObjectLink(CObject* obj)
+{
+    for (int i = 0; i < MAXPARTICULE*MAXPARTITYPE; i++)
+    {
+        if (!m_particle[i].used) continue;
+
+        if (m_particle[i].objLink == obj)
+        {
+            // If the object this particle's coordinates are linked to doesn't exist anymore, remove the particle
+            DeleteRank(i);
+        }
+
+        if (m_particle[i].objFather == obj)
+        {
+            // If the object that spawned this partcle doesn't exist anymore, remove the link
+            m_particle[i].objFather = nullptr;
+        }
+    }
+}
+
 } // namespace Gfx
diff --git a/src/graphics/engine/particle.h b/src/graphics/engine/particle.h
index 03707a9..08dfc43 100644
--- a/src/graphics/engine/particle.h
+++ b/src/graphics/engine/particle.h
@@ -291,6 +291,9 @@ public:
     //! Draws all the particles
     void        DrawParticle(int sheet);
 
+    //! Indicates that the object binds to the particle no longer exists, without deleting it
+    void        CutObjectLink(CObject* obj);
+
 protected:
     //! Removes a particle of given rank
     void        DeleteRank(int rank);
diff --git a/src/object/old_object.cpp b/src/object/old_object.cpp
index dbbb389..9655ad7 100644
--- a/src/object/old_object.cpp
+++ b/src/object/old_object.cpp
@@ -203,6 +203,7 @@ void COldObject::DeleteObject(bool bAll)
     if ( !bAll )
     {
         m_engine->GetPyroManager()->CutObjectLink(this);
+        m_particle->CutObjectLink(this);
 
         if ( m_bSelect )
         {

-- 
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