mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 04:51:19 +00:00
- Fixed: Information added with addkeysection and addmenukey was never freed.
- Fixed: A classic decorate FakeInventory's PickupText was never freed. - Fixed: Colored lights were never freed. - Fixed: When a dehacked patch was applied, the dehacked StateMap was never freed. - Removed termdone checks around atterm(S_ClearSoundData) and atterm(S_Shutdown) because atterm() already checks for duplicates. - Fixed: S_ClearSoundData() should unload all sounds before it clears S_sfx. - Fixed: AltSoundRenderer::LoadSound() didn't check if the sound had already been loaded and lost the old sound data if it had been. - Fixed: FinishDehPatch() needlessly duplicated the new DehackedPickup's name. - Fixed: PatchStrings() allocated a private string and never freed it. SVN r183 (trunk)
This commit is contained in:
parent
9655ee9843
commit
5859aa7194
9 changed files with 102 additions and 48 deletions
|
@ -1,3 +1,17 @@
|
||||||
|
June 10, 2006
|
||||||
|
- Fixed: Information added with addkeysection and addmenukey was never freed.
|
||||||
|
- Fixed: A classic decorate FakeInventory's PickupText was never freed.
|
||||||
|
- Fixed: Colored lights were never freed.
|
||||||
|
- Fixed: When a dehacked patch was applied, the dehacked StateMap was never
|
||||||
|
freed.
|
||||||
|
- Removed termdone checks around atterm(S_ClearSoundData) and
|
||||||
|
atterm(S_Shutdown) because atterm() already checks for duplicates.
|
||||||
|
- Fixed: S_ClearSoundData() should unload all sounds before it clears S_sfx.
|
||||||
|
- Fixed: AltSoundRenderer::LoadSound() didn't check if the sound had already
|
||||||
|
been loaded and lost the old sound data if it had been.
|
||||||
|
- Fixed: FinishDehPatch() needlessly duplicated the new DehackedPickup's name.
|
||||||
|
- Fixed: PatchStrings() allocated a private string and never freed it.
|
||||||
|
|
||||||
June 8, 2006 (Changes by Graf Zahl)
|
June 8, 2006 (Changes by Graf Zahl)
|
||||||
- Changed music name handling in MAPINFO so that music can be specified by
|
- Changed music name handling in MAPINFO so that music can be specified by
|
||||||
full path of a file in a Zip.
|
full path of a file in a Zip.
|
||||||
|
|
|
@ -692,6 +692,7 @@ CCMD (wdir)
|
||||||
if (wadnum < 0)
|
if (wadnum < 0)
|
||||||
{
|
{
|
||||||
Printf ("%s must be loaded to view its directory.\n", argv[1]);
|
Printf ("%s must be loaded to view its directory.\n", argv[1]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < Wads.GetNumLumps(); ++i)
|
for (int i = 0; i < Wads.GetNumLumps(); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1935,42 +1935,32 @@ donewithtext:
|
||||||
|
|
||||||
static int PatchStrings (int dummy)
|
static int PatchStrings (int dummy)
|
||||||
{
|
{
|
||||||
static size_t maxstrlen = 128;
|
|
||||||
static char *holdstring;
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
DPrintf ("[Strings]\n");
|
DPrintf ("[Strings]\n");
|
||||||
|
|
||||||
if (!holdstring)
|
|
||||||
holdstring = (char *)M_Malloc (maxstrlen);
|
|
||||||
|
|
||||||
while ((result = GetLine()) == 1)
|
while ((result = GetLine()) == 1)
|
||||||
{
|
{
|
||||||
*holdstring = '\0';
|
FString holdstring;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
while (maxstrlen < strlen (holdstring) + strlen (Line2) + 8)
|
holdstring += skipwhite (Line2);
|
||||||
|
holdstring.StripRight();
|
||||||
|
if (holdstring.Len() > 0 && holdstring[holdstring.Len()-1] == '\\')
|
||||||
{
|
{
|
||||||
maxstrlen += 128;
|
holdstring.Truncate((long)holdstring.Len()-1);
|
||||||
holdstring = (char *)M_Realloc (holdstring, maxstrlen);
|
|
||||||
}
|
|
||||||
strcat (holdstring, skipwhite (Line2));
|
|
||||||
stripwhite (holdstring);
|
|
||||||
if (holdstring[strlen(holdstring)-1] == '\\')
|
|
||||||
{
|
|
||||||
holdstring[strlen(holdstring)-1] = '\0';
|
|
||||||
Line2 = igets ();
|
Line2 = igets ();
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Line2 = NULL;
|
Line2 = NULL;
|
||||||
|
}
|
||||||
} while (Line2 && *Line2);
|
} while (Line2 && *Line2);
|
||||||
|
|
||||||
ReplaceSpecialChars (holdstring);
|
ReplaceSpecialChars (holdstring.LockBuffer());
|
||||||
// [RH] There used to be some code here to add % specifiers to
|
holdstring.UnlockBuffer();
|
||||||
// obituaries that lacked them for compatibility with old ZDoom
|
|
||||||
// versions. This code was removed when the string table was
|
|
||||||
// switched to something completely dynamic.
|
|
||||||
GStrings.SetString (Line1, holdstring);
|
GStrings.SetString (Line1, holdstring);
|
||||||
DPrintf ("%s set to:\n%s\n", Line1, holdstring);
|
DPrintf ("%s set to:\n%s\n", Line1, holdstring.GetChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -2274,6 +2264,11 @@ static void UnloadDehSupp ()
|
||||||
{
|
{
|
||||||
if (--DehUseCount <= 0)
|
if (--DehUseCount <= 0)
|
||||||
{
|
{
|
||||||
|
// StateMap is not freed here, because if you load a second
|
||||||
|
// dehacked patch through some means other than including it
|
||||||
|
// in the first patch, it won't see the state information
|
||||||
|
// that was altered by the first. So we need to keep the
|
||||||
|
// StateMap around until all patches have been applied.
|
||||||
DehUseCount = 0;
|
DehUseCount = 0;
|
||||||
delete[] DehSuppLump;
|
delete[] DehSuppLump;
|
||||||
DehSuppLump = NULL;
|
DehSuppLump = NULL;
|
||||||
|
@ -2283,13 +2278,6 @@ static void UnloadDehSupp ()
|
||||||
delete[] OrgSprNames;
|
delete[] OrgSprNames;
|
||||||
OrgSprNames = NULL;
|
OrgSprNames = NULL;
|
||||||
}
|
}
|
||||||
/* No! Not if we want to load multiple independant patches!
|
|
||||||
if (StateMap != NULL)
|
|
||||||
{
|
|
||||||
delete[] StateMap;
|
|
||||||
StateMap = NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (BitNames != NULL)
|
if (BitNames != NULL)
|
||||||
{
|
{
|
||||||
delete[] BitNames;
|
delete[] BitNames;
|
||||||
|
@ -2531,7 +2519,7 @@ void FinishDehPatch ()
|
||||||
char typeNameBuilder[32];
|
char typeNameBuilder[32];
|
||||||
sprintf (typeNameBuilder, "DehackedPickup%d", touchedIndex);
|
sprintf (typeNameBuilder, "DehackedPickup%d", touchedIndex);
|
||||||
PClass *subclass = RUNTIME_CLASS(ADehackedPickup)->CreateDerivedClass
|
PClass *subclass = RUNTIME_CLASS(ADehackedPickup)->CreateDerivedClass
|
||||||
(copystring(typeNameBuilder), sizeof(ADehackedPickup));
|
(typeNameBuilder, sizeof(ADehackedPickup));
|
||||||
AActor *defaults2 = GetDefaultByType (subclass);
|
AActor *defaults2 = GetDefaultByType (subclass);
|
||||||
memcpy (defaults2, defaults1, sizeof(AActor));
|
memcpy (defaults2, defaults1, sizeof(AActor));
|
||||||
subclass->ActorInfo->GameFilter = type->ActorInfo->GameFilter;
|
subclass->ActorInfo->GameFilter = type->ActorInfo->GameFilter;
|
||||||
|
@ -2554,6 +2542,13 @@ void FinishDehPatch ()
|
||||||
// Since deh.MaxHealth was used incorrectly this can only be set
|
// Since deh.MaxHealth was used incorrectly this can only be set
|
||||||
// after finishing with the DEH stuff.
|
// after finishing with the DEH stuff.
|
||||||
if (deh.MaxHealth == -1) deh.MaxHealth = 100;
|
if (deh.MaxHealth == -1) deh.MaxHealth = 100;
|
||||||
|
|
||||||
|
// Now that all Dehacked patches have been processed, it's okay to free StateMap.
|
||||||
|
if (StateMap != NULL)
|
||||||
|
{
|
||||||
|
delete[] StateMap;
|
||||||
|
StateMap = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleNoSector()
|
void HandleNoSector()
|
||||||
|
|
|
@ -103,16 +103,16 @@ class AFakeInventory : public AInventory
|
||||||
{
|
{
|
||||||
DECLARE_STATELESS_ACTOR (AFakeInventory, AInventory);
|
DECLARE_STATELESS_ACTOR (AFakeInventory, AInventory);
|
||||||
public:
|
public:
|
||||||
char *PickupText;
|
|
||||||
bool Respawnable;
|
bool Respawnable;
|
||||||
|
|
||||||
const char *PickupMessage ()
|
const char *PickupMessage ()
|
||||||
{
|
{
|
||||||
if (PickupText == 0)
|
const char *text = GetClass()->Meta.GetMetaString (AIMETA_PickupMessage);
|
||||||
|
if (text == 0)
|
||||||
{
|
{
|
||||||
return Super::PickupMessage();
|
return Super::PickupMessage();
|
||||||
}
|
}
|
||||||
return PickupText;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldRespawn ()
|
bool ShouldRespawn ()
|
||||||
|
@ -860,7 +860,7 @@ static void ParseInsideDecoration (FActorInfo *info, AActor *defaults,
|
||||||
else if (def == DEF_Pickup && SC_Compare ("PickupMessage"))
|
else if (def == DEF_Pickup && SC_Compare ("PickupMessage"))
|
||||||
{
|
{
|
||||||
SC_MustGetString ();
|
SC_MustGetString ();
|
||||||
inv->PickupText = copystring (sc_String);
|
info->Class->Meta.SetMetaString(AIMETA_PickupMessage, sc_String);
|
||||||
}
|
}
|
||||||
else if (def == DEF_Pickup && SC_Compare ("Respawns"))
|
else if (def == DEF_Pickup && SC_Compare ("Respawns"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -2941,6 +2941,30 @@ void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection)
|
||||||
|
|
||||||
static int AddKeySpot;
|
static int AddKeySpot;
|
||||||
|
|
||||||
|
static void FreeKeySections()
|
||||||
|
{
|
||||||
|
const unsigned int numStdControls = countof(ControlsItems);
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = numStdControls; i < CustomControlsItems.Size(); ++i)
|
||||||
|
{
|
||||||
|
menuitem_t *item = &CustomControlsItems[i];
|
||||||
|
if (item->type == whitetext || item->type == control)
|
||||||
|
{
|
||||||
|
if (item->label != NULL)
|
||||||
|
{
|
||||||
|
delete[] item->label;
|
||||||
|
item->label = NULL;
|
||||||
|
}
|
||||||
|
if (item->e.command != NULL)
|
||||||
|
{
|
||||||
|
delete[] item->e.command;
|
||||||
|
item->e.command = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CCMD (addkeysection)
|
CCMD (addkeysection)
|
||||||
{
|
{
|
||||||
if (argv.argc() != 3)
|
if (argv.argc() != 3)
|
||||||
|
@ -2973,6 +2997,7 @@ CCMD (addkeysection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atterm (FreeKeySections);
|
||||||
if (i == last)
|
if (i == last)
|
||||||
{ // Add the new section
|
{ // Add the new section
|
||||||
// Limit the ini name to 32 chars
|
// Limit the ini name to 32 chars
|
||||||
|
|
|
@ -547,6 +547,13 @@ static void S_ClearSoundData()
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
if (GSnd != NULL)
|
||||||
|
{
|
||||||
|
for (i = 0; i < S_sfx.Size(); ++i)
|
||||||
|
{
|
||||||
|
GSnd->UnloadSound (&S_sfx[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
S_sfx.Clear();
|
S_sfx.Clear();
|
||||||
|
|
||||||
for(i = 0; i < countof(Ambients); i++)
|
for(i = 0; i < countof(Ambients); i++)
|
||||||
|
@ -584,14 +591,9 @@ static void S_ClearSoundData()
|
||||||
|
|
||||||
void S_ParseSndInfo ()
|
void S_ParseSndInfo ()
|
||||||
{
|
{
|
||||||
static bool termdone=false;
|
|
||||||
int lump;
|
int lump;
|
||||||
|
|
||||||
if (!termdone)
|
atterm (S_ClearSoundData);
|
||||||
{
|
|
||||||
termdone=true;
|
|
||||||
atterm (S_ClearSoundData);
|
|
||||||
}
|
|
||||||
S_ClearSoundData(); // remove old sound data first!
|
S_ClearSoundData(); // remove old sound data first!
|
||||||
|
|
||||||
CurrentPitchMask = 0;
|
CurrentPitchMask = 0;
|
||||||
|
|
|
@ -280,16 +280,11 @@ void S_AddLocalSndInfo(int lump);
|
||||||
|
|
||||||
void S_Init ()
|
void S_Init ()
|
||||||
{
|
{
|
||||||
static bool termdone=false;
|
|
||||||
int i;
|
int i;
|
||||||
int curvelump;
|
int curvelump;
|
||||||
|
|
||||||
Printf ("S_Init\n");
|
Printf ("S_Init\n");
|
||||||
if (!termdone)
|
atterm (S_Shutdown);
|
||||||
{
|
|
||||||
termdone=true;
|
|
||||||
atterm (S_Shutdown);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove old data (S_Init can be called multiple times!)
|
// remove old data (S_Init can be called multiple times!)
|
||||||
LastLocalSndInfo = LastLocalSndSeq = "";
|
LastLocalSndInfo = LastLocalSndSeq = "";
|
||||||
|
|
|
@ -632,7 +632,12 @@ void AltSoundRenderer::LoadSound (sfxinfo_t *sfx)
|
||||||
SDWORD len;
|
SDWORD len;
|
||||||
BYTE *sfxdata, *sfxstart;
|
BYTE *sfxdata, *sfxstart;
|
||||||
SDWORD size;
|
SDWORD size;
|
||||||
|
|
||||||
|
if (sfx->data != NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
size = sfx->lumpnum >= 0 ? Wads.LumpLength (sfx->lumpnum) : 0;
|
size = sfx->lumpnum >= 0 ? Wads.LumpLength (sfx->lumpnum) : 0;
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,6 +63,8 @@ BYTE InverseColormap[NUMCOLORMAPS*256];
|
||||||
BYTE GoldColormap[NUMCOLORMAPS*256];
|
BYTE GoldColormap[NUMCOLORMAPS*256];
|
||||||
int Near255;
|
int Near255;
|
||||||
|
|
||||||
|
static void FreeSpecialLights();;
|
||||||
|
|
||||||
FColorMatcher ColorMatcher;
|
FColorMatcher ColorMatcher;
|
||||||
|
|
||||||
/* Current color blending values */
|
/* Current color blending values */
|
||||||
|
@ -337,6 +339,8 @@ void InitPalette ()
|
||||||
bool usingBuild = false;
|
bool usingBuild = false;
|
||||||
int lump;
|
int lump;
|
||||||
|
|
||||||
|
atterm (FreeSpecialLights);
|
||||||
|
|
||||||
if ((lump = Wads.CheckNumForFullName ("palette.dat")) >= 0 && Wads.LumpLength (lump) >= 768)
|
if ((lump = Wads.CheckNumForFullName ("palette.dat")) >= 0 && Wads.LumpLength (lump) >= 768)
|
||||||
{
|
{
|
||||||
usingBuild = FixBuildPalette (pal, lump, false);
|
usingBuild = FixBuildPalette (pal, lump, false);
|
||||||
|
@ -625,7 +629,7 @@ FDynamicColormap *GetSpecialLights (PalEntry color, PalEntry fade, int desaturat
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not found. Create it.
|
// Not found. Create it.
|
||||||
colormap = new FDynamicColormap;;
|
colormap = new FDynamicColormap;
|
||||||
colormap->Maps = new BYTE[NUMCOLORMAPS*256];
|
colormap->Maps = new BYTE[NUMCOLORMAPS*256];
|
||||||
colormap->Next = NormalLight.Next;
|
colormap->Next = NormalLight.Next;
|
||||||
colormap->Color = color;
|
colormap->Color = color;
|
||||||
|
@ -638,6 +642,19 @@ FDynamicColormap *GetSpecialLights (PalEntry color, PalEntry fade, int desaturat
|
||||||
return colormap;
|
return colormap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Free all lights created with GetSpecialLights
|
||||||
|
static void FreeSpecialLights()
|
||||||
|
{
|
||||||
|
FDynamicColormap *colormap, *next;
|
||||||
|
|
||||||
|
for (colormap = NormalLight.Next; colormap != NULL; colormap = next)
|
||||||
|
{
|
||||||
|
next = colormap->Next;
|
||||||
|
delete[] colormap->Maps;
|
||||||
|
delete colormap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Builds NUMCOLORMAPS colormaps lit with the specified color
|
// Builds NUMCOLORMAPS colormaps lit with the specified color
|
||||||
void FDynamicColormap::BuildLights ()
|
void FDynamicColormap::BuildLights ()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue