From 5035e832618fb02530b9855ab758a82230c9ac6d Mon Sep 17 00:00:00 2001 From: Overhaul Date: Fri, 14 Sep 2007 07:27:14 +0000 Subject: [PATCH] Fixed CTD in editor when changing detailed civ placement from wheelchair to jeep Fixed memory corruption in detailed placement due to old-inventory behavior Added Editor.slf to files JA2/Editor will load from Fixed FindBestPath to not search for a path to NOWHERE git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1362 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Editor/EditorMercs.cpp | 5 ++++- Editor/LoadScreen.cpp | 2 +- Editor/editscreen.cpp | 4 ++++ Standard Gaming Platform/Ja2 Libs.cpp | 1 + Standard Gaming Platform/Ja2 Libs.h | 1 + Tactical/PATHAI.cpp | 4 ++++ Tactical/Soldier Init List.cpp | 2 +- 7 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Editor/EditorMercs.cpp b/Editor/EditorMercs.cpp index 27dc5f42..a7f8fb65 100644 --- a/Editor/EditorMercs.cpp +++ b/Editor/EditorMercs.cpp @@ -2075,6 +2075,7 @@ void ChangeBodyType( INT8 bOffset ) //+1 or -1 only break; } SetSoldierAnimationSurface( gpSelected->pSoldier, gpSelected->pSoldier->usAnimState ); + ConvertAniCodeToAniFrame( gpSelected->pSoldier, 0 ); } //Update the placement's info as well. gpSelected->pBasicPlacement->bBodyType = (INT8)iIndex; @@ -2973,7 +2974,9 @@ void UpdateMercItemSlots() { if( gpSelected->pDetailedPlacement->ubProfile != NO_PROFILE ) { - memcpy( &gpSelected->pDetailedPlacement->Inv, &gpSelected->pSoldier->inv, sizeof( OBJECTTYPE ) * NUM_INV_SLOTS ); + // 0verhaul: Inventory is now a C++ class. Bad memcpy! No biscuit! + //memcpy( &gpSelected->pDetailedPlacement->Inv, &gpSelected->pSoldier->inv, sizeof( OBJECTTYPE ) * NUM_INV_SLOTS ); + gpSelected->pDetailedPlacement->Inv = gpSelected->pSoldier->inv; } for( x = 0; x < 9; x++ ) { diff --git a/Editor/LoadScreen.cpp b/Editor/LoadScreen.cpp index ff0f274d..9c143810 100644 --- a/Editor/LoadScreen.cpp +++ b/Editor/LoadScreen.cpp @@ -281,7 +281,7 @@ UINT32 ProcessLoadSaveScreenMessageBoxResult() RemoveFileDialog(); return EDIT_SCREEN ; } - Assert( 0 ); +// Assert( 0 ); return LOADSAVE_SCREEN; } diff --git a/Editor/editscreen.cpp b/Editor/editscreen.cpp index 00b6a79c..61298070 100644 --- a/Editor/editscreen.cpp +++ b/Editor/editscreen.cpp @@ -262,6 +262,10 @@ UINT32 EditScreenShutdown(void) GameShutdownEditorMercsInfo(); RemoveAllFromUndoList(); KillClipboard(); + if( gfWorldLoaded ) + { + KillItemPoolList(); + } return TRUE; } diff --git a/Standard Gaming Platform/Ja2 Libs.cpp b/Standard Gaming Platform/Ja2 Libs.cpp index fa93b852..aac50154 100644 --- a/Standard Gaming Platform/Ja2 Libs.cpp +++ b/Standard Gaming Platform/Ja2 Libs.cpp @@ -4,6 +4,7 @@ LibraryInitHeader gGameLibaries[ ] = //Library Name Can be Init at start // on cd { "Data.slf", FALSE, TRUE }, + { "Editor.slf", FALSE, FALSE }, { "Ambient.slf", FALSE, TRUE }, { "Anims.slf", FALSE, TRUE }, { "BattleSnds.slf", FALSE, TRUE }, diff --git a/Standard Gaming Platform/Ja2 Libs.h b/Standard Gaming Platform/Ja2 Libs.h index b9c2afaa..ea36ff17 100644 --- a/Standard Gaming Platform/Ja2 Libs.h +++ b/Standard Gaming Platform/Ja2 Libs.h @@ -6,6 +6,7 @@ enum { LIBRARY_DATA, + LIBRARY_EDITOR, LIBRARY_AMBIENT, LIBRARY_ANIMS, LIBRARY_BATTLESNDS, diff --git a/Tactical/PATHAI.cpp b/Tactical/PATHAI.cpp index e52a8181..f8721fe6 100644 --- a/Tactical/PATHAI.cpp +++ b/Tactical/PATHAI.cpp @@ -2082,6 +2082,10 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo iOriginationX = iOriginationY = 0; iOrigination = (INT32) s->sGridNo; + if (sDestination == NOWHERE) + { + return 0; // There is no path to nowhere, because everywhere you can go is somewhere! + } if (iOrigination < 0 || iOrigination > WORLD_MAX) { #ifdef JA2BETAVERSION diff --git a/Tactical/Soldier Init List.cpp b/Tactical/Soldier Init List.cpp index 6a8645e2..4ee1ef67 100644 --- a/Tactical/Soldier Init List.cpp +++ b/Tactical/Soldier Init List.cpp @@ -301,7 +301,7 @@ BOOLEAN LoadSoldiersFromMap( INT8 **hBuffer ) LOADDATA( &tempDetailedPlacement, *hBuffer, SIZEOF_SOLDIERCREATE_STRUCT_POD ); tempDetailedPlacement.CopyOldInventoryToNew(); //allocate memory for new static detailed placement - pNode->pDetailedPlacement = new (MemAlloc( SIZEOF_SOLDIERCREATE_STRUCT )) SOLDIERCREATE_STRUCT;//(SOLDIERCREATE_STRUCT*)MemAlloc( SIZEOF_SOLDIERCREATE_STRUCT ); + pNode->pDetailedPlacement = new SOLDIERCREATE_STRUCT;//(SOLDIERCREATE_STRUCT*)MemAlloc( SIZEOF_SOLDIERCREATE_STRUCT ); if( !pNode->pDetailedPlacement ) { AssertMsg( 0, "Failed to allocate memory for new detailed placement in LoadSoldiersFromMap." );