Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code clean up. #1

Merged
merged 4 commits into from
May 17, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix build clang. Fix UB.
  • Loading branch information
nekonomicon committed Apr 17, 2016
commit 0adbd65d8a3bb95c7408814e002a3d1dae4bd370
4 changes: 2 additions & 2 deletions cl_dll/StudioModelRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ StudioSetupBones
*/
void CStudioModelRenderer::StudioSetupBones ( void )
{
int i;
int i, j;
double f;

mstudiobone_t *pbones;
Expand Down Expand Up @@ -911,7 +911,7 @@ void CStudioModelRenderer::StudioSetupBones ( void )

for (i = 0; i < m_pStudioHeader->numbones; i++)
{
for( int j = 0; j < LEGS_BONES_COUNT; j++ )
for( j = 0; j < LEGS_BONES_COUNT; j++ )
{
if( !strcmp( pbones[i].name, legs_bones[j] ))
break;
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// NOTE: must include quakedef.h first

#ifndef _CAMERA_H_
#define _CAMEA_H_
#define _CAMERA_H_

// pitch, yaw, dist
extern vec3_t cam_ofs;
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/cl_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int fl
#define AngleVectors (*gEngfuncs.pfnAngleVectors)
extern cvar_t *hud_textmode;
extern float g_hud_text_color[3];
inline int DrawSetTextColor(float r, float g, float b)
inline void DrawSetTextColor(float r, float g, float b)
{
if( hud_textmode->value == 1 )
g_hud_text_color[0]=r, g_hud_text_color[1] = g, g_hud_text_color[2] = b;
Expand All @@ -111,7 +111,7 @@ inline int DrawConsoleString( int x, int y, const char *string )
inline void GetConsoleStringSize( const char *string, int *width, int *height )
{
if( hud_textmode->value == 1 )
*height = 13, *width = gHUD.DrawHudStringLen(string);
*height = 13, *width = gHUD.DrawHudStringLen( (char*)string );
else
gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height );
}
Expand Down
3 changes: 2 additions & 1 deletion cl_dll/death.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ int CHudDeathNotice :: Draw( float flTime )
// This message handler may be better off elsewhere
int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf )
{
int i;
m_iFlags |= HUD_ACTIVE;

BEGIN_READ( pbuf, iSize );
Expand All @@ -171,7 +172,7 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p

gHUD.m_Spectator.DeathMessage(victim);

for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
for ( i = 0; i < MAX_DEATHNOTICES; i++ )
{
if ( rgDeathNoticeList[i].iId == 0 )
break;
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,8 @@ void DLLEXPORT HUD_TempEntUpdate (
s = sin( pTemp->entity.baseline.origin[2] + fastFreq );
c = cos( pTemp->entity.baseline.origin[2] + fastFreq );

pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin( client_time * 20 + (int)pTemp );
pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)pTemp );
pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin( client_time * 20 + (int)(size_t)pTemp );
pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)(size_t)pTemp );
pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime;
}

