fixed missing cast found by Coverity CID 1232664

This commit is contained in:
titiger 2014-12-16 02:08:29 +01:00
parent 2d4c4ece8a
commit 9392aa0fca
1 changed files with 5 additions and 4 deletions

View File

@ -1288,17 +1288,18 @@ void UnitParticleSystem::updateParticle(Particle *p){
if(alternations > 0){
int interval= (maxParticleEnergy / alternations);
float moduloValue= (float)((int)(static_cast<float> (p->energy)) % interval);
float floatInterval=static_cast<float> (interval);
if(moduloValue < interval / 2){
energyRatio= (interval - moduloValue) / interval;
if(moduloValue < floatInterval / 2.0f){
energyRatio= (floatInterval - moduloValue) / floatInterval;
}
else{
energyRatio= moduloValue / interval;
energyRatio= moduloValue / floatInterval;
}
energyRatio= clamp(energyRatio, 0.f, 1.f);
}
else{
energyRatio= clamp(static_cast<float> (p->energy) / maxParticleEnergy, 0.f, 1.f);
energyRatio= clamp(static_cast<float> (p->energy) / static_cast<float> (maxParticleEnergy), 0.f, 1.f);
}
energyRatio = truncateDecimal<float>(energyRatio,6);