fixed negative value passed into PreRandom that could cause game to crash

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9198 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Shadooow
2021-10-27 00:21:47 +00:00
parent c7139a2569
commit 6d8e11931a
+14 -4
View File
@@ -4598,7 +4598,7 @@ void AttackTarget( SOLDIERCELL *pAttacker, SOLDIERCELL *pTarget )
ubLocation = AIM_SHOT_TORSO;
ubAccuracy = (UINT8)((usAttack - usDefence + PreRandom( usDefence - pTarget->usDefence )) / 10);
//ubAccuracy = (UINT8)((usAttack - usDefence + PreRandom( usDefence - pTarget->usDefence )) / 10);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SANDRO - increased mercs' offense/deffense rating
@@ -4672,7 +4672,7 @@ void AttackTarget( SOLDIERCELL *pAttacker, SOLDIERCELL *pTarget )
else
ubLocation = AIM_SHOT_TORSO;
ubAccuracy = (UINT8)((usAttack - usDefence + PreRandom( usDefence - pTarget->usDefence )) / 10);
//ubAccuracy = (UINT8)((usAttack - usDefence + PreRandom( usDefence - pTarget->usDefence )) / 10);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SANDRO - increased mercs' offense/deffense rating
@@ -4709,8 +4709,13 @@ void AttackTarget( SOLDIERCELL *pAttacker, SOLDIERCELL *pTarget )
ubLocation = AIM_SHOT_LEGS;
else
ubLocation = AIM_SHOT_TORSO;
if (usDefence >= pTarget->usDefence)
iRandom = PreRandom(usDefence - pTarget->usDefence);
else
iRandom = -PreRandom(pTarget->usDefence - usDefence);
ubAccuracy = (UINT8)((usAttack - usDefence + PreRandom( usDefence - pTarget->usDefence ) )/10);
ubAccuracy = (UINT8)((usAttack - usDefence + iRandom)/10);
// HEADROCK HAM 5: Added argument
iImpact = BulletImpact( pAttacker->pSoldier, NULL, pTarget->pSoldier, ubLocation, ubImpact, ubAccuracy, NULL );
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -4746,7 +4751,12 @@ void AttackTarget( SOLDIERCELL *pAttacker, SOLDIERCELL *pTarget )
return;
}
ubAccuracy = (UINT8)((usAttack - usDefence + PreRandom( usDefence - pTarget->usDefence ) )/10);
if (usDefence >= pTarget->usDefence)
iRandom = PreRandom(usDefence - pTarget->usDefence);
else
iRandom = -PreRandom(pTarget->usDefence - usDefence);
ubAccuracy = (UINT8)((usAttack - usDefence + iRandom)/10);
//Determine attacking weapon.
pAttacker->pSoldier->usAttackingWeapon = 0;