From f91d1a0be91f692796450243f9725dc978576371 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 2 Mar 2014 14:12:05 +0000 Subject: [PATCH] Merged revision(s) 7006 from branches/ja2_source_official_2014: Fix: in certain conditions, radio operators were not correctly identified to be jamming communications git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7007 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Militia Control.cpp | 6 ++---- Tactical/Soldier Control.cpp | 19 ++++++++++--------- Tactical/Soldier Control.h | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Tactical/Militia Control.cpp b/Tactical/Militia Control.cpp index b77eee29..fc2b44a6 100644 --- a/Tactical/Militia Control.cpp +++ b/Tactical/Militia Control.cpp @@ -1084,10 +1084,8 @@ BOOLEAN CheckIfRadioIsEquipped( void ) { return TRUE; } - else - { - return FALSE; - } + + return FALSE; } diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index af04fe5f..2034777c 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -17272,7 +17272,7 @@ STR16 SOLDIERTYPE::PrintSkillDesc( INT8 iSkill ) return skilldescarray; } -BOOLEAN SOLDIERTYPE::CanUseRadio() +BOOLEAN SOLDIERTYPE::CanUseRadio(BOOLEAN fCheckForAP) { // new inventory system required, as the radio set has to be in a specific slot if ( !UsingNewInventorySystem() ) @@ -17282,7 +17282,8 @@ BOOLEAN SOLDIERTYPE::CanUseRadio() if ( !NUM_SKILL_TRAITS( this, RADIO_OPERATOR_NT ) ) return FALSE; - if ( !EnoughPoints( this, APBPConstants[AP_RADIO], 0, FALSE ) ) + // if we check wether we have enough AP, exit if we don't + if ( fCheckForAP && !EnoughPoints( this, APBPConstants[AP_RADIO], 0, FALSE ) ) return FALSE; // only player mercs use new inventory system @@ -17933,7 +17934,7 @@ BOOLEAN SOLDIERTYPE::OrderArtilleryStrike( UINT32 usSectorNr, INT32 sTargetGridN BOOLEAN SOLDIERTYPE::IsJamming() { - return ( (bSoldierFlagMask & SOLDIER_RADIO_OPERATOR_JAMMING) && CanUseRadio() ); + return ( (bSoldierFlagMask & SOLDIER_RADIO_OPERATOR_JAMMING) && CanUseRadio(FALSE) ); } BOOLEAN SOLDIERTYPE::JamCommunications() @@ -17963,7 +17964,7 @@ BOOLEAN SOLDIERTYPE::JamCommunications() BOOLEAN SOLDIERTYPE::IsScanning() { - return ( (bSoldierFlagMask & SOLDIER_RADIO_OPERATOR_SCANNING) && CanUseRadio() ); + return ( (bSoldierFlagMask & SOLDIER_RADIO_OPERATOR_SCANNING) && CanUseRadio(FALSE) ); } BOOLEAN SOLDIERTYPE::ScanForJam() @@ -17993,7 +17994,7 @@ BOOLEAN SOLDIERTYPE::ScanForJam() BOOLEAN SOLDIERTYPE::IsRadioListening() { - return ( (bSoldierFlagMask & SOLDIER_RADIO_OPERATOR_LISTENING) && CanUseRadio() ); + return ( (bSoldierFlagMask & SOLDIER_RADIO_OPERATOR_LISTENING) && CanUseRadio(FALSE) ); } BOOLEAN SOLDIERTYPE::RadioListen() @@ -18080,7 +18081,7 @@ SOLDIERTYPE::RadioFail() void SOLDIERTYPE::DepleteActiveRadioSetEnergy(BOOLEAN fActivation, BOOLEAN fAssignment) { - if ( !CanUseRadio() ) + if ( !CanUseRadio(FALSE) ) return; FLOAT cost = 0; @@ -21330,7 +21331,7 @@ BOOLEAN GetRadioOperatorSignal(UINT8 usOwner, INT32* psTargetGridNo) // a merc planted this - if he's a radio operator, use his gridno SOLDIERTYPE* pSoldier = MercPtrs[usOwner - 2]; - if ( pSoldier && pSoldier->CanUseRadio() && pSoldier->bActive && pSoldier->bInSector && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) ) + if ( pSoldier && pSoldier->CanUseRadio(FALSE) && pSoldier->bActive && pSoldier->bInSector && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) ) { *psTargetGridNo = pSoldier->sGridNo; pSoldier->bSide; @@ -21349,7 +21350,7 @@ BOOLEAN GetRadioOperatorSignal(UINT8 usOwner, INT32* psTargetGridNo) INT32 lastid = gTacticalStatus.Team[ bTeam ].bLastID; for ( pSoldier = MercPtrs[ cnt ]; cnt < lastid; ++cnt, ++pSoldier) { - if ( pSoldier && pSoldier->CanUseRadio() && pSoldier->bActive && pSoldier->bInSector && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) ) + if ( pSoldier && pSoldier->CanUseRadio(FALSE) && pSoldier->bActive && pSoldier->bInSector && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) ) { *psTargetGridNo = pSoldier->sGridNo; pSoldier->bSide; @@ -21409,7 +21410,7 @@ BOOLEAN IsValidArtilleryOrderSector( INT16 sSectorX, INT16 sSectorY, INT8 bSecto if ( !pSoldier || !pSoldier->bActive || pSoldier->sSectorX != sSectorX || pSoldier->sSectorY != sSectorY || pSoldier->bSectorZ != bSectorZ || pSoldier->bAssignment > ON_DUTY ) continue; - if ( pSoldier->CanUseRadio() ) + if ( pSoldier->CanUseRadio(FALSE) ) activeradio = TRUE; if ( pSoldier->HasMortar() ) diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h index c4742b45..b441e733 100644 --- a/Tactical/Soldier Control.h +++ b/Tactical/Soldier Control.h @@ -1798,7 +1798,7 @@ public: STR16 PrintSkillDesc( INT8 iSkill); // Flugente: functions for the radio operator trait - BOOLEAN CanUseRadio(); // can we use radio, if we even have one? + BOOLEAN CanUseRadio(BOOLEAN fCheckForAP = TRUE); // can we use radio, if we even have one? BOOLEAN UseRadio(); // simply drain the batteries BOOLEAN HasMortar(); BOOLEAN GetSlotOfSignalShellIfMortar(UINT8* pbLoop); // if we have a mortar and a fitting signal shell, return the inventory slot it is in