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