From a39f5bb8f7b9bc01c1d08250061e0a594d4085b0 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 18 May 2006 04:25:26 +0000 Subject: [PATCH] - Fixed: M_NotifyNewSave() needlessly created a copy of the filename. - Fixed: Any touching_sectorlists for actors unlinked in G_StartTravel() were lost forever. - Fixed: DLightningThinker::Serialize() did not delete the old LightningLightLevels array when loading from an archive. - Fixed: Although I moved the correct polyobject freeing code into P_FreeLevelData(), I left the old wrong code there too, which just deleted the array without deleting anything hanging off of it. SVN r127 (trunk) --- docs/rh-log.txt | 8 ++++++++ src/g_level.cpp | 4 +++- src/g_level.h | 2 +- src/g_shared/a_lightning.cpp | 4 ++++ src/m_menu.cpp | 2 +- src/p_local.h | 1 + src/p_map.cpp | 17 +++++++++++++++++ src/p_mobj.cpp | 24 ++++++++++-------------- src/p_setup.cpp | 7 +------ 9 files changed, 46 insertions(+), 23 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 4d8732c49..529bac529 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,12 @@ May 17, 2006 +- Fixed: M_NotifyNewSave() needlessly created a copy of the filename. +- Fixed: Any touching_sectorlists for actors unlinked in G_StartTravel() were + lost forever. +- Fixed: DLightningThinker::Serialize() did not delete the old + LightningLightLevels array when loading from an archive. +- Fixed: Although I moved the correct polyobject freeing code into + P_FreeLevelData(), I left the old wrong code there too, which just deleted + the array without deleting anything hanging off of it. - Texture animation improvements: * Animations are now millisecond-accurate, so delays in ANIMDEFS can have fractional parts. diff --git a/src/g_level.cpp b/src/g_level.cpp index 3182e0f11..4d87f3495 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -121,7 +121,7 @@ TAutoGrowArray ACS_GlobalArrays[NUM_GLOBALVARS]; extern bool netdemo; extern FString BackupSaveName; -BOOL savegamerestore; +bool savegamerestore; extern int mousex, mousey; extern bool sendpause, sendsave, sendturn180, SendLand; @@ -1949,6 +1949,7 @@ void G_StartTravel () if (players[i].health > 0) { pawn->UnlinkFromWorld (); + P_DelSector_List (); pawn->RemoveFromHash (); pawn->ChangeStatNum (STAT_TRAVELLING); @@ -1956,6 +1957,7 @@ void G_StartTravel () { inv->ChangeStatNum (STAT_TRAVELLING); inv->UnlinkFromWorld (); + P_DelSector_List (); } } } diff --git a/src/g_level.h b/src/g_level.h index 26bf5db7a..ad4b0bf2c 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -282,7 +282,7 @@ extern SDWORD ACS_GlobalVars[NUM_GLOBALVARS]; extern TAutoGrowArray ACS_WorldArrays[NUM_WORLDVARS]; extern TAutoGrowArray ACS_GlobalArrays[NUM_GLOBALVARS]; -extern BOOL savegamerestore; +extern bool savegamerestore; // mapname will be changed if it is a valid warptrans bool CheckWarpTransMap (char mapname[9], bool substitute); diff --git a/src/g_shared/a_lightning.cpp b/src/g_shared/a_lightning.cpp index e97244e2d..501429e81 100644 --- a/src/g_shared/a_lightning.cpp +++ b/src/g_shared/a_lightning.cpp @@ -41,6 +41,10 @@ void DLightningThinker::Serialize (FArchive &arc) if (arc.IsLoading ()) { + if (LightningLightLevels != NULL) + { + delete[] LightningLightLevels; + } LightningLightLevels = new BYTE[numsectors + (numsectors+7)/8]; } lights = LightningLightLevels; diff --git a/src/m_menu.cpp b/src/m_menu.cpp index 7c3a8000d..9bef2392a 100644 --- a/src/m_menu.cpp +++ b/src/m_menu.cpp @@ -827,7 +827,7 @@ void M_NotifyNewSave (const char *file, const char *title, bool okForQuicksave) { node = new FSaveGameNode; strcpy (node->Title, title); - node->Filename = copystring (file); + node->Filename = file; node->bOldVersion = false; node->bMissingWads = false; M_InsertSaveNode (node); diff --git a/src/p_local.h b/src/p_local.h index 9857c8b5e..e032af45e 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -316,6 +316,7 @@ extern sector_t *CameraSector; // [RH] Means of death void P_RadiusAttack (AActor *spot, AActor *source, int damage, int distance, int damageType, bool hurtSelf, bool thrustless=false); +void P_DelSector_List(); void P_DelSeclist(msecnode_t *); // phares 3/16/98 void P_CreateSecNodeList(AActor*,fixed_t,fixed_t); // phares 3/14/98 int P_GetMoveFactor(const AActor *mo, int *frictionp); // phares 3/6/98 diff --git a/src/p_map.cpp b/src/p_map.cpp index 7cdc4aa30..dded60a33 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4387,6 +4387,23 @@ msecnode_t *P_DelSecnode (msecnode_t *node) return NULL; } // phares 3/13/98 +//============================================================================= +// +// P_DelSector_List +// +// Deletes the sector_list and NULLs it. +// +//============================================================================= + +void P_DelSector_List () +{ + if (sector_list != NULL) + { + P_DelSeclist (sector_list); + sector_list = NULL; + } +} + //============================================================================= // // P_DelSeclist diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 1de4a2ae8..e74c9d236 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -808,15 +808,15 @@ AInventory *AActor::GiveInventoryType (const PClass *type) bool AActor::GiveAmmo (const PClass *type, int amount) { - AInventory *item = static_cast(Spawn (type, 0, 0, 0)); - item->Amount = amount; - item->flags |= MF_DROPPED; - if (!item->TryPickup (this)) - { - item->Destroy (); - return false; - } - return true; + AInventory *item = static_cast(Spawn (type, 0, 0, 0)); + item->Amount = amount; + item->flags |= MF_DROPPED; + if (!item->TryPickup (this)) + { + item->Destroy (); + return false; + } + return true; } //============================================================================ @@ -3223,11 +3223,7 @@ void AActor::Destroy () flags |= MF_NOSECTOR|MF_NOBLOCKMAP; // Delete all nodes on the current sector_list phares 3/16/98 - if (sector_list) - { - P_DelSeclist (sector_list); - sector_list = NULL; - } + P_DelSector_List(); // stop any playing sound S_RelinkSound (this, NULL); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index a71b13b1c..118dece77 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -2926,12 +2926,6 @@ void P_FreeLevelData () delete[] PolyBlockMap; PolyBlockMap = NULL; } - po_NumPolyobjs = 0; - if (polyobjs != NULL) - { - delete[] polyobjs; - polyobjs = NULL; - } if (rejectmatrix != NULL) { delete[] rejectmatrix; @@ -2972,6 +2966,7 @@ void P_FreeLevelData () delete[] polyobjs; polyobjs = NULL; } + po_NumPolyobjs = 0; if (zones != NULL) { delete[] zones;