bugfix for particles, proper checking for valid particle states when using particles
This commit is contained in:
parent
1c4480cb02
commit
0b511efe36
|
@ -426,7 +426,9 @@ Unit::~Unit() {
|
||||||
// fade(and by this remove) all unit particle systems
|
// fade(and by this remove) all unit particle systems
|
||||||
queuedUnitParticleSystemTypes.clear();
|
queuedUnitParticleSystemTypes.clear();
|
||||||
while(unitParticleSystems.empty() == false) {
|
while(unitParticleSystems.empty() == false) {
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists(unitParticleSystems.back(),rsGame) == true) {
|
||||||
unitParticleSystems.back()->fade();
|
unitParticleSystems.back()->fade();
|
||||||
|
}
|
||||||
unitParticleSystems.pop_back();
|
unitParticleSystems.pop_back();
|
||||||
}
|
}
|
||||||
stopDamageParticles(true);
|
stopDamageParticles(true);
|
||||||
|
@ -834,7 +836,9 @@ void Unit::setCurrSkill(const SkillType *currSkill) {
|
||||||
|
|
||||||
queuedUnitParticleSystemTypes.clear();
|
queuedUnitParticleSystemTypes.clear();
|
||||||
while(unitParticleSystems.empty() == false) {
|
while(unitParticleSystems.empty() == false) {
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists(unitParticleSystems.back(),rsGame) == true) {
|
||||||
unitParticleSystems.back()->fade();
|
unitParticleSystems.back()->fade();
|
||||||
|
}
|
||||||
unitParticleSystems.pop_back();
|
unitParticleSystems.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -946,14 +950,20 @@ void Unit::setVisible(const bool visible) {
|
||||||
this->visible = visible;
|
this->visible = visible;
|
||||||
|
|
||||||
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) {
|
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) {
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||||
(*it)->setVisible(visible);
|
(*it)->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for(UnitParticleSystems::iterator it= damageParticleSystems.begin(); it != damageParticleSystems.end(); ++it) {
|
for(UnitParticleSystems::iterator it= damageParticleSystems.begin(); it != damageParticleSystems.end(); ++it) {
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||||
(*it)->setVisible(visible);
|
(*it)->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for(UnitParticleSystems::iterator it= smokeParticleSystems.begin(); it != smokeParticleSystems.end(); ++it) {
|
for(UnitParticleSystems::iterator it= smokeParticleSystems.begin(); it != smokeParticleSystems.end(); ++it) {
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||||
(*it)->setVisible(visible);
|
(*it)->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
|
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
|
||||||
UnitAttackBoostEffect *effect = currentAttackBoostEffects[i];
|
UnitAttackBoostEffect *effect = currentAttackBoostEffects[i];
|
||||||
|
@ -1540,6 +1550,7 @@ void Unit::updateTimedParticles() {
|
||||||
for(int i = unitParticleSystems.size() - 1; i >= 0; i--) {
|
for(int i = unitParticleSystems.size() - 1; i >= 0; i--) {
|
||||||
UnitParticleSystem *ps = unitParticleSystems[i];
|
UnitParticleSystem *ps = unitParticleSystems[i];
|
||||||
if(ps != NULL) {
|
if(ps != NULL) {
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||||
if(truncateDecimal<float>(ps->getStartTime()) != 0.0 || truncateDecimal<float>(ps->getEndTime()) != 1.0) {
|
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));
|
//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());
|
fire->setPos(getCurrVector());
|
||||||
}
|
}
|
||||||
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) {
|
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) {
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||||
(*it)->setPos(getCurrVector());
|
(*it)->setPos(getCurrVector());
|
||||||
(*it)->setRotation(getRotation());
|
(*it)->setRotation(getRotation());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for(UnitParticleSystems::iterator it= damageParticleSystems.begin(); it != damageParticleSystems.end(); ++it) {
|
for(UnitParticleSystems::iterator it= damageParticleSystems.begin(); it != damageParticleSystems.end(); ++it) {
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||||
(*it)->setPos(getCurrVector());
|
(*it)->setPos(getCurrVector());
|
||||||
(*it)->setRotation(getRotation());
|
(*it)->setRotation(getRotation());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(UnitParticleSystems::iterator it= smokeParticleSystems.begin(); it != smokeParticleSystems.end(); ++it) {
|
for(UnitParticleSystems::iterator it= smokeParticleSystems.begin(); it != smokeParticleSystems.end(); ++it) {
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||||
(*it)->setPos(getCurrVector());
|
(*it)->setPos(getCurrVector());
|
||||||
(*it)->setRotation(getRotation());
|
(*it)->setRotation(getRotation());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
|
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
|
||||||
UnitAttackBoostEffect *effect = currentAttackBoostEffects[i];
|
UnitAttackBoostEffect *effect = currentAttackBoostEffects[i];
|
||||||
|
@ -2716,7 +2734,9 @@ void Unit::stopDamageParticles(bool force) {
|
||||||
if(smokeParticleSystems.empty() == false) {
|
if(smokeParticleSystems.empty() == false) {
|
||||||
for(int i = smokeParticleSystems.size()-1; i >= 0; --i) {
|
for(int i = smokeParticleSystems.size()-1; i >= 0; --i) {
|
||||||
UnitParticleSystem *ps = smokeParticleSystems[i];
|
UnitParticleSystem *ps = smokeParticleSystems[i];
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||||
ps->fade();
|
ps->fade();
|
||||||
|
}
|
||||||
smokeParticleSystems.pop_back();
|
smokeParticleSystems.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2726,6 +2746,7 @@ void Unit::stopDamageParticles(bool force) {
|
||||||
UnitParticleSystem *ps = damageParticleSystems[i];
|
UnitParticleSystem *ps = damageParticleSystems[i];
|
||||||
UnitParticleSystemType *pst = NULL;
|
UnitParticleSystemType *pst = NULL;
|
||||||
int foundParticleIndexType = -2;
|
int foundParticleIndexType = -2;
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||||
for(std::map<int, UnitParticleSystem *>::iterator iterMap = damageParticleSystemsInUse.begin();
|
for(std::map<int, UnitParticleSystem *>::iterator iterMap = damageParticleSystemsInUse.begin();
|
||||||
iterMap != damageParticleSystemsInUse.end(); ++iterMap) {
|
iterMap != damageParticleSystemsInUse.end(); ++iterMap) {
|
||||||
if(iterMap->second == ps) {
|
if(iterMap->second == ps) {
|
||||||
|
@ -2736,9 +2757,12 @@ void Unit::stopDamageParticles(bool force) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(force == true || ( pst !=NULL && pst->getMinmaxEnabled() == false )) {
|
if(force == true || ( pst !=NULL && pst->getMinmaxEnabled() == false )) {
|
||||||
damageParticleSystemsInUse.erase(foundParticleIndexType);
|
damageParticleSystemsInUse.erase(foundParticleIndexType);
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||||
ps->fade();
|
ps->fade();
|
||||||
|
}
|
||||||
damageParticleSystems.pop_back();
|
damageParticleSystems.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2755,6 +2779,7 @@ void Unit::checkCustomizedParticleTriggers(bool force) {
|
||||||
UnitParticleSystem *ps = damageParticleSystems[i];
|
UnitParticleSystem *ps = damageParticleSystems[i];
|
||||||
UnitParticleSystemType *pst = NULL;
|
UnitParticleSystemType *pst = NULL;
|
||||||
int foundParticleIndexType = -2;
|
int foundParticleIndexType = -2;
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||||
for(std::map<int, UnitParticleSystem *>::iterator iterMap = damageParticleSystemsInUse.begin();
|
for(std::map<int, UnitParticleSystem *>::iterator iterMap = damageParticleSystemsInUse.begin();
|
||||||
iterMap != damageParticleSystemsInUse.end(); ++iterMap) {
|
iterMap != damageParticleSystemsInUse.end(); ++iterMap) {
|
||||||
if(iterMap->second == ps) {
|
if(iterMap->second == ps) {
|
||||||
|
@ -2765,6 +2790,7 @@ void Unit::checkCustomizedParticleTriggers(bool force) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(force == true || (pst != NULL && pst->getMinmaxEnabled() == true)) {
|
if(force == true || (pst != NULL && pst->getMinmaxEnabled() == true)) {
|
||||||
bool stopParticle = force;
|
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);
|
//printf("STOPPING customized particle trigger by HP [%d to %d] current hp = %d\n",pst->getMinHp(),pst->getMaxHp(),hp);
|
||||||
|
|
||||||
damageParticleSystemsInUse.erase(foundParticleIndexType);
|
damageParticleSystemsInUse.erase(foundParticleIndexType);
|
||||||
|
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||||
ps->fade();
|
ps->fade();
|
||||||
|
}
|
||||||
damageParticleSystems.pop_back();
|
damageParticleSystems.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue