mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- Had a look at sbarinfo.cpp and noticed a few places where it allocated
character arrays and never freed them. Those have been replaced with uses of FString. (One of these was even an instance of a member variable being set to point at a stack variable.) SVN r622 (trunk)
This commit is contained in:
parent
4131ec141d
commit
e419cc246f
3 changed files with 19 additions and 17 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
December 22, 2007
|
||||||
|
- Had a look at sbarinfo.cpp and noticed a few places where it allocated
|
||||||
|
character arrays and never freed them. Those have been replaced with
|
||||||
|
uses of FString. (One of these was even an instance of a member variable
|
||||||
|
being set to point at a stack variable.)
|
||||||
|
|
||||||
December 22, 2007 (Changes by Graf Zahl)
|
December 22, 2007 (Changes by Graf Zahl)
|
||||||
- Added Karate Chris's teamdamage in MAPINFO submission.
|
- Added Karate Chris's teamdamage in MAPINFO submission.
|
||||||
- Added Blzut3's second SBARINFO update.
|
- Added Blzut3's second SBARINFO update.
|
||||||
|
|
|
@ -737,20 +737,18 @@ int SBarInfo::newImage(const char* patchname)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char * name = new char[9];
|
return this->Images.Push(patchname);
|
||||||
memset(name, '\0', 9);
|
|
||||||
memcpy(name, patchname, 8);
|
|
||||||
this->Images.Push(name);
|
|
||||||
return this->Images.Size() - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//converts a string into a tranlation.
|
//converts a string into a tranlation.
|
||||||
EColorRange SBarInfo::GetTranslation(char* translation)
|
EColorRange SBarInfo::GetTranslation(char* translation)
|
||||||
{
|
{
|
||||||
EColorRange returnVal = CR_UNTRANSLATED;
|
EColorRange returnVal = CR_UNTRANSLATED;
|
||||||
char* namedTranslation = new char[strlen(translation)+3]; //we must send in "[translation]"
|
FString namedTranslation; //we must send in "[translation]"
|
||||||
sprintf(namedTranslation, "[%s]", translation);
|
const BYTE *trans_ptr;
|
||||||
if((returnVal = V_ParseFontColor((const BYTE*&) namedTranslation, CR_UNTRANSLATED, CR_UNTRANSLATED)) == CR_UNDEFINED)
|
namedTranslation.Format("[%s]", translation);
|
||||||
|
trans_ptr = (const BYTE *)(&namedTranslation[0]);
|
||||||
|
if((returnVal = V_ParseFontColor(trans_ptr, CR_UNTRANSLATED, CR_UNTRANSLATED)) == CR_UNDEFINED)
|
||||||
{
|
{
|
||||||
SC_ScriptError("Missing definition for color %s.", translation);
|
SC_ScriptError("Missing definition for color %s.", translation);
|
||||||
}
|
}
|
||||||
|
@ -783,9 +781,7 @@ void SBarInfoCommand::setString(const char* source, int strnum, int maxlength, b
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->string[strnum] = new char[strlen(source) + 1];
|
string[strnum] = source;
|
||||||
memset(this->string[strnum], '\0', strlen(source) + 1);
|
|
||||||
memcpy(this->string[strnum], source, strlen(source));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SBarInfoCommand::SBarInfoCommand() //sets the default values for more predicable behavior
|
SBarInfoCommand::SBarInfoCommand() //sets the default values for more predicable behavior
|
||||||
|
@ -958,7 +954,7 @@ public:
|
||||||
oldHealth = 0;
|
oldHealth = 0;
|
||||||
}
|
}
|
||||||
mugshotHealth = -1;
|
mugshotHealth = -1;
|
||||||
lastPrefix = new char[4];
|
lastPrefix = "";
|
||||||
weaponGrin = false;
|
weaponGrin = false;
|
||||||
chainWiggle = 0;
|
chainWiggle = 0;
|
||||||
}
|
}
|
||||||
|
@ -1054,7 +1050,7 @@ public:
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
//code from doom_sbar.cpp but it should do fine.
|
//code from doom_sbar.cpp but it should do fine.
|
||||||
void SetFace (FPlayerSkin *skin, char* defPrefix)
|
void SetFace (FPlayerSkin *skin, const char* defPrefix)
|
||||||
{
|
{
|
||||||
oldSkin = skin;
|
oldSkin = skin;
|
||||||
const char *nameptrs[ST_NUMFACES];
|
const char *nameptrs[ST_NUMFACES];
|
||||||
|
@ -1297,7 +1293,7 @@ private:
|
||||||
bool xdth = false;
|
bool xdth = false;
|
||||||
if(cmd.special2 != 0)
|
if(cmd.special2 != 0)
|
||||||
xdth = true;
|
xdth = true;
|
||||||
SetFace(oldSkin, cmd.string[0]);
|
SetFace(oldSkin, cmd.string[0].GetChars());
|
||||||
DrawFace(cmd.special, xdth, cmd.x, cmd.y);
|
DrawFace(cmd.special, xdth, cmd.x, cmd.y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1752,7 +1748,7 @@ private:
|
||||||
FImageCollection Faces;
|
FImageCollection Faces;
|
||||||
FPlayerSkin *oldSkin;
|
FPlayerSkin *oldSkin;
|
||||||
FFont *drawingFont;
|
FFont *drawingFont;
|
||||||
char* lastPrefix;
|
FString lastPrefix;
|
||||||
bool weaponGrin;
|
bool weaponGrin;
|
||||||
int faceTimer;
|
int faceTimer;
|
||||||
int faceIndex;
|
int faceIndex;
|
||||||
|
|
|
@ -23,7 +23,7 @@ struct SBarInfoCommand
|
||||||
int y;
|
int y;
|
||||||
int value;
|
int value;
|
||||||
int sprite;
|
int sprite;
|
||||||
char* string[2];
|
FString string[2];
|
||||||
FFont *font;
|
FFont *font;
|
||||||
EColorRange translation;
|
EColorRange translation;
|
||||||
SBarInfoBlock subBlock; //for type SBarInfo_CMD_GAMEMODE
|
SBarInfoBlock subBlock; //for type SBarInfo_CMD_GAMEMODE
|
||||||
|
@ -33,7 +33,7 @@ struct SBarInfoCommand
|
||||||
|
|
||||||
struct SBarInfo
|
struct SBarInfo
|
||||||
{
|
{
|
||||||
TArray<const char*> Images;
|
TArray<FString> Images;
|
||||||
SBarInfoBlock huds[6];
|
SBarInfoBlock huds[6];
|
||||||
bool automapbar;
|
bool automapbar;
|
||||||
bool interpolateHealth;
|
bool interpolateHealth;
|
||||||
|
|
Loading…
Reference in a new issue