From 728f7267e0a47d814c36e03af20ec9c236c5e331 Mon Sep 17 00:00:00 2001 From: silversurfer Date: Fri, 13 Sep 2013 17:03:56 +0000 Subject: [PATCH] Bugfix for item handling When you click at an item with a valid attachment at the hand cursor the game will no longer move that item to an empty slot and instead open the UDB. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6401 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Interface Panels.cpp | 36 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index 0bdc8c8e1..c15fdc7c8 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -3954,27 +3954,22 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason ) } return; } - - if ( uiHandPos == HANDPOS || uiHandPos == SECONDHANDPOS || uiHandPos == HELMETPOS || uiHandPos == VESTPOS || uiHandPos == LEGPOS )//dnl ch66 070913 without this condition we have option to attach and merge with left click too, and solve problem with CanItemFitInPosition which return TRUE if slot has weapon and we try to put clip or attachment or grenade which fits + + // we allow attaching on items in any slot + if ( ValidAttachment( usNewItemIndex, &(gpSMCurrentMerc->inv[uiHandPos]) ) ) { - //if ( ValidAttachmentClass( usNewItemIndex, usOldItemIndex ) ) - if ( ValidAttachment( usNewItemIndex, &(gpSMCurrentMerc->inv[uiHandPos]) ) ) + // it's an attempt to attach; bring up the inventory panel + if ( !InItemDescriptionBox( ) ) { - // removed because of problems with attaching when INV_AP_COST is on -// if(INV_AP_COST && (gTacticalStatus.uiFlags & INCOMBAT) && !(uiHandPos == HANDPOS || uiHandPos == SECONDHANDPOS || uiHandPos == HELMETPOS || uiHandPos == VESTPOS || uiHandPos == LEGPOS))//dnl ch66 070913 if INV_AP_COST is active then attach or merge is allowed only in those slots -// return; - // it's an attempt to attach; bring up the inventory panel - if ( !InItemDescriptionBox( ) ) - { - InitItemDescriptionBox( gpSMCurrentMerc, (UINT8)uiHandPos, ITEMDESC_START_X, ITEMDESC_START_Y, 0 ); - } - return; + InitItemDescriptionBox( gpSMCurrentMerc, (UINT8)uiHandPos, ITEMDESC_START_X, ITEMDESC_START_Y, 0 ); } - else if ( ValidMerge( usNewItemIndex, usOldItemIndex ) ) + return; + } + + if ( uiHandPos == HANDPOS || uiHandPos == SECONDHANDPOS || uiHandPos == HELMETPOS || uiHandPos == VESTPOS || uiHandPos == LEGPOS ) + { + if ( ValidMerge( usNewItemIndex, usOldItemIndex ) ) { - // removed because of problems with putting items on top of stack when INV_AP_COST is on -// if(INV_AP_COST && (gTacticalStatus.uiFlags & INCOMBAT) && !(uiHandPos == HANDPOS || uiHandPos == SECONDHANDPOS || uiHandPos == HELMETPOS || uiHandPos == VESTPOS || uiHandPos == LEGPOS))//dnl ch66 070913 if INV_AP_COST is active then attach or merge is allowed only in those slots -// return; // bring up merge requestor gubHandPos = (UINT8) uiHandPos; gusOldItemIndex = usOldItemIndex; @@ -3993,9 +3988,6 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason ) DoMessageBox( MSG_BOX_BASIC_STYLE, Message[ STR_MERGE_ITEMS ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, MergeMessageBoxCallBack, NULL ); return; } - // removed because of problems when INV_AP_COST is on -// else if(INV_AP_COST && (gTacticalStatus.uiFlags & INCOMBAT) && !(uiHandPos == HANDPOS || uiHandPos == SECONDHANDPOS) && CompatibleAmmoForGun(gpItemPointer, &gpSMCurrentMerc->inv[uiHandPos]))//dnl ch66 070913 if INV_AP_COST is active then reload is not allowed if weapon not in HANDPOS -// return; // else handle normally } @@ -4148,8 +4140,7 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason ) // access description box directly if CTRL is pressed for stack items if( !( ( gpSMCurrentMerc->inv[ uiHandPos ].ubNumberOfObjects > 1 && isLimit > 0 ) && ( guiCurrentScreen != MAP_SCREEN ) ) || _KeyDown( CTRL ) ) { - // removed fix because it causes UDB to become inaccessible for all other slots than those listed - if ( !InItemDescriptionBox( ) ) //&& !(INV_AP_COST && (gTacticalStatus.uiFlags & INCOMBAT) && !(uiHandPos == HANDPOS || uiHandPos == SECONDHANDPOS || uiHandPos == HELMETPOS || uiHandPos == VESTPOS || uiHandPos == LEGPOS)) )//dnl ch66 070913 if INV_AP_COST is active then attach is not allowed if not in one of these slots + if ( !InItemDescriptionBox( ) ) { if ( _KeyDown(SHIFT) && gpItemPointer == NULL && Item[gpSMCurrentMerc->inv[ uiHandPos ].usItem].usItemClass == IC_GUN && (gpSMCurrentMerc->inv[ uiHandPos ])[uiHandPos]->data.gun.ubGunShotsLeft > 0 && !(Item[gpSMCurrentMerc->inv[ uiHandPos ].usItem].singleshotrocketlauncher) && !( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) ) { @@ -7984,4 +7975,3 @@ BOOLEAN HandleKlerykPistolet( SOLDIERTYPE *pSoldier, UINT32 uiHandPos, UINT16 us -