Fix handling of particle 'father' objects when they are destroyed

master
krzys-h 2017-05-23 20:31:55 +02:00
parent 904b7e580b
commit 648dfd75c4
3 changed files with 24 additions and 0 deletions

View File

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

View File

@ -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);

View File

@ -203,6 +203,7 @@ void COldObject::DeleteObject(bool bAll)
if ( !bAll )
{
m_engine->GetPyroManager()->CutObjectLink(this);
m_particle->CutObjectLink(this);
if ( m_bSelect )
{