mirror of
https://github.com/1dot13/source.git
synced 2026-09-02 14:36:06 +02:00
Fix: crash due to overflow as a result of very low reliability values
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9088 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+6
-3
@@ -6296,17 +6296,20 @@ INT8 FireBulletGivenTargetTrapOnly( SOLDIERTYPE* pThrower, OBJECTTYPE* pObj, INT
|
|||||||
// Flugente : Added a malus to reliability for overheated guns
|
// Flugente : Added a malus to reliability for overheated guns
|
||||||
// HEADROCK HAM 5: Variable NCTH base change
|
// HEADROCK HAM 5: Variable NCTH base change
|
||||||
UINT32 uiDepreciateTest = 0;
|
UINT32 uiDepreciateTest = 0;
|
||||||
|
INT32 depreciatetest = 0;
|
||||||
if ( UsingNewCTHSystem() == true)
|
if ( UsingNewCTHSystem() == true)
|
||||||
{
|
{
|
||||||
UINT16 usBaseChance = gGameCTHConstants.BASIC_RELIABILITY_ODDS;
|
UINT16 usBaseChance = gGameCTHConstants.BASIC_RELIABILITY_ODDS;
|
||||||
FLOAT dReliabilityRatio = 3.0f * ((FLOAT)usBaseChance / (FLOAT)gItemSettings.usBasicDeprecateChance); // Compare original odds to new odds.
|
FLOAT dReliabilityRatio = 3.0f * ((FLOAT)usBaseChance / (FLOAT)gItemSettings.usBasicDeprecateChance); // Compare original odds to new odds.
|
||||||
uiDepreciateTest = usBaseChance + (INT16)( dReliabilityRatio * GetReliability( pObj ) - iOverheatReliabilityMalus);
|
depreciatetest = usBaseChance + (INT16)( dReliabilityRatio * GetReliability( pObj ) - iOverheatReliabilityMalus);
|
||||||
uiDepreciateTest = max(0, uiDepreciateTest);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uiDepreciateTest = max( gItemSettings.usBasicDeprecateChance + 3 * GetReliability( pObj ) - iOverheatReliabilityMalus, 0 );
|
depreciatetest = gItemSettings.usBasicDeprecateChance + 3 * GetReliability( pObj ) - iOverheatReliabilityMalus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiDepreciateTest = min( 100, max( 0, depreciatetest ) );
|
||||||
|
|
||||||
if ( !PreRandom( uiDepreciateTest ) && ( (*pObj)[0]->data.objectStatus > 1) )
|
if ( !PreRandom( uiDepreciateTest ) && ( (*pObj)[0]->data.objectStatus > 1) )
|
||||||
{
|
{
|
||||||
(*pObj)[0]->data.objectStatus--;
|
(*pObj)[0]->data.objectStatus--;
|
||||||
|
|||||||
+23
-12
@@ -2536,17 +2536,20 @@ BOOLEAN UseGunNCTH( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo )
|
|||||||
{
|
{
|
||||||
INT16 ammoReliability = Item[(*pObjAttHand)[0]->data.gun.usGunAmmoItem].bReliability;
|
INT16 ammoReliability = Item[(*pObjAttHand)[0]->data.gun.usGunAmmoItem].bReliability;
|
||||||
// HEADROCK HAM 5: Variable base chance
|
// HEADROCK HAM 5: Variable base chance
|
||||||
|
INT32 depreciatetest = 0;
|
||||||
if ( UsingNewCTHSystem() == true)
|
if ( UsingNewCTHSystem() == true)
|
||||||
{
|
{
|
||||||
UINT16 usBaseChance = gGameCTHConstants.BASIC_RELIABILITY_ODDS;
|
UINT16 usBaseChance = gGameCTHConstants.BASIC_RELIABILITY_ODDS;
|
||||||
FLOAT dReliabilityRatio = 3.0f * ((FLOAT)usBaseChance / (FLOAT)gItemSettings.usBasicDeprecateChance); // Compare original odds to new odds.
|
FLOAT dReliabilityRatio = 3.0f * ((FLOAT)usBaseChance / (FLOAT)gItemSettings.usBasicDeprecateChance); // Compare original odds to new odds.
|
||||||
uiDepreciateTest = usBaseChance + (INT16)( dReliabilityRatio * (Item[ iter->usItem ].bReliability + ammoReliability) );
|
depreciatetest = usBaseChance + (INT16)( dReliabilityRatio * (Item[ iter->usItem ].bReliability + ammoReliability) );
|
||||||
uiDepreciateTest = max(0, uiDepreciateTest);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uiDepreciateTest = max( 0, gItemSettings.usBasicDeprecateChance + 3 * (Item[iter->usItem].bReliability + ammoReliability) );
|
depreciatetest = gItemSettings.usBasicDeprecateChance + 3 * (Item[iter->usItem].bReliability + ammoReliability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiDepreciateTest = min( 100, max( 0, depreciatetest ) );
|
||||||
|
|
||||||
if ( !PreRandom( uiDepreciateTest ) && ( (*pObjAttHand)[0]->data.objectStatus > 1) )
|
if ( !PreRandom( uiDepreciateTest ) && ( (*pObjAttHand)[0]->data.objectStatus > 1) )
|
||||||
{
|
{
|
||||||
(*pA)[0]->data.objectStatus--;
|
(*pA)[0]->data.objectStatus--;
|
||||||
@@ -3039,18 +3042,20 @@ BOOLEAN UseGunNCTH( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo )
|
|||||||
|
|
||||||
// Flugente: Added a malus to reliability for overheated guns
|
// Flugente: Added a malus to reliability for overheated guns
|
||||||
// HEADROCK HAM 5: Variable NCTH base change
|
// HEADROCK HAM 5: Variable NCTH base change
|
||||||
|
INT32 depreciatetest = 0;
|
||||||
if ( UsingNewCTHSystem() == true)
|
if ( UsingNewCTHSystem() == true)
|
||||||
{
|
{
|
||||||
UINT16 usBaseChance = gGameCTHConstants.BASIC_RELIABILITY_ODDS;
|
UINT16 usBaseChance = gGameCTHConstants.BASIC_RELIABILITY_ODDS;
|
||||||
FLOAT dReliabilityRatio = 3.0f * ((FLOAT)usBaseChance / (FLOAT)gItemSettings.usBasicDeprecateChance); // Compare original odds to new odds.
|
FLOAT dReliabilityRatio = 3.0f * ((FLOAT)usBaseChance / (FLOAT)gItemSettings.usBasicDeprecateChance); // Compare original odds to new odds.
|
||||||
uiDepreciateTest = (UINT32)((usBaseChance + (INT16)( dReliabilityRatio * GetReliability( &(pSoldier->inv[pSoldier->ubAttackingHand]) ) - iOverheatReliabilityMalus)) / dirtincreasefactor);
|
uiDepreciateTest = (usBaseChance + (INT16)( dReliabilityRatio * GetReliability( &(pSoldier->inv[pSoldier->ubAttackingHand]) ) - iOverheatReliabilityMalus)) / dirtincreasefactor;
|
||||||
uiDepreciateTest = max(0, uiDepreciateTest);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uiDepreciateTest = max( (UINT32)((gItemSettings.usBasicDeprecateChance + 3 * GetReliability( pObjAttHand ) - iOverheatReliabilityMalus) / dirtincreasefactor), 0 );
|
depreciatetest = ( gItemSettings.usBasicDeprecateChance + 3 * GetReliability( pObjAttHand ) - iOverheatReliabilityMalus ) / dirtincreasefactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiDepreciateTest = min( 100, max( 0, depreciatetest ) );
|
||||||
|
|
||||||
if ( !PreRandom( uiDepreciateTest ) && ( (*pObjAttHand)[0]->data.objectStatus > 1) )
|
if ( !PreRandom( uiDepreciateTest ) && ( (*pObjAttHand)[0]->data.objectStatus > 1) )
|
||||||
{
|
{
|
||||||
(*pObjAttHand)[0]->data.objectStatus--;
|
(*pObjAttHand)[0]->data.objectStatus--;
|
||||||
@@ -3266,17 +3271,21 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo )
|
|||||||
{
|
{
|
||||||
INT16 ammoReliability = Item[(*pObjUsed)[0]->data.gun.usGunAmmoItem].bReliability;
|
INT16 ammoReliability = Item[(*pObjUsed)[0]->data.gun.usGunAmmoItem].bReliability;
|
||||||
// HEADROCK HAM 5: Variable base chance
|
// HEADROCK HAM 5: Variable base chance
|
||||||
|
|
||||||
|
INT32 depreciatetest = 0;
|
||||||
if ( UsingNewCTHSystem() == true )
|
if ( UsingNewCTHSystem() == true )
|
||||||
{
|
{
|
||||||
UINT16 usBaseChance = gGameCTHConstants.BASIC_RELIABILITY_ODDS;
|
UINT16 usBaseChance = gGameCTHConstants.BASIC_RELIABILITY_ODDS;
|
||||||
FLOAT dReliabilityRatio = 3.0f * ((FLOAT)usBaseChance / (FLOAT)gItemSettings.usBasicDeprecateChance); // Compare original odds to new odds.
|
FLOAT dReliabilityRatio = 3.0f * ((FLOAT)usBaseChance / (FLOAT)gItemSettings.usBasicDeprecateChance); // Compare original odds to new odds.
|
||||||
uiDepreciateTest = usBaseChance + (INT16)( dReliabilityRatio * (Item[ iter->usItem ].bReliability + ammoReliability) );
|
depreciatetest = usBaseChance + (INT16)( dReliabilityRatio * (Item[ iter->usItem ].bReliability + ammoReliability) );
|
||||||
uiDepreciateTest = __max(0, uiDepreciateTest);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uiDepreciateTest = __max( 0, gItemSettings.usBasicDeprecateChance + 3 * (Item[iter->usItem].bReliability + ammoReliability) );
|
depreciatetest = gItemSettings.usBasicDeprecateChance + 3 * (Item[iter->usItem].bReliability + ammoReliability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiDepreciateTest = min( 100, max( 0, depreciatetest ) );
|
||||||
|
|
||||||
if ( !PreRandom( uiDepreciateTest ) && ( (*pObjUsed)[0]->data.objectStatus > 1) )
|
if ( !PreRandom( uiDepreciateTest ) && ( (*pObjUsed)[0]->data.objectStatus > 1) )
|
||||||
{
|
{
|
||||||
(*pA)[0]->data.objectStatus--;
|
(*pA)[0]->data.objectStatus--;
|
||||||
@@ -3803,18 +3812,20 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Flugente: Added a malus to reliability for overheated guns
|
// Flugente: Added a malus to reliability for overheated guns
|
||||||
|
INT32 depreciatetest = 0;
|
||||||
if ( UsingNewCTHSystem() == true )
|
if ( UsingNewCTHSystem() == true )
|
||||||
{
|
{
|
||||||
UINT16 usBaseChance = gGameCTHConstants.BASIC_RELIABILITY_ODDS;
|
UINT16 usBaseChance = gGameCTHConstants.BASIC_RELIABILITY_ODDS;
|
||||||
FLOAT dReliabilityRatio = 3.0f * ((FLOAT)usBaseChance / (FLOAT)gItemSettings.usBasicDeprecateChance); // Compare original odds to new odds.
|
FLOAT dReliabilityRatio = 3.0f * ((FLOAT)usBaseChance / (FLOAT)gItemSettings.usBasicDeprecateChance); // Compare original odds to new odds.
|
||||||
uiDepreciateTest = (UINT32)(usBaseChance + (INT16)( dReliabilityRatio * GetReliability( &(pSoldier->inv[ pSoldier->ubAttackingHand ])) - iOverheatReliabilityMalus) / dirtincreasefactor);
|
uiDepreciateTest = usBaseChance + (INT16)( dReliabilityRatio * GetReliability( &(pSoldier->inv[ pSoldier->ubAttackingHand ])) - iOverheatReliabilityMalus) / dirtincreasefactor;
|
||||||
uiDepreciateTest = max(0, uiDepreciateTest);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uiDepreciateTest = max( (UINT32)((gItemSettings.usBasicDeprecateChance + 3 * (GetReliability( pObjUsed )) - iOverheatReliabilityMalus) / dirtincreasefactor), 0 );
|
depreciatetest = (gItemSettings.usBasicDeprecateChance + 3 * (GetReliability( pObjUsed )) - iOverheatReliabilityMalus) / dirtincreasefactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiDepreciateTest = min( 100, max( 0, depreciatetest ) );
|
||||||
|
|
||||||
if ( !PreRandom( uiDepreciateTest ) && ( (*pObjUsed)[0]->data.objectStatus > 1) )
|
if ( !PreRandom( uiDepreciateTest ) && ( (*pObjUsed)[0]->data.objectStatus > 1) )
|
||||||
{
|
{
|
||||||
(*pObjUsed)[0]->data.objectStatus--;
|
(*pObjUsed)[0]->data.objectStatus--;
|
||||||
|
|||||||
Reference in New Issue
Block a user