From 6de9e9a433b53f70c4d806e2da404d0e383ce71a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 May 2006 15:51:17 +0000 Subject: [PATCH] - Changed FDoorAnimation deletion so that the array takes care of it. The original destructor approach would have necessitated a lot more supporting code to work as intended. SVN r91 (trunk) --- docs/rh-log.txt | 2 ++ src/p_doors.cpp | 44 ++++++++++++++++++++++++++------------------ src/p_spec.h | 4 ---- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index e8ea5c770..f76039730 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ May 9, 2006 (Changes by Graf Zahl) +- Changed FDoorAnimation deletion so that the array takes care of it. This + eliminates some complications with the requirements a destructor has. - Fixed: Skin definitions were never freed. - Fixed: Names in terrain definitions were never freed. Replacing them with FNames would have been a good idea anyway. diff --git a/src/p_doors.cpp b/src/p_doors.cpp index 4dcab349a..c995497f0 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -478,33 +478,41 @@ void P_SpawnDoorRaiseIn5Mins (sector_t *sec) // Strife's animated doors. Based on Doom's unused sliding doors, but slightly different. -TArray DoorAnimations; - -FDoorAnimation::~FDoorAnimation() +class DeletingDoorArray : public TArray { - if (TextureFrames != NULL) +public: + ~DeletingDoorArray() { - delete [] TextureFrames; - TextureFrames = NULL; + for(unsigned i=0;iTextureFrames != NULL) + { + delete [] ani->TextureFrames; + ani->TextureFrames = NULL; + } + if (ani->OpenSound != NULL) + { + delete [] ani->OpenSound; + ani->OpenSound = NULL; + } + if (ani->CloseSound != NULL) + { + delete [] ani->CloseSound; + ani->CloseSound = NULL; + } + } } - if (OpenSound != NULL) - { - delete [] OpenSound; - OpenSound = NULL; - } - if (CloseSound != NULL) - { - delete [] CloseSound; - CloseSound = NULL; - } -} +}; + +DeletingDoorArray DoorAnimations; // EV_SlidingDoor : slide a door horizontally // (animate midtexture, then set noblocking line) // // -// Return index into "DoorAnimatinos" array for which door type to use +// Return index into "DoorAnimations" array for which door type to use // static int P_FindSlidingDoorType (int picnum) { diff --git a/src/p_spec.h b/src/p_spec.h index 740c26c62..21e927294 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -578,12 +578,8 @@ struct FDoorAnimation int NumTextureFrames; char *OpenSound; char *CloseSound; - - ~FDoorAnimation(); }; -extern TArray DoorAnimations; - void P_ParseAnimatedDoor (); class DAnimatedDoor : public DMovingCeiling