Fix - after merging or transforming an item, any attachments on the base item which themselves had default inseparable attachments, would see those attachments lost upon the result of the merge/transformation.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5283 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
MaddMugsy
2012-05-17 17:14:21 +00:00
parent defbf8444f
commit 5930c90585
2 changed files with 15 additions and 8 deletions
+15 -7
View File
@@ -5428,7 +5428,7 @@ void ReInitMergedItem(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, UINT16 usOldItem,
for(UINT16 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS && Item[pObj->usItem].defaultattachments[cnt] != 0; cnt++){
//Only add inseparable default attachments, because they are likely "part" of the gun.
if(Item[Item[pObj->usItem].defaultattachments[cnt]].inseparable == 1){
static OBJECTTYPE defaultAttachment;
OBJECTTYPE defaultAttachment;
CreateItem(Item [ pObj->usItem ].defaultattachments[cnt],(*pObj)[ubStatusIndex]->data.objectStatus,&defaultAttachment);
AssertMsg(pObj->AttachObject(NULL,&defaultAttachment, FALSE, ubStatusIndex, -1, FALSE), "A default attachment could not be attached after merging, this should not be possible.");
}
@@ -5438,7 +5438,9 @@ void ReInitMergedItem(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, UINT16 usOldItem,
for (attachmentList::iterator iter = tempSlotChangingAttachList.begin(); iter != tempSlotChangingAttachList.end();) {
if( ValidItemAttachmentSlot(pObj, iter->usItem, TRUE, FALSE, ubStatusIndex )){
//This seems to be rather valid. Can't be 100% sure though.
if(pObj->AttachObject(NULL, &(*iter), FALSE, ubStatusIndex)){
OBJECTTYPE tempAttachment; // Madd: we must recreate the attachments because they may themselves have default inseparable attachments...
CreateItem(iter->usItem, (*iter)[0]->data.objectStatus, &tempAttachment);
if(pObj->AttachObject(NULL, &tempAttachment, FALSE, ubStatusIndex)){
//Ok now we can be sure, lets remove this object so we don't try to drop it later.
iter = tempSlotChangingAttachList.erase(iter);
} else {
@@ -5453,7 +5455,9 @@ void ReInitMergedItem(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, UINT16 usOldItem,
for (attachmentList::iterator iter = tempAttachList.begin(); iter != tempAttachList.end();) {
if( ValidItemAttachmentSlot(pObj, iter->usItem, TRUE, FALSE, ubStatusIndex)){
//This seems to be rather valid. Can't be 100% sure though.
if(pObj->AttachObject(NULL, &(*iter), FALSE, ubStatusIndex)){
OBJECTTYPE tempAttachment; // Madd: we must recreate the attachments because they may themselves have default inseparable attachments...
CreateItem(iter->usItem, (*iter)[0]->data.objectStatus, &tempAttachment);
if(pObj->AttachObject(NULL, &tempAttachment, FALSE, ubStatusIndex)){
//Ok now we can be sure, lets remove this object so we don't try to drop it later.
iter = tempAttachList.erase(iter);
} else {
@@ -5469,10 +5473,12 @@ void ReInitMergedItem(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, UINT16 usOldItem,
if ( Item[iter->usItem].inseparable != 1)
{//WarmSteel - Couldn't re-attach this item, try to drop it.
if (pSoldier) {
if ( !AutoPlaceObject( pSoldier, &(*iter), FALSE ) )
OBJECTTYPE tempAttachment; // Madd: we must recreate the attachments because they may themselves have default inseparable attachments...
CreateItem(iter->usItem, (*iter)[0]->data.objectStatus, &tempAttachment);
if ( !AutoPlaceObject( pSoldier, &tempAttachment, FALSE ) )
{ // put it on the ground
// HEADROCK HAM 5: A much more suitable function. Works in both tactical and mapscreen!
AutoPlaceObjectToWorld( pSoldier, &(*iter), true );
AutoPlaceObjectToWorld( pSoldier, &tempAttachment, true );
//AddItemToPool( pSoldier->sGridNo, &(*iter), 1, pSoldier->pathing.bLevel, 0 , -1 );
}
}
@@ -5483,10 +5489,12 @@ void ReInitMergedItem(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, UINT16 usOldItem,
if ( Item[iter->usItem].inseparable != 1)
{//WarmSteel - Couldn't re-attach this item, try to drop it.
if (pSoldier) {
if ( !AutoPlaceObject( pSoldier, &(*iter), FALSE ) )
OBJECTTYPE tempAttachment; // Madd: we must recreate the attachments because they may themselves have default inseparable attachments...
CreateItem(iter->usItem, (*iter)[0]->data.objectStatus, &tempAttachment);
if ( !AutoPlaceObject( pSoldier, &tempAttachment, FALSE ) )
{ // put it on the ground
// HEADROCK HAM 5: A much more suitable function. Works in both tactical and mapscreen!
AutoPlaceObjectToWorld( pSoldier, &(*iter), true );
AutoPlaceObjectToWorld( pSoldier, &tempAttachment, true );
//AddItemToPool( pSoldier->sGridNo, &(*iter), 1, pSoldier->pathing.bLevel, 0 , -1 );
}
}
-1
View File
@@ -682,7 +682,6 @@ void LoadWorldItemsFromMap( INT8 **hBuffer, float dMajorMapVersion, int ubMinorM
if(Item [ dummyItem.object.usItem ].defaultattachments[cnt] == 0)
break;
//cannot use gTempObject
OBJECTTYPE defaultAttachment;
CreateItem(Item [ dummyItem.object.usItem ].defaultattachments[cnt],100,&defaultAttachment);
dummyItem.object.AttachObject(NULL,&defaultAttachment, FALSE);