Expand Down
2 changes: 1 addition & 1 deletion cl_dll/geiger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
int CHudGeiger::Draw (float flTime)
{
int pct;
float flvol;
float flvol = 0.0f;
int rg[3];
int i;

Expand Down
6 changes: 3 additions & 3 deletions cl_dll/health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ int CHudHealth::DrawPain(float flTime)

int CHudHealth::DrawDamage(float flTime)
{
int r, g, b, a;
int i, r, g, b, a;
DAMAGE_IMAGE *pdmg;

if (!m_bitsDamage)
Expand All @@ -390,7 +390,7 @@ int CHudHealth::DrawDamage(float flTime)
ScaleColors(r, g, b, a);

// Draw all the items
for (int i = 0; i < NUM_DMG_TYPES; i++)
for (i = 0; i < NUM_DMG_TYPES; i++)
{
if (m_bitsDamage & giDmgFlags[i])
{
Expand All @@ -404,7 +404,7 @@ int CHudHealth::DrawDamage(float flTime)
// check for bits that should be expired
for ( i = 0; i < NUM_DMG_TYPES; i++ )
{
DAMAGE_IMAGE *pdmg = &m_dmg[i];
pdmg = &m_dmg[i];

if ( m_bitsDamage & giDmgFlags[i] )
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/hl/hl_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ void HUD_InitClientWeapons( void )
// Pass through to engine
g_engfuncs.pfnPrecacheEvent = gEngfuncs.pfnPrecacheEvent;
g_engfuncs.pfnRandomFloat = gEngfuncs.pfnRandomFloat;
g_engfuncs.pfnRandomLong = RandomLong;
g_engfuncs.pfnRandomLong = gEngfuncs.pfnRandomLong;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a different funtion prototypes. Isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. It seems Uncle Mike changed it.


// Allocate a slot for the local player
HUD_PrepEntity( &player , NULL );
Expand Down
5 changes: 3 additions & 2 deletions cl_dll/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ int CHud :: GetSpriteIndex( const char *SpriteName )

void CHud :: VidInit( void )
{
int j;
m_scrinfo.iSize = sizeof(m_scrinfo);
GetScreenInfo(&m_scrinfo);

Expand Down Expand Up @@ -307,7 +308,7 @@ void CHud :: VidInit( void )
// count the number of sprites of the appropriate res
m_iSpriteCount = 0;
client_sprite_t *p = m_pSpriteList;
for ( int j = 0; j < m_iSpriteCountAllRes; j++ )
for ( j = 0; j < m_iSpriteCountAllRes; j++ )
{
if ( p->iRes == m_iRes )
m_iSpriteCount++;
Expand Down Expand Up @@ -346,7 +347,7 @@ void CHud :: VidInit( void )

// count the number of sprites of the appropriate res
m_iSpriteCount = 0;
for ( int j = 0; j < m_iSpriteCountAllRes; j++ )
for ( j = 0; j < m_iSpriteCountAllRes; j++ )
{
if ( p->iRes == m_iRes )
m_iSpriteCount++;
Expand Down
3 changes: 3 additions & 0 deletions cl_dll/hud_spectator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,9 @@ bool CHudSpectator::ParseOverviewFile( )

char *pfile = NULL;

memset( filename, 0, 255 );
memset( levelname, 0, 255 );
memset( token, 0, 1024 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a C++. Why not to use array initializers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'm rework it.

memset( &m_OverviewData, 0, sizeof(m_OverviewData));

// fill in standrd values
Expand Down
4 changes: 3 additions & 1 deletion cl_dll/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ int CHudMenu :: VidInit( void )

int CHudMenu :: Draw( float flTime )
{
int i;

// check for if menu is set to disappear
if ( m_flShutoffTime > 0 )
{
Expand All @@ -83,7 +85,7 @@ int CHudMenu :: Draw( float flTime )

// count the number of newlines
int nlc = 0;
for ( int i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
for ( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
{
if ( g_szMenuString[i] == '\n' )
nlc++;
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int CHudMessage::YPosition( float y, int height )

void CHudMessage::MessageScanNextChar( void )
{
int srcRed, srcGreen, srcBlue, destRed, destGreen, destBlue;
int srcRed, srcGreen, srcBlue, destRed = 0, destGreen = 0, destBlue = 0;
int blend;

srcRed = m_parms.pMessage->r1;
Expand Down
3 changes: 2 additions & 1 deletion cl_dll/saytext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )

void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
{
int i;
ConsolePrint( pszBuf );

// find an empty string slot
for ( int i = 0; i < MAX_LINES; i++ )
for ( i = 0; i < MAX_LINES; i++ )
{
if ( ! *g_szLineBuffer[i] )
break;
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/scoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pb
if ( j > m_iNumTeams )
{ // they aren't in a listed team, so make a new one
// search through for an empty team slot
for ( int j = 1; j <= m_iNumTeams; j++ )
for ( j = 1; j <= m_iNumTeams; j++ )
{
if ( g_TeamInfo[j].name[0] == '\0' )
break;
Expand Down
4 changes: 3 additions & 1 deletion cl_dll/status_icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *p
// add the icon to the icon list, and set it's drawing color
void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue )
{
int i;

// check to see if the sprite is in the current list
for ( int i = 0; i < MAX_ICONSPRITES; i++ )
for ( i = 0; i < MAX_ICONSPRITES; i++ )
{
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
break;
Expand Down
5 changes: 2 additions & 3 deletions cl_dll/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void V_NormalizeAngles( float *angles )
}
}

/*

===================
V_InterpolateAngles

Expand Down Expand Up @@ -466,7 +466,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
waterOffset = 0;
if ( pparams->waterlevel >= 2 )
{
int i, contents, waterDist, waterEntity;
int contents, waterDist, waterEntity;
vec3_t point;
waterDist = cl_waterdist->value;

Expand Down Expand Up @@ -661,7 +661,6 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
( pparams->smoothing && ( pparams->maxclients > 1 ) ) )
{
int foundidx;
int i;
float t;

if ( cl_vsmoothing->value < 0.0 )
Expand Down
14 changes: 7 additions & 7 deletions dlls/aflock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void CFlockingFlyer :: Spawn( )

pev->frame = 0;
pev->nextthink = gpGlobals->time + 0.1;
SetThink( &IdleThink );
SetThink( &CFlockingFlyer::IdleThink );
}

//=========================================================
Expand Down Expand Up @@ -292,7 +292,7 @@ void CFlockingFlyer :: Killed( entvars_t *pevAttacker, int iGib )
UTIL_SetSize( pev, Vector(0,0,0), Vector(0,0,0) );
pev->movetype = MOVETYPE_TOSS;

SetThink( &FallHack );
SetThink( &CFlockingFlyer::FallHack );
pev->nextthink = gpGlobals->time + 0.1;
}

Expand Down Expand Up @@ -366,7 +366,7 @@ void CFlockingFlyer :: IdleThink( void )
// see if there's a client in the same pvs as the monster
if ( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) )
{
SetThink( &Start );
SetThink( &CFlockingFlyer::Start );
pev->nextthink = gpGlobals->time + 0.1;
}
}
Expand All @@ -380,11 +380,11 @@ void CFlockingFlyer :: Start( void )

if ( IsLeader() )
{
SetThink( &FlockLeaderThink );
SetThink( &CFlockingFlyer::FlockLeaderThink );
}
else
{
SetThink( &FlockFollowerThink );
SetThink( &CFlockingFlyer::FlockFollowerThink );
}

/*
Expand Down Expand Up @@ -438,7 +438,7 @@ void CFlockingFlyer :: FormFlock( void )
}
}

SetThink( &IdleThink );// now that flock is formed, go to idle and wait for a player to come along.
SetThink( &CFlockingFlyer::IdleThink );// now that flock is formed, go to idle and wait for a player to come along.
pev->nextthink = gpGlobals->time;
}

Expand Down Expand Up @@ -673,7 +673,7 @@ void CFlockingFlyer :: FlockFollowerThink( void )
if ( IsLeader() || !InSquad() )
{
// the leader has been killed and this flyer suddenly finds himself the leader.
SetThink( &FlockLeaderThink );
SetThink( &CFlockingFlyer::FlockLeaderThink );
return;
}

Expand Down
4 changes: 2 additions & 2 deletions dlls/airtank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ void CAirtank :: Spawn( void )
UTIL_SetSize(pev, Vector( -16, -16, 0), Vector(16, 16, 36));
UTIL_SetOrigin( pev, pev->origin );

SetTouch( &TankTouch );
SetThink( &TankThink );
SetTouch( &CAirtank::TankTouch );
SetThink( &CAirtank::TankThink );

pev->flags |= FL_MONSTER;
pev->takedamage = DAMAGE_YES;
Expand Down
24 changes: 12 additions & 12 deletions dlls/apache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ void CApache :: Spawn( void )

if (pev->spawnflags & SF_WAITFORTRIGGER)
{
SetUse( &StartupUse );
SetUse( &CApache::StartupUse );
}
else
{
SetThink( &HuntThink );
SetTouch( &FlyTouch );
SetThink( &CApache::HuntThink );
SetTouch( &CApache::FlyTouch );
pev->nextthink = gpGlobals->time + 1.0;
}

Expand Down Expand Up @@ -186,8 +186,8 @@ void CApache::NullThink( void )

void CApache::StartupUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
SetThink( &HuntThink );
SetTouch( &FlyTouch );
SetThink( &CApache::HuntThink );
SetTouch( &CApache::FlyTouch );
pev->nextthink = gpGlobals->time + 0.1;
SetUse( NULL );
}
Expand All @@ -200,8 +200,8 @@ void CApache :: Killed( entvars_t *pevAttacker, int iGib )
STOP_SOUND( ENT(pev), CHAN_STATIC, "apache/ap_rotor2.wav" );

UTIL_SetSize( pev, Vector( -32, -32, -64), Vector( 32, 32, 0) );
SetThink( &DyingThink );
SetTouch( &CrashTouch );
SetThink( &CApache::DyingThink );
SetTouch( &CApache::CrashTouch );
pev->nextthink = gpGlobals->time + 0.1;
pev->health = 0;
pev->takedamage = DAMAGE_NO;
Expand Down Expand Up @@ -402,7 +402,7 @@ void CApache :: DyingThink( void )
WRITE_BYTE( BREAK_METAL );
MESSAGE_END();

SetThink( &SUB_Remove );
SetThink( &CBaseEntity::SUB_Remove );
pev->nextthink = gpGlobals->time + 0.1;
}
}
Expand Down Expand Up @@ -972,8 +972,8 @@ void CApacheHVR :: Spawn( void )
UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0));
UTIL_SetOrigin( pev, pev->origin );

SetThink( &IgniteThink );
SetTouch( &ExplodeTouch );
SetThink( &CApacheHVR::IgniteThink );
SetTouch( &CGrenade::ExplodeTouch );

UTIL_MakeAimVectors( pev->angles );
m_vecForward = gpGlobals->v_forward;
Expand Down Expand Up @@ -1019,7 +1019,7 @@ void CApacheHVR :: IgniteThink( void )
MESSAGE_END(); // move PHS/PVS data sending into here (SEND_ALL, SEND_PVS, SEND_PHS)

// set to accelerate
SetThink( &AccelerateThink );
SetThink( &CApacheHVR::AccelerateThink );
pev->nextthink = gpGlobals->time + 0.1;
}

Expand Down Expand Up @@ -1047,4 +1047,4 @@ void CApacheHVR :: AccelerateThink( void )
}


#endif
#endif
Loading