From 4b646aad968bec5abbc948d5ab5e0880456a4148 Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Sun, 24 Oct 2021 15:02:27 +0000 Subject: [PATCH] GetSightAdjustmentCamouflageOnTerrain: fix signed/unsigned calculation, limit effectiveness to +-100. GetDetailedSightAdjustmentCamouflageOnTerrain: fix signed/unsigned calculation. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9194 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/LOS.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp index 88d02d5a..09c0ef8b 100644 --- a/Tactical/LOS.cpp +++ b/Tactical/LOS.cpp @@ -632,15 +632,16 @@ INT8 GetSightAdjustmentCamouflageOnTerrain( SOLDIERTYPE* pSoldier, const UINT8& INT16 scaler = -(ANIM_STAND+1 - ubStance); // stand = 7-6 => 10%, crouch = 7-3 => 66%, prone = 7-1 => 100%; - UINT8 effectiveness = gGameExternalOptions.ubCamouflageEffectiveness; - - effectiveness += (UINT8)(pSoldier->GetBackgroundValue(BG_PERC_CAMO)); + INT16 effectiveness = gGameExternalOptions.ubCamouflageEffectiveness + pSoldier->GetBackgroundValue(BG_PERC_CAMO); if (ProfileHasSkillTrait(pSoldier->ubProfile, SURVIVAL_NT)) { effectiveness += gSkillTraitValues.ubSVCamoEffectivenessBonus; } + effectiveness = min(100, effectiveness); + effectiveness = max(-100, effectiveness); + scaler = effectiveness * scaler / 6; switch(ubTerrainType) { @@ -675,9 +676,7 @@ INT8 GetDetailedSightAdjustmentCamouflageOnTerrain( SOLDIERTYPE* pSoldier, const INT16 scaler = -(ANIM_STAND+1 - max(ANIM_PRONE, ubStance - bStanceModifier)); // stand = 7-6 => 10%, crouch = 7-3 => 66%, prone = 7-1 => 100%; - UINT8 effectiveness = gGameExternalOptions.ubCamouflageEffectiveness; - - effectiveness += (UINT8)(pSoldier->GetBackgroundValue(BG_PERC_CAMO)); + INT16 effectiveness = gGameExternalOptions.ubCamouflageEffectiveness + pSoldier->GetBackgroundValue(BG_PERC_CAMO); if (ProfileHasSkillTrait(pSoldier->ubProfile, SURVIVAL_NT)) {