From d3d47da188400f81763014c022ad344fd4c26575 Mon Sep 17 00:00:00 2001 From: Wanne Date: Sun, 25 Nov 2012 21:47:42 +0000 Subject: [PATCH] - Fixed previous attachment fix (by Realist) o If you removed grenade launcher incl. grenade from attachments, a "ghost" items slot was crated o If this fix causes any weird behaviors with attachments, it can be reverted... git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5699 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Items.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index e5d71588..44c25b99 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -8110,10 +8110,14 @@ BOOLEAN OBJECTTYPE::RemoveAttachment( OBJECTTYPE* pAttachment, OBJECTTYPE * pNew OBJECTTYPE* pGrenade = FindAttachmentByClass( this, IC_GRENADE ); if (pGrenade->exists()) { - pNewObj->AttachObject(NULL, pGrenade, FALSE, 0, -1, 0); //ADB ubWeight has been removed, see comments in OBJECTTYPE //pNewObj->ubWeight = CalculateObjectWeight( pNewObj ); - this->RemoveAttachment(pGrenade, NULL, 0, NULL, 1, 0); + + // we might have to do it in this order, because if we attach first, + // the object is pretty much gone and RemoveAttachment won't work (returns right away) + OBJECTTYPE tmp; + this->RemoveAttachment(pGrenade, &tmp, 0, NULL, 1, 0); + pNewObj->AttachObject(NULL, &tmp, FALSE, 0, -1, 0); } } //Removing an attachment can alter slots, check them.