attempt to bugfix attackboost segfault discovered while playing vs Romans

This commit is contained in:
Mark Vejvoda 2011-10-30 06:12:40 +00:00
parent ca45749cd8
commit 0f6e8ba928
1 changed files with 26 additions and 11 deletions

View File

@ -238,6 +238,8 @@ UnitAttackBoostEffect::~UnitAttackBoostEffect() {
} }
if(ups != NULL) { if(ups != NULL) {
bool particleValid = Renderer::getInstance().validateParticleSystemStillExists(ups,rsGame);
if(particleValid == true) {
ups->fade(); ups->fade();
vector<UnitParticleSystem *> particleSystemToRemove; vector<UnitParticleSystem *> particleSystemToRemove;
@ -246,6 +248,7 @@ UnitAttackBoostEffect::~UnitAttackBoostEffect() {
Renderer::getInstance().cleanupUnitParticleSystems(particleSystemToRemove,rsGame); Renderer::getInstance().cleanupUnitParticleSystems(particleSystemToRemove,rsGame);
ups = NULL; ups = NULL;
} }
}
delete upst; delete upst;
upst = NULL; upst = NULL;
@ -955,14 +958,20 @@ void Unit::setVisible(const bool 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];
if(effect != NULL && effect->ups != NULL) { if(effect != NULL && effect->ups != NULL) {
bool particleValid = Renderer::getInstance().validateParticleSystemStillExists(effect->ups,rsGame);
if(particleValid == true) {
effect->ups->setVisible(visible); effect->ups->setVisible(visible);
} }
} }
}
if(currentAttackBoostOriginatorEffect.currentAppliedEffect != NULL) { if(currentAttackBoostOriginatorEffect.currentAppliedEffect != NULL) {
if(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups != NULL) { if(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups != NULL) {
bool particleValid = Renderer::getInstance().validateParticleSystemStillExists(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups,rsGame);
if(particleValid == true) {
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setVisible(visible); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setVisible(visible);
} }
} }
}
} }
// =============================== Render related ================================== // =============================== Render related ==================================
@ -1663,16 +1672,22 @@ bool Unit::update() {
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];
if(effect != NULL && effect->ups != NULL) { if(effect != NULL && effect->ups != NULL) {
bool particleValid = Renderer::getInstance().validateParticleSystemStillExists(effect->ups,rsGame);
if(particleValid == true) {
effect->ups->setPos(getCurrVector()); effect->ups->setPos(getCurrVector());
effect->ups->setRotation(getRotation()); effect->ups->setRotation(getRotation());
} }
} }
}
if(currentAttackBoostOriginatorEffect.currentAppliedEffect != NULL) { if(currentAttackBoostOriginatorEffect.currentAppliedEffect != NULL) {
if(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups != NULL) { if(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups != NULL) {
bool particleValid = Renderer::getInstance().validateParticleSystemStillExists(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups,rsGame);
if(particleValid == true) {
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(getCurrVector()); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(getCurrVector());
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setRotation(getRotation()); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setRotation(getRotation());
} }
} }
}
//checks //checks
if(animProgress > 1.f) { if(animProgress > 1.f) {