From 59646b9dcd0547bab5c45649e3d4c3474084a318 Mon Sep 17 00:00:00 2001 From: Flugente Date: Mon, 6 May 2013 23:35:17 +0000 Subject: [PATCH] - Fix: crash when switching to bayonet while aimed - Fix: batteries were drained for inactive flashlights git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6067 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Item Types.h | 2 +- Tactical/Soldier Control.cpp | 31 +++++++++++++++++-------------- Tactical/UI Cursors.cpp | 4 ++++ 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Tactical/Item Types.h b/Tactical/Item Types.h index 1cb634f5e..fb20038fe 100644 --- a/Tactical/Item Types.h +++ b/Tactical/Item Types.h @@ -669,7 +669,7 @@ extern OBJECTTYPE gTempObject; #define AC_FEEDER 0x00800000 //8388608 // allow external feeding #define AC_MODPOUCH 0x01000000 //16777216 // for new modular pouches #define AC_RIFLEGRENADE 0x02000000 //33554432 // GL, needs a bullet and blocks other firing modes -#define AC_MISC15 0x04000000 //67108864 +#define AC_BAYONET 0x04000000 //67108864 #define AC_MISC16 0x08000000 //134217728 #define AC_MISC17 0x10000000 //268435456 #define AC_MISC18 0x20000000 //536870912 diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 98eaa934e..8079c9d9b 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -13717,8 +13717,11 @@ void SOLDIERTYPE::SoldierInventoryCoolDown(void) if ( !flashlightfound ) { attachmentList::iterator iterend = (*pObj)[0]->attachments.end(); - for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != iterend; ++iter) - flashlightfound = TRUE; + for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != iterend; ++iter) + { + if ( Item [ iter->usItem ].usFlashLightRange ) + flashlightfound = TRUE; + } } if ( flashlightfound ) @@ -16294,21 +16297,21 @@ void SOLDIERTYPE::HandleFlashLights() { UINT8 flashlightrange = this->GetBestEquippedFlashLightRange(); - // the range at which we create additional light sources to the side - UINT8 firstexpand = 8; - UINT8 secondexpand = 12; - - // depending on our direction, alter range - if ( this->ubDirection == NORTHEAST || this->ubDirection == NORTHWEST || this->ubDirection == SOUTHEAST || this->ubDirection == SOUTHWEST ) - { - flashlightrange = sqrt( (FLOAT)flashlightrange*(FLOAT)flashlightrange / 2.0f ); - firstexpand = sqrt( (FLOAT)firstexpand*(FLOAT)firstexpand / 2.0f ); - secondexpand = sqrt( (FLOAT)secondexpand*(FLOAT)secondexpand / 2.0f ); - } - // if no flashlight is found, this will be 0 if ( flashlightrange ) { + // the range at which we create additional light sources to the side + UINT8 firstexpand = 8; + UINT8 secondexpand = 12; + + // depending on our direction, alter range + if ( this->ubDirection == NORTHEAST || this->ubDirection == NORTHWEST || this->ubDirection == SOUTHEAST || this->ubDirection == SOUTHWEST ) + { + flashlightrange = sqrt( (FLOAT)flashlightrange*(FLOAT)flashlightrange / 2.0f ); + firstexpand = sqrt( (FLOAT)firstexpand*(FLOAT)firstexpand / 2.0f ); + secondexpand = sqrt( (FLOAT)secondexpand*(FLOAT)secondexpand / 2.0f ); + } + // we determine the height of the next tile in our direction. Because of the way structures are handled, we sometimes have to take the very tile we're occupying right now INT32 nextGridNoinSight = this->sGridNo; diff --git a/Tactical/UI Cursors.cpp b/Tactical/UI Cursors.cpp index 8cc65f78e..fdd943052 100644 --- a/Tactical/UI Cursors.cpp +++ b/Tactical/UI Cursors.cpp @@ -1628,6 +1628,10 @@ UINT8 HandleKnifeCursor( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fActivate // DRAW PATH TO GUY HandleUIMovementCursor( pSoldier, uiCursorFlags, sGridNo, MOVEUI_TARGET_MERCS ); + // Flugente: if we are using a bayonet, adjust aimtime + if ( pSoldier->bWeaponMode == WM_ATTACHED_BAYONET && pSoldier->aiData.bShownAimTime != REFINE_KNIFE_1 ) + pSoldier->aiData.bShownAimTime = REFINE_KNIFE_2; + if ( fActivated ) { DetermineCursorBodyLocation( pSoldier->ubID, TRUE, TRUE );