Aivolution:
Attempt to avoid division by 0. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4280 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
a1008c093d
commit
5045ee4d27
|
@ -15437,13 +15437,18 @@ function int LanchasterTimeToWin(float _fStartForceA, float _fStartForceB,
|
|||
{
|
||||
local float _fTimeToWin,_fKillFactor;
|
||||
|
||||
if(_fStartForceA <= 0.0 or _fStartForceB <= 0.0){
|
||||
if(_fStartForceA <= 0.0 or _fStartForceB <= 0.0 or _fKillRateB == 0.0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
_fKillFactor = (_fStartForceB / _fStartForceA) *
|
||||
sqrt(_fKillRateA / _fKillRateB);
|
||||
|
||||
// avoid division by 0
|
||||
if( (1.0 - _fKillFactor) == 0.0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
_fTimeToWin = 1.0 / (2.0 * sqrt(_fKillRateA * _fKillRateB)) *
|
||||
log ( (1.0 + _fKillFactor) / (1.0 - _fKillFactor) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue