From 4f0ee82ccb9b31bef6e62dff127617a97c21c4c3 Mon Sep 17 00:00:00 2001 From: Wanne Date: Wed, 25 Jun 2014 17:53:15 +0000 Subject: [PATCH] Merged from revision: 7290 - Fixed inaccessible or lost items for moving items from mercs to sector inventory when a different tactical map is loaded (by Buggler & anv) - Revert fix on queen reinforcement pool being replenished on depletion when playing with limited enemy troops setting (by Buggler) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7291 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- .../Map Screen Interface Map Inventory.cpp | 25 ++++++++++++++++--- Strategic/Strategic AI.cpp | 3 +-- Tactical/Items.cpp | 20 +++++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index 4a1e689c2..c88b381e3 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -1592,11 +1592,30 @@ void MapInvenPoolSlots(MOUSE_REGION * pRegion, INT32 iReason ) // HEADROCK HAM 5: A LOT of functions rely on these flags being set. So set them!! pInventoryPoolList[(iCurrentInventoryPoolPage*MAP_INVENTORY_POOL_SLOT_COUNT)+iCounter].bVisible = TRUE; pInventoryPoolList[(iCurrentInventoryPoolPage*MAP_INVENTORY_POOL_SLOT_COUNT)+iCounter].fExists = TRUE; - if(gGameExternalOptions.fEnableInventoryPoolQ)//dnl ch51 091009 + + /*if(gGameExternalOptions.fEnableInventoryPoolQ)//dnl ch51 091009 { if(!GridNoOnVisibleWorldTile(sObjectSourceGridNo)) sObjectSourceGridNo = gMapInformation.sCenterGridNo; - } + }*/ + + // set a grid no for item from mercs with invalid grid no in sector inventory, e.g. merc arriving in sector with a different tactical map loaded + if(!GridNoOnVisibleWorldTile(sObjectSourceGridNo)) + { + // use the grid no of the first visible, reachable item + for(UINT32 i = 0; i < pInventoryPoolList.size(); i++ ) + { + if( pInventoryPoolList[i].bVisible == 1 && pInventoryPoolList[i].fExists == TRUE && pInventoryPoolList[i].usFlags & WORLD_ITEM_REACHABLE ) + { + sObjectSourceGridNo = pInventoryPoolList[i].sGridNo; + break; + } + + // empty sector to use the center grid no of the loaded tactical sector, hope that it's accessible + if(!GridNoOnVisibleWorldTile(sObjectSourceGridNo)) + sObjectSourceGridNo = gMapInformation.sCenterGridNo; + } + } //CHRISL: Make sure we put the item at the same level as the merc if(gpItemPointerSoldier->exists() == true) @@ -2492,7 +2511,7 @@ BOOLEAN AutoPlaceObjectInInventoryStash( OBJECTTYPE *pItemPtr, INT32 sGridNo ) if(sGridNo != 0) { pInventoryPoolList[cnt].sGridNo = sGridNo; - pInventoryPoolList[cnt].usFlags = 512; + pInventoryPoolList[cnt].usFlags |= WORLD_ITEM_REACHABLE; pInventoryPoolList[cnt].bVisible = 1; pInventoryPoolList[cnt].fExists = TRUE; } diff --git a/Strategic/Strategic AI.cpp b/Strategic/Strategic AI.cpp index 8dd262876..cb42ebe03 100644 --- a/Strategic/Strategic AI.cpp +++ b/Strategic/Strategic AI.cpp @@ -3313,7 +3313,6 @@ void EvaluateQueenSituation() break; } - /* // Buggler: Unlimited troops setting will have a constant pool value, limited troops setting should not be able to recruit new troops if( !giReinforcementPool ) { //Queen has run out of reinforcements. Simulate recruiting and training new troops uiOffset *= 10; @@ -3321,7 +3320,7 @@ void EvaluateQueenSituation() giReinforcementPool += ( gGameExternalOptions.guiBaseQueenPoolIncrement * gGameOptions.ubDifficultyLevel ) * ( 100 + CurrentPlayerProgressPercentage() ) / 100 ; AddStrategicEvent( EVENT_EVALUATE_QUEEN_SITUATION, GetWorldTotalMin() + uiOffset, 0 ); return; - }*/ + } //Re-post the event AddStrategicEvent( EVENT_EVALUATE_QUEEN_SITUATION, GetWorldTotalMin() + uiOffset, 0 ); diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 9b0386da8..b7b65508b 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -59,6 +59,7 @@ #include "Sys Globals.h"//dnl ch74 201013 #include "CampaignStats.h" // added by Flugente #include "DisplayCover.h" // added by Flugente + #include "Map Information.h" #endif #ifdef JA2UB @@ -6919,6 +6920,25 @@ BOOLEAN AutoPlaceObjectToWorld(SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, INT8 b fShowMapInventoryPool = TRUE; CreateDestroyMapInventoryPoolButtons(FALSE); } + + // set a grid no for item from mercs with invalid grid no in sector inventory, e.g. merc arriving in sector with a different tactical map loaded + if(!GridNoOnVisibleWorldTile(sGridNo)) + { + // use the grid no of the first visible, reachable item + for(UINT32 i = 0; i < pInventoryPoolList.size(); i++ ) + { + if( pInventoryPoolList[i].bVisible == 1 && pInventoryPoolList[i].fExists == TRUE && pInventoryPoolList[i].usFlags & WORLD_ITEM_REACHABLE ) + { + sGridNo = pInventoryPoolList[i].sGridNo; + break; + } + } + + // empty sector to use the center grid no of the loaded tactical sector, hope that it's accessible + if(!GridNoOnVisibleWorldTile(sGridNo)) + sGridNo = gMapInformation.sCenterGridNo; + } + fMapPanelDirty = TRUE; return( AutoPlaceObjectInInventoryStash(pObj, sGridNo) ); }