diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 4d46b60906..e8ea5c7708 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,12 @@ May 9, 2006 (Changes by Graf Zahl) +- 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. +- Fixed: The lock definitions were never freed. +- Fixed: FDoorAnimation was missing a destructor. +- Fixed: animation and switch definitions were never freed. +- Replaced all other places where FindType was used with FNames with + IFindType. - Fixed: If you want to use a name as the missile parameter for the basic attack functions the type search in DoAttack must be case insensitive. - Fixed: APowerup::DoEffect must do more thorough checks before resetting diff --git a/src/d_main.cpp b/src/d_main.cpp index b9ae76e8b8..70f2732436 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2011,6 +2011,7 @@ void D_DoomMain (void) Wads.InitMultipleFiles (&wadfiles); + // [RH] Initialize localizable strings. GStrings.LoadStrings (false); @@ -2080,6 +2081,7 @@ void D_DoomMain (void) FActorInfo::StaticSetActorNums (); + // [RH] User-configurable startup strings. Because BOOM does. static const char *startupString[5] = { "STARTUP1", "STARTUP2", "STARTUP3", "STARTUP4", "STARTUP5" diff --git a/src/g_shared/a_keys.cpp b/src/g_shared/a_keys.cpp index 754c3e614e..fd7e17d6f4 100644 --- a/src/g_shared/a_keys.cpp +++ b/src/g_shared/a_keys.cpp @@ -85,6 +85,15 @@ static bool keysdone=false; // have the locks been initialized? static int currentnumber; // number to be assigned to next key static bool ignorekey; // set to true when the current lock is not being used +static void ClearLocks(); + +static struct LockDeleter +{ + ~LockDeleter() + { + ClearLocks(); + } +} DeleteTheLocks; static const char * keywords_lock[]={ "ANY", diff --git a/src/p_doors.cpp b/src/p_doors.cpp index ee811143ae..4dcab349a4 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -480,6 +480,25 @@ void P_SpawnDoorRaiseIn5Mins (sector_t *sec) TArray DoorAnimations; +FDoorAnimation::~FDoorAnimation() +{ + if (TextureFrames != NULL) + { + delete [] TextureFrames; + TextureFrames = NULL; + } + if (OpenSound != NULL) + { + delete [] OpenSound; + OpenSound = NULL; + } + if (CloseSound != NULL) + { + delete [] CloseSound; + CloseSound = NULL; + } +} + // EV_SlidingDoor : slide a door horizontally // (animate midtexture, then set noblocking line) // diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 1ca5d3694a..4fe8cfb24f 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -142,7 +142,19 @@ struct FAnimDef }; }; -TArray Anims; +class DeletingAnimArray : public TArray +{ +public: + ~DeletingAnimArray() + { + for(unsigned i=0;i DoorAnimations; diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 65175d3f49..b83d9cdc6b 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -114,7 +114,19 @@ static WORD AddSwitchDef (FSwitchDef *def); // CHANGE THE TEXTURE OF A WALL SWITCH TO ITS OPPOSITE // -static TArray SwitchList; +class DeletingSwitchArray : public TArray +{ +public: + ~DeletingSwitchArray() + { + for(unsigned i=0;iTerrainTypes; TArray Splashes; TArray Terrains; @@ -268,8 +268,8 @@ void P_InitTerrainTypes () int size; size = (TexMan.NumTextures()+1)*sizeof(byte); - TerrainTypes = (byte *)M_Malloc (size); - memset (TerrainTypes, 0, size); + TerrainTypes.Resize(size); + memset (&TerrainTypes[0], 0, size); MakeDefaultTerrain (); @@ -295,7 +295,7 @@ static void MakeDefaultTerrain () FTerrainDef def; memset (&def, 0, sizeof(def)); - def.Name = copystring ("Solid"); + def.Name = "Solid"; def.Splash = -1; Terrains.Push (def); } @@ -399,13 +399,15 @@ void ParseSplash () int splashnum; FSplashDef *splashdef; bool isnew = false; + FName name; SC_MustGetString (); - splashnum = (int)FindSplash (sc_String); + name = sc_String; + splashnum = (int)FindSplash (name); if (splashnum < 0) { FSplashDef def; - def.Name = copystring (sc_String); + def.Name = name; splashnum = (int)Splashes.Push (def); isnew = true; } @@ -446,16 +448,17 @@ void ParseSplash () void ParseTerrain () { int terrainnum; - const char *name; + FName name; SC_MustGetString (); - terrainnum = (int)FindTerrain (sc_String); + name = sc_String; + terrainnum = (int)FindTerrain (name); if (terrainnum < 0) { FTerrainDef def; memset (&def, 0, sizeof(def)); def.Splash = -1; - def.Name = copystring (sc_String); + def.Name = name; terrainnum = (int)Terrains.Push (def); } @@ -549,7 +552,7 @@ static void ParseFriction (int keyword, void *fields) //========================================================================== static void GenericParse (FGenericParse *parser, const char **keywords, - void *fields, const char *type, const char *name) + void *fields, const char *type, FName name) { bool notdone = true; int keyword; @@ -578,7 +581,7 @@ static void GenericParse (FGenericParse *parser, const char **keywords, if (val == 0) { Printf ("Unknown sound %s in %s %s\n", - sc_String, type, name); + sc_String, type, name.GetChars()); } break; @@ -599,13 +602,13 @@ static void GenericParse (FGenericParse *parser, const char **keywords, if (!info->IsDescendantOf (RUNTIME_CLASS(AActor))) { Printf ("%s is not an Actor (in %s %s)\n", - sc_String, type, name); + sc_String, type, name.GetChars()); info = NULL; } else if (info == NULL) { Printf ("Unknown actor %s in %s %s\n", - sc_String, type, name); + sc_String, type, name.GetChars()); } } SET_FIELD (const TypeInfo *, info); @@ -618,7 +621,7 @@ static void GenericParse (FGenericParse *parser, const char **keywords, if (val == -1) { Printf ("Splash %s is not defined yet (in %s %s)\n", - sc_String, type, name); + sc_String, type, name.GetChars()); } break; @@ -683,13 +686,13 @@ static void ParseFloor () // //========================================================================== -int FindSplash (const char *name) +int FindSplash (FName name) { unsigned int i; for (i = 0; i < Splashes.Size (); i++) { - if (stricmp (Splashes[i].Name, name) == 0) + if (Splashes[i].Name == name) { return (int)i; } @@ -703,13 +706,13 @@ int FindSplash (const char *name) // //========================================================================== -int FindTerrain (const char *name) +int FindTerrain (FName name) { unsigned int i; for (i = 0; i < Terrains.Size (); i++) { - if (stricmp (Terrains[i].Name, name) == 0) + if (Terrains[i].Name == name) { return (int)i; } diff --git a/src/p_terrain.h b/src/p_terrain.h index c75bea5bec..5c9a7c6209 100644 --- a/src/p_terrain.h +++ b/src/p_terrain.h @@ -36,15 +36,17 @@ #include "dobject.h" #include "m_fixed.h" +#include "tarray.h" +#include "name.h" -extern byte *TerrainTypes; +extern TArray TerrainTypes; // at game start void P_InitTerrainTypes (); struct FSplashDef { - const char *Name; + FName Name; int SmallSplashSound; int NormalSplashSound; const TypeInfo *SmallSplash; @@ -60,7 +62,7 @@ struct FSplashDef struct FTerrainDef { - const char *Name; + FName Name; int Splash; int DamageAmount; int DamageMOD; diff --git a/src/r_things.cpp b/src/r_things.cpp index 5c1606d4ce..0e6949e8d0 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -785,6 +785,13 @@ void R_InitSprites () qsort (&skins[1], numskins-1, sizeof(FPlayerSkin), skinsorter); } +static struct SkinDeleter +{ + ~SkinDeleter() + { + if (skins!=NULL) delete[] skins; + } +} DeleteTheSkins; // diff --git a/src/thingdef.cpp b/src/thingdef.cpp index b1057f7895..48272eb097 100644 --- a/src/thingdef.cpp +++ b/src/thingdef.cpp @@ -1015,7 +1015,7 @@ void A_NoBlocking (AActor *actor) { if (di->Name != NAME_None) { - const TypeInfo *ti = TypeInfo::FindType(di->Name); + const TypeInfo *ti = TypeInfo::IFindType(di->Name); if (ti) P_DropItem (actor, ti, di->amount, di->probability); } di = di->Next; @@ -3618,7 +3618,7 @@ void FinishThingdef() v = defaults->AmmoType1; if (v != NAME_None && v.IsValidName()) { - defaults->AmmoType1 = TypeInfo::FindType(v.GetChars()); + defaults->AmmoType1 = TypeInfo::IFindType(v.GetChars()); if (!defaults->AmmoType1) { SC_ScriptError("Unknown ammo type '%s' in '%s'\n", v.GetChars(), ti->Name+1); @@ -3632,7 +3632,7 @@ void FinishThingdef() v = defaults->AmmoType2; if (v != NAME_None && v.IsValidName()) { - defaults->AmmoType2 = TypeInfo::FindType(v.GetChars()); + defaults->AmmoType2 = TypeInfo::IFindType(v.GetChars()); if (!defaults->AmmoType2) { SC_ScriptError("Unknown ammo type '%s' in '%s'\n", v.GetChars(), ti->Name+1); @@ -3646,7 +3646,7 @@ void FinishThingdef() v = defaults->SisterWeaponType; if (v != NAME_None && v.IsValidName()) { - defaults->SisterWeaponType = TypeInfo::FindType(v.GetChars()); + defaults->SisterWeaponType = TypeInfo::IFindType(v.GetChars()); if (!defaults->SisterWeaponType) { SC_ScriptError("Unknown sister weapon type '%s' in '%s'\n", v.GetChars(), ti->Name+1); @@ -3677,7 +3677,7 @@ void FinishThingdef() v = defaults->WeaponClass; if (v != NAME_None) { - defaults->WeaponClass = TypeInfo::FindType(v.GetChars()); + defaults->WeaponClass = TypeInfo::IFindType(v.GetChars()); if (!defaults->WeaponClass) { SC_ScriptError("Unknown weapon type '%s' in '%s'\n", v.GetChars(), ti->Name+1); @@ -3695,6 +3695,6 @@ void FinishThingdef() { char fmt[20]; sprintf(fmt, "QuestItem%d", i+1); - QuestItemClasses[i]=TypeInfo::FindType(fmt); + QuestItemClasses[i]=TypeInfo::IFindType(fmt); } }