From 891a17d859f6c995d5f70bd931ca9afbb2688d5b Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Fri, 30 Apr 2021 20:54:27 +0000 Subject: [PATCH] Fix for not enough action points error message not appearing when using consumable without enough AP in turn based mode. (The message got overriden with another one -> "Huh?") (by Shadooow) Additionally fixed empty canteens to consume AP just to do nothing. Empty canteen now throws the Huh? error. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8993 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/mapscreen.cpp | 5 +++-- Tactical/Soldier Control.cpp | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 85f38aabf..89e2b84d8 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -9508,11 +9508,12 @@ void MAPInvClickCamoCallback( MOUSE_REGION *pRegion, INT32 iReason ) // We are doing this ourselve, continue if ( pSoldier->stats.bLife >= CONSCIOUSNESS ) { - if ( ApplyConsumable( pSoldier, gpItemPointer, FALSE, TRUE ) ) + BOOLEAN bApplyConsumable = ApplyConsumable(pSoldier, gpItemPointer, FALSE, TRUE); + if (bApplyConsumable == TRUE) { UpdateMercBodyRegionHelpText( ); } - else + else if(!bApplyConsumable) { // Send message //Heinz: 23.02.09 BUGFIX: Don't send message when SKI is on diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index bc764c211..5632328dc 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -22738,7 +22738,7 @@ void SOLDIERTYPE::EVENT_SoldierApplyItemToPerson( INT32 sGridNo, UINT8 ubDirecti { success = AutoPlaceObject( pSoldier, pObj, FALSE ); } - else if ( ApplyConsumable( pSoldier, pObj, TRUE, TRUE ) ) + else if ( ApplyConsumable( pSoldier, pObj, TRUE, TRUE ) == TRUE) { success = TRUE; } @@ -25729,13 +25729,14 @@ void HandleVolunteerRecruitment( SOLDIERTYPE* pRecruiter, SOLDIERTYPE* pTarget ) } // Flugente: apply a consumable item on a soldier. Returns true if item was successfully interacted with -BOOLEAN ApplyConsumable( SOLDIERTYPE* pSoldier, OBJECTTYPE *pObj, BOOLEAN fForce, BOOLEAN fUseAPs ) +// Shadooow: Now returns 2 in case that the action failed due to the not enough action points! +BOOLEAN ApplyConsumable(SOLDIERTYPE* pSoldier, OBJECTTYPE *pObj, BOOLEAN fForce, BOOLEAN fUseAPs) { - if ( !pSoldier || !pObj ) + if (!pSoldier || !pObj) return FALSE; // if it's not a kit or a misc item, we cannot consume it - if ( !(Item[pObj->usItem].usItemClass & (IC_KIT | IC_MISC)) ) + if (!(Item[pObj->usItem].usItemClass & (IC_KIT | IC_MISC))) return FALSE; BOOLEAN fSuccess = FALSE; @@ -25743,12 +25744,12 @@ BOOLEAN ApplyConsumable( SOLDIERTYPE* pSoldier, OBJECTTYPE *pObj, BOOLEAN fForce // use portionsize, if none was entered, use full item UINT8 portionsize = Item[pObj->usItem].usPortionSize; - if ( !portionsize ) + if (!portionsize) portionsize = 100; // how much of this item do we use up - UINT16 statusused = min( portionsize, (*pObj)[0]->data.objectStatus ); - if ( !statusused ) + UINT16 statusused = min(portionsize, (*pObj)[0]->data.objectStatus); + if (!statusused || (statusused == 1 && Item[pObj->usItem].canteen)) return FALSE; INT16 apcost = 0; @@ -25804,7 +25805,7 @@ BOOLEAN ApplyConsumable( SOLDIERTYPE* pSoldier, OBJECTTYPE *pObj, BOOLEAN fForce if ( !fForce && !EnoughPoints( pSoldier, apcost, 0, TRUE ) ) { - return FALSE; + return 2; } }