cleanup all particle systems when morphing

https://forum.megaglest.org/index.php?topic=9561.0
This commit is contained in:
titiger 2014-09-22 02:58:47 +02:00
parent 4fc4359d99
commit 2f00143782
2 changed files with 27 additions and 21 deletions

View File

@ -666,27 +666,7 @@ Unit::~Unit() {
}
safeMutex.ReleaseLock();
// If the unit is not visible we better make sure we cleanup associated particles
if(this->getVisible() == false) {
Renderer::getInstance().cleanupUnitParticleSystems(unitParticleSystems,rsGame);
Renderer::getInstance().cleanupParticleSystems(fireParticleSystems,rsGame);
// Must set this to null of it will be used below in stopDamageParticles()
if(Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) {
this->fire = NULL;
}
}
// fade(and by this remove) all unit particle systems
queuedUnitParticleSystemTypes.clear();
while(unitParticleSystems.empty() == false) {
if(Renderer::getInstance().validateParticleSystemStillExists(unitParticleSystems.back(),rsGame) == true) {
unitParticleSystems.back()->fade();
}
unitParticleSystems.pop_back();
}
stopDamageParticles(true);
cleanupAllParticlesystems();
while(currentAttackBoostEffects.empty() == false) {
//UnitAttackBoostEffect &effect = currentAttackBoostEffects.back();
@ -726,6 +706,29 @@ Unit::~Unit() {
#endif
}
void Unit::cleanupAllParticlesystems() {
Renderer::getInstance().cleanupUnitParticleSystems(unitParticleSystems,rsGame);
Renderer::getInstance().cleanupParticleSystems(fireParticleSystems,rsGame);
// Must set this to null of it will be used below in stopDamageParticles()
if(Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) {
this->fire = NULL;
}
// fade(and by this remove) all unit particle systems
queuedUnitParticleSystemTypes.clear();
while(unitParticleSystems.empty() == false) {
if(Renderer::getInstance().validateParticleSystemStillExists(unitParticleSystems.back(),rsGame) == true) {
unitParticleSystems.back()->fade();
}
unitParticleSystems.pop_back();
}
stopDamageParticles(true);
}
ParticleSystem * Unit::getFire() const {
if(this->fire != NULL &&
Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) {
@ -3580,6 +3583,8 @@ bool Unit::morph(const MorphCommandType *mct) {
}
}
//stopDamageParticles(true);
cleanupAllParticlesystems();
checkItemInVault(&this->hp,this->hp);
int original_hp = this->hp;

View File

@ -806,6 +806,7 @@ public:
private:
void cleanupAllParticlesystems();
bool isNetworkCRCEnabled();
string getNetworkCRCDecHpList() const;
string getParticleInfo() const;