From 7964e90c0afb58c15cdc91fe556790b632ea7ddc Mon Sep 17 00:00:00 2001 From: Flugente Date: Thu, 25 Jul 2013 17:32:15 +0000 Subject: [PATCH] Fix: preplaced items with incompatible attachments causes entire sector inventories to vanish if entering the sector a second time git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6242 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Items.cpp | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 83b992b1..53057fdb 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -5619,25 +5619,36 @@ void RemoveProhibitedAttachments(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, UINT16 if(usInfiniteLoopCount > 10){ //run through the loop 10 times before we drop items. //Anything that's still in our tempAttachList couldn't be attached, and should be dropped. for (attachmentList::iterator iter = tempAttachList.begin(); iter != tempAttachList.end();) { - if (iter->exists()) { - if ( pSoldier && AutoPlaceObject( pSoldier, &(*iter), FALSE ) ) + if (iter->exists()) + { + // Flugente: placing objects at a soldier is only advised if the soldier exists in the first place + if ( pSoldier ) { - iter = tempAttachList.erase(iter); - } else { // put it on the ground - INT8 pathing = (pSoldier?pSoldier->pathing.bLevel:0); - INT32 sGridNo = (pSoldier?pSoldier->sGridNo:0); - AutoPlaceObjectToWorld(pSoldier, &(*iter), TRUE); - iter = tempAttachList.erase(iter); - /*if(guiCurrentItemDescriptionScreen == MAP_SCREEN && fShowMapInventoryPool){ + if ( !AutoPlaceObject( pSoldier, &(*iter), FALSE ) ) + { + AutoPlaceObjectToWorld(pSoldier, &(*iter), TRUE); + } + } + else + { + // put it on the ground + INT32 sGridNo = 1; + + if(guiCurrentItemDescriptionScreen == MAP_SCREEN && fShowMapInventoryPool) + { AutoPlaceObjectInInventoryStash(&(*iter), sGridNo); //AddItemToPool( sGridNo, &(*iter), 1, pathing, WORLD_ITEM_REACHABLE, 0 ); - iter = tempAttachList.erase(iter); - } else { - AddItemToPool( sGridNo, &(*iter), 1, pathing, WORLD_ITEM_REACHABLE, 0 ); - iter = tempAttachList.erase(iter); - }*/ + } + else + { + AddItemToPool( sGridNo, &(*iter), 1, 0, WORLD_ITEM_REACHABLE, 0 ); + } } - } else { + + iter = tempAttachList.erase(iter); + } + else + { ++iter; } }