From 56262574920e8f4c1afa2b559a5f6c5aa6a34238 Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Mon, 19 Apr 2021 06:18:24 +0000 Subject: [PATCH] Improved r8961: - removed unneeded checks in BtnClimbCallback - improved code in UpdateSMPanel, check if crouched stance is valid when enabling jump button Warnings fixes. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8962 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Interface Panels.cpp | 68 ++++++++++------------------------- 1 file changed, 18 insertions(+), 50 deletions(-) diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index 791aa040a..28a59af73 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -958,41 +958,30 @@ void UpdateSMPanel( ) GetMercClimbDirection( gpSMCurrentMerc->ubID, &fNearLowerLevel, &fNearHeigherLevel ); - if ( fNearLowerLevel || fNearHeigherLevel ) + if (fNearLowerLevel || fNearHeigherLevel) { - if ( fNearLowerLevel ) + if (IsValidStance(gpSMCurrentMerc, ANIM_CROUCH) && EnoughPoints(gpSMCurrentMerc, GetAPsToClimbRoof(gpSMCurrentMerc, fNearLowerLevel), GetBPsToClimbRoof(gpSMCurrentMerc, fNearLowerLevel), FALSE)) { - if ( EnoughPoints( gpSMCurrentMerc, GetAPsToClimbRoof( gpSMCurrentMerc, TRUE ), 0, FALSE ) ) - { - EnableButton( iSMPanelButtons[ CLIMB_BUTTON ] ); - } - } - - if ( fNearHeigherLevel ) - { - if ( EnoughPoints( gpSMCurrentMerc, GetAPsToClimbRoof( gpSMCurrentMerc, FALSE ), 0, FALSE ) ) - { - EnableButton( iSMPanelButtons[ CLIMB_BUTTON ] ); - } + EnableButton(iSMPanelButtons[CLIMB_BUTTON]); } } - + if (gGameExternalOptions.fCanClimbOnWalls == TRUE) { - if ( FindWallJumpDirection( gpSMCurrentMerc, gpSMCurrentMerc->sGridNo, gpSMCurrentMerc->ubDirection, &bDirection ) ) - { - if ( EnoughPoints( gpSMCurrentMerc, GetAPsToJumpWall( gpSMCurrentMerc, FALSE ), 0, FALSE ) ) + if (FindWallJumpDirection(gpSMCurrentMerc, gpSMCurrentMerc->sGridNo, gpSMCurrentMerc->ubDirection, &bDirection)) + { + if (IsValidStance(gpSMCurrentMerc, ANIM_CROUCH) && EnoughPoints(gpSMCurrentMerc, GetAPsToJumpWall(gpSMCurrentMerc, FALSE), GetBPsToJumpWall(gpSMCurrentMerc, FALSE), FALSE)) { - EnableButton( iSMPanelButtons[ CLIMB_BUTTON ] ); + EnableButton(iSMPanelButtons[CLIMB_BUTTON]); } - } + } } - if ( FindFenceJumpDirection( gpSMCurrentMerc, gpSMCurrentMerc->sGridNo, gpSMCurrentMerc->ubDirection, &bDirection ) ) + if (FindFenceJumpDirection(gpSMCurrentMerc, gpSMCurrentMerc->sGridNo, gpSMCurrentMerc->ubDirection, &bDirection)) { - if ( EnoughPoints( gpSMCurrentMerc, GetAPsToJumpFence( gpSMCurrentMerc, FALSE ), 0, FALSE ) ) + if (IsValidStance(gpSMCurrentMerc, ANIM_CROUCH) && EnoughPoints(gpSMCurrentMerc, GetAPsToJumpFence(gpSMCurrentMerc, FALSE), GetBPsToJumpFence(gpSMCurrentMerc, FALSE), FALSE)) { - EnableButton( iSMPanelButtons[ CLIMB_BUTTON ] ); + EnableButton(iSMPanelButtons[CLIMB_BUTTON]); } } @@ -2960,7 +2949,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) SetRegionHelpEndCallback( &gSM_SELMERCCamoRegion, SkiHelpTextDoneCallBack ); // Flugente: weight help text - FLOAT totalweight = GetTotalWeight( gpSMCurrentMerc ); + FLOAT totalweight = (FLOAT)GetTotalWeight( gpSMCurrentMerc ); swprintf( pStr, gzMiscItemStatsFasthelp[35], totalweight / 10.0 ); SetRegionFastHelpText( &(gSM_SELMERCWeightRegion), pStr ); @@ -4626,15 +4615,6 @@ void BtnClimbCallback(GUI_BUTTON *btn,INT32 reason) { btn->uiFlags &= (~BUTTON_CLICKED_ON ); - if (!IsValidStance(gpSMCurrentMerc, ANIM_CROUCH)) - { - if (gpSMCurrentMerc->bCollapsed && gpSMCurrentMerc->bBreath < OKBREATH) - { - ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, gzLateLocalizedString[4], gpSMCurrentMerc->GetName()); - } - return; - } - GetMercClimbDirection( gpSMCurrentMerc->ubID, &fNearLowerLevel, &fNearHeigherLevel ); if ( fNearLowerLevel ) @@ -4648,10 +4628,7 @@ void BtnClimbCallback(GUI_BUTTON *btn,INT32 reason) return; } - if (EnoughPoints(gpSMCurrentMerc, GetAPsToClimbRoof(gpSMCurrentMerc, TRUE), GetBPsToClimbRoof(gpSMCurrentMerc, TRUE), FALSE)) - { - gpSMCurrentMerc->BeginSoldierClimbDownRoof(); - } + gpSMCurrentMerc->BeginSoldierClimbDownRoof(); } if ( fNearHeigherLevel ) @@ -4665,10 +4642,7 @@ void BtnClimbCallback(GUI_BUTTON *btn,INT32 reason) return; } - if (EnoughPoints(gpSMCurrentMerc, GetAPsToClimbRoof(gpSMCurrentMerc, FALSE), GetBPsToClimbRoof(gpSMCurrentMerc, FALSE), FALSE)) - { - gpSMCurrentMerc->BeginSoldierClimbUpRoof(); - } + gpSMCurrentMerc->BeginSoldierClimbUpRoof(); } //---------------Legion by JAzz----------- @@ -4686,10 +4660,7 @@ void BtnClimbCallback(GUI_BUTTON *btn,INT32 reason) if ( FindWallJumpDirection( gpSMCurrentMerc, gpSMCurrentMerc->sGridNo, gpSMCurrentMerc->ubDirection, &bDirection ) ) { - if (EnoughPoints(gpSMCurrentMerc, GetAPsToJumpWall(gpSMCurrentMerc, FALSE), GetBPsToJumpWall(gpSMCurrentMerc, FALSE), FALSE)) - { - gpSMCurrentMerc->BeginSoldierClimbWall(); - } + gpSMCurrentMerc->BeginSoldierClimbWall(); } } @@ -4706,10 +4677,7 @@ void BtnClimbCallback(GUI_BUTTON *btn,INT32 reason) return; } - if (EnoughPoints(gpSMCurrentMerc, GetAPsToJumpFence(gpSMCurrentMerc, FALSE), GetBPsToJumpFence(gpSMCurrentMerc, FALSE), FALSE)) - { - gpSMCurrentMerc->BeginSoldierClimbFence(); - } + gpSMCurrentMerc->BeginSoldierClimbFence(); } } else if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE ) @@ -7215,7 +7183,7 @@ UINT8 FindNextMercInTeamPanel( SOLDIERTYPE *pSoldier, BOOLEAN fGoodForLessOKLife if ( pNewSoldier->bAssignment != iCurrentSquad ) { - if ( gGameExternalOptions.fUseXMLSquadNames && pNewSoldier->bAssignment < min(ON_DUTY, gSquadNameVector.size()) ) + if ( gGameExternalOptions.fUseXMLSquadNames && pNewSoldier->bAssignment < min(ON_DUTY, (INT8)gSquadNameVector.size()) ) ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[MSG_SQUAD_ACTIVE_STRING], gSquadNameVector[pNewSoldier->bAssignment].c_str() ); else //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE ], ( CurrentSquad( ) + 1 ) );