Skip to content

Commit

Permalink
Fix uninitialized variable warnings that aren't bugs
Browse files Browse the repository at this point in the history
(cherry picked from commit 70b19f7)
  • Loading branch information
SamVanheer authored and LogicAndTrick committed Dec 26, 2021
1 parent 4793119 commit 199dc69
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cl_dll/hl/hl_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Only produces random numbers to match the server ones.
*/
Vector CBaseEntity::FireBulletsPlayer(unsigned int cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t* pevAttacker, int shared_rand)
{
float x, y, z;
float x = 0, y = 0, z;

for (unsigned int iShot = 1; iShot <= cShots; iShot++)
{
Expand Down
1 change: 1 addition & 0 deletions cl_dll/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ bool CHudMessage::Draw(float fTime)
// This is when the message is over
switch (pMessage->effect)
{
default:
case 0:
case 1:
endTime = m_startTime[i] + pMessage->fadein + pMessage->fadeout + pMessage->holdtime;
Expand Down
3 changes: 2 additions & 1 deletion cl_dll/vgui_TeamFortressViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ void TeamFortressViewport::SetCurrentMenu(CMenuPanel* pMenu)
CMenuPanel* TeamFortressViewport::CreateTextWindow(int iTextToShow)
{
char sz[256];
char* cText;
const char* cText = "";
char* pfile = NULL;
static const int MAX_TITLE_LENGTH = 64;
char cTitle[MAX_TITLE_LENGTH];
Expand Down Expand Up @@ -1788,6 +1788,7 @@ CMenuPanel* TeamFortressViewport::CreateTextWindow(int iTextToShow)
{
sprintf(sz, "classes/long_%s.txt", sTFClassSelection[g_iPlayerClass]);
}
//TODO: This is a bug waiting to happen, won't be freed later on. Use IFileSystem
char* pfile = (char*)gEngfuncs.COM_LoadFile(sz, 5, NULL);
if (pfile)
{
Expand Down
2 changes: 1 addition & 1 deletion dlls/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ Vector CBaseEntity::FireBulletsPlayer(unsigned int cShots, Vector vecSrc, Vector
TraceResult tr;
Vector vecRight = gpGlobals->v_right;
Vector vecUp = gpGlobals->v_up;
float x, y, z;
float x = 0, y = 0, z;

if (pevAttacker == NULL)
pevAttacker = pev; // the default attacker is ourselves
Expand Down
1 change: 1 addition & 0 deletions dlls/egon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ void CEgon::Fire(const Vector& vecOrigSrc, const Vector& vecDir)

switch (m_fireMode)
{
default:
case FIRE_NARROW:
#ifndef CLIENT_DLL
if (pev->dmgtime < gpGlobals->time)
Expand Down
2 changes: 2 additions & 0 deletions dlls/func_break.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ void CBreakable::Precache()

switch (m_Material)
{
default: //Wood is default, needs to match constant used in KeyValue
case matWood:
pGibName = "models/woodgibs.mdl";

Expand Down Expand Up @@ -450,6 +451,7 @@ void CBreakable::DamageSound()
i = 3;
break;

default: //Wood is default, needs to match constant used in KeyValue
case matWood:
rgpsz[0] = "debris/wood1.wav";
rgpsz[1] = "debris/wood2.wav";
Expand Down
31 changes: 11 additions & 20 deletions dlls/soundent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,28 +270,19 @@ void CSoundEnt ::Initialize()
//=========================================================
int CSoundEnt ::ISoundsInList(int iListType)
{
int i;
int iThisSound;

if (iListType == SOUNDLISTTYPE_FREE)
{
iThisSound = m_iFreeSound;
}
else if (iListType == SOUNDLISTTYPE_ACTIVE)
{
iThisSound = m_iActiveSound;
}
else
int iThisSound = [=]()
{
ALERT(at_debug, "Unknown Sound List Type!\n");
}

if (iThisSound == SOUNDLIST_EMPTY)
{
return 0;
}
switch (iListType)
{
case SOUNDLISTTYPE_FREE: return m_iFreeSound;
case SOUNDLISTTYPE_ACTIVE: return m_iActiveSound;
default:
ALERT(at_console, "Unknown Sound List Type!\n");
return SOUNDLIST_EMPTY;
}
}();

i = 0;
int i = 0;

while (iThisSound != SOUNDLIST_EMPTY)
{
Expand Down
3 changes: 3 additions & 0 deletions dlls/tentacle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ void CTentacle ::HandleAnimEvent(MonsterEvent_t* pEvent)
case 7: // roar
switch (RANDOM_LONG(0, 1))
{
default:
case 0:
sound = "tentacle/te_roar1.wav";
break;
Expand All @@ -905,6 +906,7 @@ void CTentacle ::HandleAnimEvent(MonsterEvent_t* pEvent)
case 8: // search
switch (RANDOM_LONG(0, 1))
{
default:
case 0:
sound = "tentacle/te_search1.wav";
break;
Expand All @@ -919,6 +921,7 @@ void CTentacle ::HandleAnimEvent(MonsterEvent_t* pEvent)
case 9: // swing
switch (RANDOM_LONG(0, 1))
{
default:
case 0:
sound = "tentacle/te_move1.wav";
break;
Expand Down

0 comments on commit 199dc69

Please sign in to comment.