mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 23:45:14 +02:00
bugfix for particles, proper checking for valid particle states when using particles
This commit is contained in:
@@ -426,7 +426,9 @@ Unit::~Unit() {
|
||||
// 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);
|
||||
@@ -834,7 +836,9 @@ void Unit::setCurrSkill(const SkillType *currSkill) {
|
||||
|
||||
queuedUnitParticleSystemTypes.clear();
|
||||
while(unitParticleSystems.empty() == false) {
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists(unitParticleSystems.back(),rsGame) == true) {
|
||||
unitParticleSystems.back()->fade();
|
||||
}
|
||||
unitParticleSystems.pop_back();
|
||||
}
|
||||
}
|
||||
@@ -946,14 +950,20 @@ void Unit::setVisible(const bool visible) {
|
||||
this->visible = visible;
|
||||
|
||||
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) {
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||
(*it)->setVisible(visible);
|
||||
}
|
||||
}
|
||||
for(UnitParticleSystems::iterator it= damageParticleSystems.begin(); it != damageParticleSystems.end(); ++it) {
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||
(*it)->setVisible(visible);
|
||||
}
|
||||
}
|
||||
for(UnitParticleSystems::iterator it= smokeParticleSystems.begin(); it != smokeParticleSystems.end(); ++it) {
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||
(*it)->setVisible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
|
||||
UnitAttackBoostEffect *effect = currentAttackBoostEffects[i];
|
||||
@@ -1540,6 +1550,7 @@ void Unit::updateTimedParticles() {
|
||||
for(int i = unitParticleSystems.size() - 1; i >= 0; i--) {
|
||||
UnitParticleSystem *ps = unitParticleSystems[i];
|
||||
if(ps != NULL) {
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||
if(truncateDecimal<float>(ps->getStartTime()) != 0.0 || truncateDecimal<float>(ps->getEndTime()) != 1.0) {
|
||||
//printf("Checking for end particle system #%d [%d] [%f] [%f] [%f] [%f]\n",i,ps->shape,truncateDecimal<float>(ps->getStartTime()),truncateDecimal<float>(ps->getEndTime()),truncateDecimal<float>(animProgress),truncateDecimal<float>(lastAnimProgress));
|
||||
|
||||
@@ -1553,6 +1564,7 @@ void Unit::updateTimedParticles() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1656,18 +1668,24 @@ bool Unit::update() {
|
||||
fire->setPos(getCurrVector());
|
||||
}
|
||||
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) {
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||
(*it)->setPos(getCurrVector());
|
||||
(*it)->setRotation(getRotation());
|
||||
}
|
||||
}
|
||||
for(UnitParticleSystems::iterator it= damageParticleSystems.begin(); it != damageParticleSystems.end(); ++it) {
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||
(*it)->setPos(getCurrVector());
|
||||
(*it)->setRotation(getRotation());
|
||||
}
|
||||
}
|
||||
|
||||
for(UnitParticleSystems::iterator it= smokeParticleSystems.begin(); it != smokeParticleSystems.end(); ++it) {
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||
(*it)->setPos(getCurrVector());
|
||||
(*it)->setRotation(getRotation());
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
|
||||
UnitAttackBoostEffect *effect = currentAttackBoostEffects[i];
|
||||
@@ -2716,7 +2734,9 @@ void Unit::stopDamageParticles(bool force) {
|
||||
if(smokeParticleSystems.empty() == false) {
|
||||
for(int i = smokeParticleSystems.size()-1; i >= 0; --i) {
|
||||
UnitParticleSystem *ps = smokeParticleSystems[i];
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||
ps->fade();
|
||||
}
|
||||
smokeParticleSystems.pop_back();
|
||||
}
|
||||
}
|
||||
@@ -2726,6 +2746,7 @@ void Unit::stopDamageParticles(bool force) {
|
||||
UnitParticleSystem *ps = damageParticleSystems[i];
|
||||
UnitParticleSystemType *pst = NULL;
|
||||
int foundParticleIndexType = -2;
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||
for(std::map<int, UnitParticleSystem *>::iterator iterMap = damageParticleSystemsInUse.begin();
|
||||
iterMap != damageParticleSystemsInUse.end(); ++iterMap) {
|
||||
if(iterMap->second == ps) {
|
||||
@@ -2736,9 +2757,12 @@ void Unit::stopDamageParticles(bool force) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(force == true || ( pst !=NULL && pst->getMinmaxEnabled() == false )) {
|
||||
damageParticleSystemsInUse.erase(foundParticleIndexType);
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||
ps->fade();
|
||||
}
|
||||
damageParticleSystems.pop_back();
|
||||
}
|
||||
}
|
||||
@@ -2755,6 +2779,7 @@ void Unit::checkCustomizedParticleTriggers(bool force) {
|
||||
UnitParticleSystem *ps = damageParticleSystems[i];
|
||||
UnitParticleSystemType *pst = NULL;
|
||||
int foundParticleIndexType = -2;
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||
for(std::map<int, UnitParticleSystem *>::iterator iterMap = damageParticleSystemsInUse.begin();
|
||||
iterMap != damageParticleSystemsInUse.end(); ++iterMap) {
|
||||
if(iterMap->second == ps) {
|
||||
@@ -2765,6 +2790,7 @@ void Unit::checkCustomizedParticleTriggers(bool force) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(force == true || (pst != NULL && pst->getMinmaxEnabled() == true)) {
|
||||
bool stopParticle = force;
|
||||
@@ -2788,7 +2814,9 @@ void Unit::checkCustomizedParticleTriggers(bool force) {
|
||||
//printf("STOPPING customized particle trigger by HP [%d to %d] current hp = %d\n",pst->getMinHp(),pst->getMaxHp(),hp);
|
||||
|
||||
damageParticleSystemsInUse.erase(foundParticleIndexType);
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||
ps->fade();
|
||||
}
|
||||
damageParticleSystems.pop_back();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user