From 75e797f9ae1ac9170d92c5f89962e1cc5ac761d9 Mon Sep 17 00:00:00 2001 From: ChrisL Date: Thu, 14 Jul 2011 16:46:14 +0000 Subject: [PATCH] BUGFIX 551: Prior fix would allow items to be auto placed into the wrong sector if you had a sector inventory panel already open. The code should now realize that the wrong sector inventory screen is displayed, close that screen, switch to the correct sector, and then open the sector inventory panel before placing the item into sector inventory. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4573 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/mapscreen.cpp | 12 ++++++++++++ Tactical/Items.cpp | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 371b8acad..5714b759c 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -1008,6 +1008,18 @@ void DumpSectorDifficultyInfo( void ); void DumpItemsList( void ); #endif +BOOLEAN IsMercInActiveSector(SOLDIERTYPE * pSoldier) +{ + if(pSoldier->sSectorX != sSelMapX) + return( FALSE ); + if(pSoldier->sSectorY != sSelMapY) + return( FALSE ); + if(pSoldier->bSectorZ != iCurrentMapSectorZ) + return( FALSE ); + + return( TRUE ); +} + void BeginSellAllCallBack( UINT8 bExitValue ) { INT32 iPrice = 0; diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index c5b938b21..ba712431e 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -6283,6 +6283,7 @@ BOOLEAN AutoPlaceObjectAnywhere(SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLE return FALSE; } +extern BOOLEAN IsMercInActiveSector(SOLDIERTYPE * pSoldier); extern void CreateDestroyMapInventoryPoolButtons( BOOLEAN fExitFromMapScreen ); BOOLEAN AutoPlaceObjectToWorld(SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, INT8 bVisible) { @@ -6294,6 +6295,12 @@ BOOLEAN AutoPlaceObjectToWorld(SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, INT8 b if( guiCurrentScreen == MAP_SCREEN ) { + if(fShowMapInventoryPool && !IsMercInActiveSector(pSoldier) ) + { + fShowMapInventoryPool = FALSE; + CreateDestroyMapInventoryPoolButtons(FALSE); + } + ChangeSelectedMapSector(pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ); if(!fShowMapInventoryPool) { fShowMapInventoryPool = TRUE;