From 5e5103635a18b16a32ffa222c0c05a2e7b0307a1 Mon Sep 17 00:00:00 2001 From: Flugente Date: Wed, 10 Apr 2013 22:52:35 +0000 Subject: [PATCH] Fix: no bullet when not targetting a soldier git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5992 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Drugs And Alcohol.cpp | 2 -- Tactical/Weapons.cpp | 12 ++++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Tactical/Drugs And Alcohol.cpp b/Tactical/Drugs And Alcohol.cpp index e58be6d8d..ec752aad1 100644 --- a/Tactical/Drugs And Alcohol.cpp +++ b/Tactical/Drugs And Alcohol.cpp @@ -259,8 +259,6 @@ void HandleEndTurnDrugAdjustments( SOLDIERTYPE *pSoldier ) // We test for every 'pure' drug separately for (cnt = DRUG_TYPE_ADRENALINE; cnt < DRUG_TYPE_MAX; ++cnt) { - UINT32 drugtestflag = (1 << cnt); // comparing with this flag will determine the drug - // omit DRUG_TYPE_REGENERATION, because that is checked afterwards separately if ( cnt == DRUG_TYPE_REGENERATION ) continue; diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 7e76b358d..ef44fd94b 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -4990,7 +4990,11 @@ UINT32 CalcNewChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTi } // Flugente: moved trait modifiers into a member function - iTraitModifier = pSoldier->GetTraitCTHModifier( usInHand, ubAimTime, pTarget->ubProfile ); + UINT8 targetprofile = NOBODY; + if ( pTarget && pTarget->ubProfile != NOBODY ) + targetprofile = pTarget->ubProfile; + + iTraitModifier = pSoldier->GetTraitCTHModifier( usInHand, ubAimTime, targetprofile ); // SHOOTING AT SAME TARGET AGAIN if (sGridNo == pSoldier->sLastTarget ) @@ -6459,7 +6463,11 @@ UINT32 CalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTime, ///////////////////////////////////////////////////////////////////////////////////// // Modify for traits // Flugente: moved trait modifiers into a member function - iChance += pSoldier->GetTraitCTHModifier( usInHand, ubAimTime, pTarget->ubProfile ); + UINT8 targetprofile = NOBODY; + if ( pTarget && pTarget->ubProfile != NOBODY ) + targetprofile = pTarget->ubProfile; + + iChance += pSoldier->GetTraitCTHModifier( usInHand, ubAimTime, targetprofile ); /////////////////////////////////////////////////////////////////////////////////////