From da2e6f10c1f659c467762a49e03f203dda4b9ebc Mon Sep 17 00:00:00 2001 From: MaddMugsy Date: Tue, 22 May 2012 03:43:16 +0000 Subject: [PATCH] 1. Bugfix - one more pSoldier->bScopeMode != NULL check added 2. Bugfix - removing attachments which created new slots and had attachments in those slots which were also able to go into existing slots in the base item was resulting in duplication of the base attachment and loss of the attached attachment. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5295 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Items.cpp | 14 +++----------- Tactical/Weapons.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 4340ec08a..eb2d222ae 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -7693,7 +7693,6 @@ BOOLEAN OBJECTTYPE::RemoveAttachment( OBJECTTYPE* pAttachment, OBJECTTYPE * pNew //CHRISL: We need to know if the removed attachment could have altered the base items potential attachments BOOLEAN removeAttachments = TRUE, cleanAttachments = FALSE; INT8 loopCount = 0; - removedAttachment[0]->attachments.clear(); while(removeAttachments){ usRemAttachmentSlotIndexVector = GetItemSlots(&removedAttachment); @@ -7705,7 +7704,8 @@ BOOLEAN OBJECTTYPE::RemoveAttachment( OBJECTTYPE* pAttachment, OBJECTTYPE * pNew for(attachmentList::iterator iter = (*this)[subObject]->attachments.begin(); iter != (*this)[subObject]->attachments.end(); ++iter){ removeAttachments = FALSE; if(iter->exists()){ - if(!ValidItemAttachment(this, iter->usItem, FALSE, FALSE, subObject, usAttachmentSlotIndexVector)){ //attachment is no longer valid + if(!ValidItemAttachment(this, iter->usItem, FALSE, FALSE, subObject, usAttachmentSlotIndexVector)) + { //attachment is no longer valid removeAttachments = TRUE; OBJECTTYPE remObj; remObj = *iter; @@ -7723,14 +7723,6 @@ BOOLEAN OBJECTTYPE::RemoveAttachment( OBJECTTYPE* pAttachment, OBJECTTYPE * pNew INT32 sGridNo = (pSoldier?pSoldier->sGridNo:0); if( AutoPlaceObjectToWorld(pSoldier, &remObj) ) iter = (*this)[subObject]->RemoveAttachmentAtIter(iter); - /*if(guiCurrentItemDescriptionScreen == MAP_SCREEN && fShowMapInventoryPool){ - if(AutoPlaceObjectInInventoryStash(&remObj, sGridNo)){ - iter = (*this)[subObject]->RemoveAttachmentAtIter(iter); - } - } else { - AddItemToPool( sGridNo, &remObj, 1, pathing, WORLD_ITEM_REACHABLE, 0 ); - iter = (*this)[subObject]->RemoveAttachmentAtIter(iter); - }*/ } } } @@ -7746,7 +7738,7 @@ BOOLEAN OBJECTTYPE::RemoveAttachment( OBJECTTYPE* pAttachment, OBJECTTYPE * pNew if(pNewObj != NULL) *pNewObj = removedAttachment; - if(pAttachment->exists() ) + if(pAttachment->exists() && pAttachment->usItem == 0) *pAttachment = removedAttachment; if (pNewObj->exists() && Item[pNewObj->usItem].grenadelauncher )//UNDER_GLAUNCHER) diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index c7d54775a..40e2173ab 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -6364,9 +6364,12 @@ UINT32 CalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTime, std::map ObjList; GetScopeLists((&(pSoldier->inv[pSoldier->ubAttackingHand])), ObjList); - iPenalty = (Item[ObjList[pSoldier->bScopeMode]->usItem].aimbonus * (iRange - Item[ObjList[pSoldier->bScopeMode]->usItem].minrangeforaimbonus)) / 1000; - iPenalty = min(AIM_BONUS_PRONE, iPenalty); - iChance -= iPenalty; + if ( ObjList[pSoldier->bScopeMode] != NULL ) + { + iPenalty = (Item[ObjList[pSoldier->bScopeMode]->usItem].aimbonus * (iRange - Item[ObjList[pSoldier->bScopeMode]->usItem].minrangeforaimbonus)) / 1000; + iPenalty = min(AIM_BONUS_PRONE, iPenalty); + iChance -= iPenalty; + } } /////////////////////////////////////////////////////////////////////////////////////