Minor code improvements

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8833 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2020-07-02 22:11:11 +00:00
parent de24b4df88
commit 00313a526b
3 changed files with 19 additions and 15 deletions
+13 -12
View File
@@ -2972,7 +2972,7 @@ UINT16 CalculateAmmoWeight( UINT16 usGunAmmoItem, UINT16 ubShotsLeft )
uiMinWeight = 1;
}
double weight = 0.0;
double weight = 0.5; //Pulmu:To round correctly
if(ubShotsLeft > 0)
{
@@ -2985,7 +2985,7 @@ UINT16 CalculateAmmoWeight( UINT16 usGunAmmoItem, UINT16 ubShotsLeft )
weight += (double)uiMinWeight + (( (double)ubShotsLeft / (double)Magazine[ Item[usGunAmmoItem].ubClassIndex ].ubMagSize) * ( (double)Item[usGunAmmoItem].ubWeight - (double)uiMinWeight ));
}
}
weight += 0.5; //Pulmu:To round correctly
return (UINT16)weight;
//Pulmu end
}
@@ -3010,11 +3010,10 @@ UINT16 CalculateObjectWeight( OBJECTTYPE *pObject )
weight += CalculateAmmoWeight(pObject->usItem, (*pObject)[cnt]->data.ubShotsLeft);
}
}
else {
// Start with base weight
weight = pItem->ubWeight;
//multiply by the number of objects, can be 0
weight *= pObject->ubNumberOfObjects;
else
{
// Start with base weight, multiply by the number of objects, can be 0
weight = pItem->ubWeight * pObject->ubNumberOfObjects;
}
}
else {
@@ -3040,7 +3039,7 @@ UINT16 OBJECTTYPE::GetWeightOfObjectInStack(unsigned int index)
UINT16 weight = pItem->ubWeight;
// Are we looking at an LBENODE item? New inventory only.
if ( pItem->usItemClass == IC_LBEGEAR && IsActiveLBE( index ) && ( UsingNewInventorySystem() == true ) )
if ( UsingNewInventorySystem() && IsActiveLBE( index ) )
{
LBENODE* pLBE = GetLBEPointer( index );
if ( pLBE )
@@ -3081,8 +3080,7 @@ UINT16 OBJECTTYPE::GetWeightOfObjectInStack(unsigned int index)
weight += Item[ (*this)[index]->data.gun.usGunAmmoItem ].ubWeight;
}
}
if ( gGameExternalOptions.fAmmoDynamicWeight && ( pItem->camouflagekit || pItem->canteen || pItem->drugtype || pItem->foodtype || usItem == JAR_ELIXIR ) )
else if ( gGameExternalOptions.fAmmoDynamicWeight && ( pItem->camouflagekit || pItem->canteen || pItem->drugtype || pItem->foodtype || usItem == JAR_ELIXIR ) )
{
weight *= (FLOAT)( ( *this )[index] )->data.objectStatus / 100.0f;
}
@@ -3150,8 +3148,11 @@ UINT32 CalculateCarriedWeight( SOLDIERTYPE * pSoldier, BOOLEAN fConsiderDragging
// Flugente: diseases can affect stat effectivity
INT16 diseaseeffect = 0;
for ( int i = 0; i < NUM_DISEASES; ++i )
diseaseeffect += Disease[i].sEffCarryStrength * pSoldier->GetDiseaseMagnitude( i );
if ( gGameExternalOptions.fDisease )
{
for ( int i = 0; i < NUM_DISEASES; ++i )
diseaseeffect += Disease[i].sEffCarryStrength * pSoldier->GetDiseaseMagnitude( i );
}
ubStrengthForCarrying = (ubStrengthForCarrying * (100 + diseaseeffect + pSoldier->GetBackgroundValue( BG_PERC_CARRYSTRENGTH )) / 100);
+5 -2
View File
@@ -52,8 +52,11 @@ INT16 EffectiveStrength( SOLDIERTYPE *pSoldier, BOOLEAN fTrainer )
// Flugente: diseases can affect stat effectivity
INT16 diseaseeffect = 0;
for ( int i = 0; i < NUM_DISEASES; ++i )
diseaseeffect += Disease[i].sEffStat[INFST_STR] * pSoldier->GetDiseaseMagnitude( i );
if ( gGameExternalOptions.fDisease )
{
for ( int i = 0; i < NUM_DISEASES; ++i )
diseaseeffect += Disease[i].sEffStat[INFST_STR] * pSoldier->GetDiseaseMagnitude( i );
}
iEffStrength = (iEffStrength * (100 + diseaseeffect + pSoldier->GetBackgroundValue( BG_STRENGTH ))) / 100;
+1 -1
View File
@@ -11283,7 +11283,7 @@ BOOLEAN SOLDIERTYPE::InternalDoMercBattleSound( UINT8 ubBattleSoundID, INT8 bSpe
}
}
UINT16 soundtoplay = 1 + Random( numBattleSounds_Npc[entrynum][pSoldier->ubBattleSoundID][ubSoundID] );
UINT32 soundtoplay = 1 + Random( numBattleSounds_Npc[entrynum][pSoldier->ubBattleSoundID][ubSoundID] );
sprintf( zFilename, "BATTLESNDS\\%s%d_%s%d", gBattleSndsNpcHelperData[entrynum].zName, pSoldier->ubBattleSoundID, gBattleSndsData[ubSoundID].zName, soundtoplay );