mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 08:41:59 +00:00
- 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. SVN r90 (trunk)
This commit is contained in:
parent
ace3ed1188
commit
763efb3682
11 changed files with 108 additions and 32 deletions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -480,6 +480,25 @@ void P_SpawnDoorRaiseIn5Mins (sector_t *sec)
|
|||
|
||||
TArray<FDoorAnimation> 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)
|
||||
//
|
||||
|
|
|
@ -142,7 +142,19 @@ struct FAnimDef
|
|||
};
|
||||
};
|
||||
|
||||
TArray<FAnimDef *> Anims;
|
||||
class DeletingAnimArray : public TArray<FAnimDef *>
|
||||
{
|
||||
public:
|
||||
~DeletingAnimArray()
|
||||
{
|
||||
for(unsigned i=0;i<Size();i++)
|
||||
{
|
||||
if ((*this)[i] != NULL) free((*this)[i]);
|
||||
(*this)[i]=NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
static DeletingAnimArray Anims;
|
||||
|
||||
// killough 3/7/98: Initialize generalized scrolling
|
||||
static void P_SpawnScrollers();
|
||||
|
|
|
@ -578,6 +578,8 @@ struct FDoorAnimation
|
|||
int NumTextureFrames;
|
||||
char *OpenSound;
|
||||
char *CloseSound;
|
||||
|
||||
~FDoorAnimation();
|
||||
};
|
||||
|
||||
extern TArray<FDoorAnimation> DoorAnimations;
|
||||
|
|
|
@ -114,7 +114,19 @@ static WORD AddSwitchDef (FSwitchDef *def);
|
|||
// CHANGE THE TEXTURE OF A WALL SWITCH TO ITS OPPOSITE
|
||||
//
|
||||
|
||||
static TArray<FSwitchDef *> SwitchList;
|
||||
class DeletingSwitchArray : public TArray<FSwitchDef *>
|
||||
{
|
||||
public:
|
||||
~DeletingSwitchArray()
|
||||
{
|
||||
for(unsigned i=0;i<Size();i++)
|
||||
{
|
||||
if ((*this)[i] != NULL) free((*this)[i]);
|
||||
(*this)[i]=NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
static DeletingSwitchArray SwitchList;
|
||||
|
||||
//
|
||||
// P_InitSwitchList
|
||||
|
|
|
@ -125,10 +125,10 @@ static void ParseOuter ();
|
|||
static void ParseSplash ();
|
||||
static void ParseTerrain ();
|
||||
static void ParseFloor ();
|
||||
static int FindSplash (const char *name);
|
||||
static int FindTerrain (const char *name);
|
||||
static int FindSplash (FName name);
|
||||
static int FindTerrain (FName name);
|
||||
static void GenericParse (FGenericParse *parser, const char **keywords,
|
||||
void *fields, const char *type, const char *name);
|
||||
void *fields, const char *type, FName name);
|
||||
static void ParseDamage (int keyword, void *fields);
|
||||
static void ParseFriction (int keyword, void *fields);
|
||||
|
||||
|
@ -136,7 +136,7 @@ static void ParseFriction (int keyword, void *fields);
|
|||
|
||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||
|
||||
byte *TerrainTypes;
|
||||
TArray<byte>TerrainTypes;
|
||||
TArray<FSplashDef> Splashes;
|
||||
TArray<FTerrainDef> 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;
|
||||
}
|
||||
|
|
|
@ -36,15 +36,17 @@
|
|||
|
||||
#include "dobject.h"
|
||||
#include "m_fixed.h"
|
||||
#include "tarray.h"
|
||||
#include "name.h"
|
||||
|
||||
extern byte *TerrainTypes;
|
||||
extern TArray<byte> 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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
//
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue