From 6a264daa04e7b315c8935cf6c0a261a3f75ac5bf Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 31 May 2008 03:49:56 +0000 Subject: [PATCH] - Fixed: DDoomStatusBar::UpdateState() needed the same fix as DSBarInfo::updateState(), since it received a code infusion from there. SVN r1007 (trunk) --- docs/rh-log.txt | 4 ++-- src/g_doom/doom_sbar.cpp | 27 ++++++++++++--------------- src/g_shared/sbarinfo_display.cpp | 18 +++++++++--------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 9c3193502..80e42ed00 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -5,8 +5,8 @@ May 30, 2008 playing while the sound is paused. - Fixed: S_StartNamedSound() looked for SECF_SILENT in MoreFlags instead of Flags. -- Fixed: DSBarInfo::updateState() sprung leaks and didn't allocate enough - space for the fullStateName string. +- Fixed: DSBarInfo::updateState() and DDoomStatusBar::UpdateState() sprung + leaks and didn't allocate enough space for the fullStateName string. - Disabled DUMB's mono destination mixers. It's not like I'm ever going to target an original SoundBlaster, so they're a waste of space to have around. This trims resample.obj down to ~60k now. diff --git a/src/g_doom/doom_sbar.cpp b/src/g_doom/doom_sbar.cpp index e54658c1a..d944dfbc5 100644 --- a/src/g_doom/doom_sbar.cpp +++ b/src/g_doom/doom_sbar.cpp @@ -801,16 +801,16 @@ private: } } bool useOuch = false; - const char* stateName = new char[5]; + const char *stateName; if ((FaceHealth != -1 && CPlayer->health - FaceHealth > 20) || bOuchActive) { useOuch = true; - stateName = "ouch"; + stateName = "ouch."; } else - stateName = "pain"; - char* fullStateName = new char[sizeof(stateName)+sizeof((const char*) CPlayer->LastDamageType) + 1]; - sprintf(fullStateName, "%s.%s", stateName, (const char*) CPlayer->LastDamageType); + stateName = "pain."; + FString fullStateName; + fullStateName << stateName << CPlayer->LastDamageType; if(FindMugShotState(fullStateName) != NULL) SetMugShotState(fullStateName); else @@ -827,16 +827,16 @@ private: else { bool useOuch = false; - const char* stateName = new char[5]; + const char *stateName; if ((FaceHealth != -1 && CPlayer->health - FaceHealth > 20) || bOuchActive) { useOuch = true; - stateName = "ouch"; + stateName = "ouch."; } else - stateName = "pain"; - char* fullStateName = new char[sizeof(stateName)+sizeof((const char*) CPlayer->LastDamageType) + 1]; - sprintf(fullStateName, "%s.%s", stateName, (const char*) CPlayer->LastDamageType); + stateName = "pain."; + FString fullStateName; + fullStateName << stateName << CPlayer->LastDamageType; if(FindMugShotState(fullStateName) != NULL) SetMugShotState(fullStateName); else @@ -863,11 +863,8 @@ private: } else { - const char* stateName = new char[7]; - stateName = "death"; - //new string the size of stateName and the damage type put together - char* fullStateName = new char[sizeof(stateName)+sizeof((const char*) CPlayer->LastDamageType) + 1]; - sprintf(fullStateName, "%s.%s", stateName, (const char*) CPlayer->LastDamageType); + FString fullStateName; + fullStateName << "death." << CPlayer->LastDamageType; if(FindMugShotState(fullStateName) != NULL) SetMugShotState(fullStateName); else diff --git a/src/g_shared/sbarinfo_display.cpp b/src/g_shared/sbarinfo_display.cpp index 268d502ae..2fbaafc98 100644 --- a/src/g_shared/sbarinfo_display.cpp +++ b/src/g_shared/sbarinfo_display.cpp @@ -1427,12 +1427,12 @@ int DSBarInfo::updateState(bool xdth, bool animatedgodmode) if ((mugshotHealth != -1 && CPlayer->health - mugshotHealth > 20) || ouchActive) { setOuch = true; - stateName = "ouch"; + stateName = "ouch."; } else - stateName = "pain"; + stateName = "pain."; FString fullStateName; - fullStateName << stateName << '.' << CPlayer->LastDamageType; + fullStateName << stateName << CPlayer->LastDamageType; if(FindMugShotState(fullStateName) != NULL) SetMugShotState(fullStateName); else @@ -1453,12 +1453,12 @@ int DSBarInfo::updateState(bool xdth, bool animatedgodmode) if ((mugshotHealth != -1 && CPlayer->health - mugshotHealth > 20) || ouchActive) { setOuch = true; - stateName = "ouch"; + stateName = "ouch."; } else - stateName = "pain"; + stateName = "pain."; FString fullStateName; - fullStateName << stateName << '.' << CPlayer->LastDamageType; + fullStateName << stateName << CPlayer->LastDamageType; if(FindMugShotState(fullStateName) != NULL) SetMugShotState(fullStateName); else @@ -1492,11 +1492,11 @@ int DSBarInfo::updateState(bool xdth, bool animatedgodmode) { const char *stateName; if(!xdth || !(CPlayer->cheats & CF_EXTREMELYDEAD)) - stateName = "death"; + stateName = "death."; else - stateName = "xdeath"; + stateName = "xdeath."; FString fullStateName; - fullStateName << stateName << '.' << CPlayer->LastDamageType; + fullStateName << stateName << CPlayer->LastDamageType; if(FindMugShotState(fullStateName) != NULL) SetMugShotState(fullStateName); else