mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
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:
+15
-7
@@ -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++){
|
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.
|
//Only add inseparable default attachments, because they are likely "part" of the gun.
|
||||||
if(Item[Item[pObj->usItem].defaultattachments[cnt]].inseparable == 1){
|
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);
|
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.");
|
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();) {
|
for (attachmentList::iterator iter = tempSlotChangingAttachList.begin(); iter != tempSlotChangingAttachList.end();) {
|
||||||
if( ValidItemAttachmentSlot(pObj, iter->usItem, TRUE, FALSE, ubStatusIndex )){
|
if( ValidItemAttachmentSlot(pObj, iter->usItem, TRUE, FALSE, ubStatusIndex )){
|
||||||
//This seems to be rather valid. Can't be 100% sure though.
|
//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.
|
//Ok now we can be sure, lets remove this object so we don't try to drop it later.
|
||||||
iter = tempSlotChangingAttachList.erase(iter);
|
iter = tempSlotChangingAttachList.erase(iter);
|
||||||
} else {
|
} else {
|
||||||
@@ -5453,7 +5455,9 @@ void ReInitMergedItem(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, UINT16 usOldItem,
|
|||||||
for (attachmentList::iterator iter = tempAttachList.begin(); iter != tempAttachList.end();) {
|
for (attachmentList::iterator iter = tempAttachList.begin(); iter != tempAttachList.end();) {
|
||||||
if( ValidItemAttachmentSlot(pObj, iter->usItem, TRUE, FALSE, ubStatusIndex)){
|
if( ValidItemAttachmentSlot(pObj, iter->usItem, TRUE, FALSE, ubStatusIndex)){
|
||||||
//This seems to be rather valid. Can't be 100% sure though.
|
//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.
|
//Ok now we can be sure, lets remove this object so we don't try to drop it later.
|
||||||
iter = tempAttachList.erase(iter);
|
iter = tempAttachList.erase(iter);
|
||||||
} else {
|
} else {
|
||||||
@@ -5469,10 +5473,12 @@ void ReInitMergedItem(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, UINT16 usOldItem,
|
|||||||
if ( Item[iter->usItem].inseparable != 1)
|
if ( Item[iter->usItem].inseparable != 1)
|
||||||
{//WarmSteel - Couldn't re-attach this item, try to drop it.
|
{//WarmSteel - Couldn't re-attach this item, try to drop it.
|
||||||
if (pSoldier) {
|
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
|
{ // put it on the ground
|
||||||
// HEADROCK HAM 5: A much more suitable function. Works in both tactical and mapscreen!
|
// 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 );
|
//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)
|
if ( Item[iter->usItem].inseparable != 1)
|
||||||
{//WarmSteel - Couldn't re-attach this item, try to drop it.
|
{//WarmSteel - Couldn't re-attach this item, try to drop it.
|
||||||
if (pSoldier) {
|
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
|
{ // put it on the ground
|
||||||
// HEADROCK HAM 5: A much more suitable function. Works in both tactical and mapscreen!
|
// 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 );
|
//AddItemToPool( pSoldier->sGridNo, &(*iter), 1, pSoldier->pathing.bLevel, 0 , -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -682,7 +682,6 @@ void LoadWorldItemsFromMap( INT8 **hBuffer, float dMajorMapVersion, int ubMinorM
|
|||||||
if(Item [ dummyItem.object.usItem ].defaultattachments[cnt] == 0)
|
if(Item [ dummyItem.object.usItem ].defaultattachments[cnt] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//cannot use gTempObject
|
|
||||||
OBJECTTYPE defaultAttachment;
|
OBJECTTYPE defaultAttachment;
|
||||||
CreateItem(Item [ dummyItem.object.usItem ].defaultattachments[cnt],100,&defaultAttachment);
|
CreateItem(Item [ dummyItem.object.usItem ].defaultattachments[cnt],100,&defaultAttachment);
|
||||||
dummyItem.object.AttachObject(NULL,&defaultAttachment, FALSE);
|
dummyItem.object.AttachObject(NULL,&defaultAttachment, FALSE);
|
||||||
|
|||||||
Reference in New Issue
Block a user