From c6525a227177f877619bb02da9d2b8e3f6e51699 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 13 Dec 2010 10:02:45 +0000 Subject: [PATCH] - changed some data init code to delete the data it wants to initialize first. - The 'savebuffer' variable still existed? - Changed AInventory::Destroy to NULL SendItemUse and SendItemDrop if they point to the destroyed object. Although unlikely it can't be ruled out completely that this can happen with delayed CCMDs. - fixed: Starting a new game did not clear the hub statistics array. SVN r3034 (trunk) --- src/d_iwad.cpp | 1 + src/decallib.cpp | 9 +++++++++ src/g_game.cpp | 2 -- src/g_game.h | 2 ++ src/g_hub.cpp | 7 ++++++- src/g_level.cpp | 2 +- src/g_level.h | 1 + src/g_mapinfo.cpp | 5 +++++ src/g_shared/a_pickups.cpp | 5 +++++ src/info.cpp | 1 + 10 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index b02407b15..0c7cc3bf2 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -549,6 +549,7 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, exit (0); // zdoom.pk3 must always be the first file loaded and the IWAD second. + wadfiles.Clear(); D_AddFile (wadfiles, zdoom_wad); if (mIWads[wads[pickwad].Type].preload >= 0) diff --git a/src/decallib.cpp b/src/decallib.cpp index bfcc1ac14..072262da9 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -347,6 +347,15 @@ void FDecalLib::ReadAllDecals () int lump, lastlump = 0; unsigned int i; + for(unsigned i=0;i hubdata; +static TArray hubdata; void G_LeavingHub(int mode, cluster_info_t * cluster, wbstartstruct_t * wbs) { @@ -182,3 +182,8 @@ void G_ReadHubInfo (PNGHandle *png) G_SerializeHub(arc); } } + +void G_ClearHubInfo() +{ + hubdata.Clear(); +} \ No newline at end of file diff --git a/src/g_level.cpp b/src/g_level.cpp index e3321f884..a962d5196 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -119,7 +119,6 @@ bool savegamerestore; extern int mousex, mousey; extern bool sendpause, sendsave, sendturn180, SendLand; -extern const AInventory *SendItemUse, *SendItemDrop; void *statcopy; // for statistics driver @@ -309,6 +308,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel) bool wantFast; int i; + G_ClearHubInfo(); if (!savegamerestore) { G_ClearSnapshots (); diff --git a/src/g_level.h b/src/g_level.h index d7add35b5..6cb9d8441 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -514,6 +514,7 @@ void G_UnSnapshotLevel (bool keepPlayers); struct PNGHandle; void G_ReadSnapshots (PNGHandle *png); void G_WriteSnapshots (FILE *file); +void G_ClearHubInfo(); enum ESkillProperty { diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index adf0b2cd0..bc1a19d48 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -1803,7 +1803,11 @@ void DeinitIntermissions(); static void ClearMapinfo() { + wadclusterinfos.Clear(); + wadlevelinfos.Clear(); ClearEpisodes(); + AllSkills.Clear(); + DefaultSkill = -1; DeinitIntermissions(); } @@ -1820,6 +1824,7 @@ void G_ParseMapInfo (const char *basemapinfo) int lump, lastlump = 0; level_info_t gamedefaults; + ClearMapinfo(); atterm(ClearMapinfo); // Parse the default MAPINFO for the current game. This lump *MUST* come from zdoom.pk3. diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 524daee77..f059d8d3a 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -16,6 +16,7 @@ #include "a_specialspot.h" #include "thingdef/thingdef.h" #include "g_level.h" +#include "g_game.h" #include "doomstat.h" static FRandom pr_restore ("RestorePos"); @@ -1033,6 +1034,10 @@ void AInventory::Destroy () } Inventory = NULL; Super::Destroy (); + + // Although contrived it can theoretically happen that these variables still got a pointer to this item + if (SendItemUse == this) SendItemUse = NULL; + if (SendItemDrop == this) SendItemDrop = NULL; } //=========================================================================== diff --git a/src/info.cpp b/src/info.cpp index 988c175df..f345a6e7f 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -101,6 +101,7 @@ int GetSpriteIndex(const char * spritename) void FActorInfo::StaticInit () { + sprites.Clear(); if (sprites.Size() == 0) { spritedef_t temp;