engine: client: explicitly cast literals to floats

This commit is contained in:
Alibek Omarov 2019-10-06 06:49:47 +03:00
parent 148846c02d
commit c67f065d90
11 changed files with 50 additions and 50 deletions

View File

@ -55,7 +55,7 @@ short R_LookupColor( byte r, byte g, byte b )
bf = b - clgame.palette[i].b;
// convert color to monochrome
diff = rf * (rf * 0.2) + gf * (gf * 0.5) + bf * (bf * 0.3);
diff = rf * (rf * 0.2f) + gf * (gf * 0.5f) + bf * (bf * 0.3f);
if ( diff < bestdiff )
{

View File

@ -63,7 +63,7 @@ void CL_CalcPlayerVelocity( int idx, vec3_t velocity )
if( dt != 0.0 )
{
VectorSubtract( clgame.entities[idx].curstate.velocity, clgame.entities[idx].prevstate.velocity, delta );
VectorScale( delta, 1.0 / dt, velocity );
VectorScale( delta, 1.0f / dt, velocity );
}
else
{

View File

@ -101,7 +101,7 @@ qboolean CL_EntityTeleported( cl_entity_t *ent )
VectorSubtract( ent->curstate.origin, ent->prevstate.origin, delta );
// compute potential max movement in units per frame and compare with entity movement
maxlen = ( clgame.movevars.maxvelocity * ( 1.0 / GAME_FPS ));
maxlen = ( clgame.movevars.maxvelocity * ( 1.0f / GAME_FPS ));
len = VectorLength( delta );
return (len > maxlen);
@ -356,7 +356,7 @@ qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, float targettime, positi
for( i = 1; i < HISTORY_MAX - 1; i++ )
{
at = ent->ph[( imod - i ) & HISTORY_MASK].animtime;
if( at == 0.0 ) break;
if( at == 0.0f ) break;
if( targettime > at )
{

View File

@ -272,13 +272,13 @@ static float CL_LerpPoint( void )
if( frac < 0.0f )
{
if( frac < -0.01 )
if( frac < -0.01f )
cl.time = cl.mtime[1];
frac = 0.0f;
}
else if( frac > 1.0f )
{
if( frac > 1.01 )
if( frac > 1.01f )
cl.time = cl.mtime[0];
frac = 1.0f;
}
@ -2941,10 +2941,10 @@ void CL_AdjustClock( void )
{
double msec, adjust, sign;
msec = ( cl.timedelta * 1000.0 );
sign = ( msec < 0 ) ? 1.0 : -1.0;
msec = ( cl.timedelta * 1000.0f );
sign = ( msec < 0 ) ? 1.0f : -1.0f;
msec = fabs( msec );
adjust = sign * ( cl_fixtimerate->value / 1000.0 );
adjust = sign * ( cl_fixtimerate->value / 1000.0f );
if( fabs( adjust ) < fabs( cl.timedelta ))
{

View File

@ -18,10 +18,10 @@ GNU General Public License for more details.
#define NET_TIMINGS 1024
#define NET_TIMINGS_MASK (NET_TIMINGS - 1)
#define LATENCY_AVG_FRAC 0.5
#define FRAMERATE_AVG_FRAC 0.5
#define PACKETLOSS_AVG_FRAC 0.5
#define PACKETCHOKE_AVG_FRAC 0.5
#define LATENCY_AVG_FRAC 0.5f
#define FRAMERATE_AVG_FRAC 0.5f
#define PACKETLOSS_AVG_FRAC 0.5f
#define PACKETCHOKE_AVG_FRAC 0.5f
#define NETGRAPH_LERP_HEIGHT 24
#define NETGRAPH_NET_COLORS 5
#define NUM_LATENCY_SAMPLES 8
@ -203,7 +203,7 @@ void NetGraph_GetFrameData( float *latency, int *latency_count )
else
{
int frame_latency = Q_min( 1.0f, f->latency );
p->latency = (( frame_latency + 0.1 ) / 1.1 ) * ( net_graphheight->value - NETGRAPH_LERP_HEIGHT - 2 );
p->latency = (( frame_latency + 0.1f ) / 1.1f ) * ( net_graphheight->value - NETGRAPH_LERP_HEIGHT - 2 );
if( i > cls.netchan.incoming_sequence - NUM_LATENCY_SAMPLES )
{
@ -229,12 +229,12 @@ void NetGraph_GetFrameData( float *latency, int *latency_count )
}
// packet loss
loss = 100.0 * (float)loss_count / CL_UPDATE_BACKUP;
packet_loss = PACKETLOSS_AVG_FRAC * packet_loss + ( 1.0 - PACKETLOSS_AVG_FRAC ) * loss;
loss = 100.0f * (float)loss_count / CL_UPDATE_BACKUP;
packet_loss = PACKETLOSS_AVG_FRAC * packet_loss + ( 1.0f - PACKETLOSS_AVG_FRAC ) * loss;
// packet choke
choke = 100.0 * (float)choke_count / CL_UPDATE_BACKUP;
packet_choke = PACKETCHOKE_AVG_FRAC * packet_choke + ( 1.0 - PACKETCHOKE_AVG_FRAC ) * choke;
choke = 100.0f * (float)choke_count / CL_UPDATE_BACKUP;
packet_choke = PACKETCHOKE_AVG_FRAC * packet_choke + ( 1.0f - PACKETCHOKE_AVG_FRAC ) * choke;
}
/*
@ -365,12 +365,12 @@ void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int count, floa
avg -= 1000.0f / cl_updaterate->value;
// can't be below zero
avg = Q_max( 0.0, avg );
avg = Q_max( 0.0f, avg );
}
else avg = 0.0;
// move rolling average
framerate = FRAMERATE_AVG_FRAC * host.frametime + ( 1.0 - FRAMERATE_AVG_FRAC ) * framerate;
framerate = FRAMERATE_AVG_FRAC * host.frametime + ( 1.0f - FRAMERATE_AVG_FRAC ) * framerate;
Con_SetFont( 0 );
if( framerate > 0.0f )
@ -396,8 +396,8 @@ void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int count, floa
if( net_graph->value > 2 )
{
int loss = (int)(( packet_loss + PACKETLOSS_AVG_FRAC ) - 0.01 );
int choke = (int)(( packet_choke + PACKETCHOKE_AVG_FRAC ) - 0.01 );
int loss = (int)(( packet_loss + PACKETLOSS_AVG_FRAC ) - 0.01f );
int choke = (int)(( packet_choke + PACKETCHOKE_AVG_FRAC ) - 0.01f );
Con_DrawString( x, y, va( "loss: %i choke: %i", loss, choke ), colors );
}

View File

@ -216,7 +216,7 @@ qboolean CL_PlayerTeleported( local_state_t *from, local_state_t *to )
VectorSubtract( to->playerstate.origin, from->playerstate.origin, delta );
// compute potential max movement in units per frame and compare with entity movement
maxlen = ( clgame.movevars.maxvelocity * ( 1.0 / GAME_FPS ));
maxlen = ( clgame.movevars.maxvelocity * ( 1.0f / GAME_FPS ));
len = VectorLength( delta );
return (len > maxlen);
@ -1326,14 +1326,14 @@ void CL_PredictMovement( qboolean repredicting )
cls.correction_time -= host.frametime;
// Make sure smoothtime is postive
if( cl_smoothtime->value <= 0.0 )
if( cl_smoothtime->value <= 0.0f )
Cvar_DirectSet( cl_smoothtime, "0.1" );
// Clamp from 0 to cl_smoothtime.value
cls.correction_time = bound( 0.0, cls.correction_time, cl_smoothtime->value );
// Compute backward interpolation fraction along full correction
frac = 1.0 - cls.correction_time / cl_smoothtime->value;
frac = 1.0f - cls.correction_time / cl_smoothtime->value;
// Determine how much error we still have to make up for
VectorSubtract( cl.simorg, cl.local.lastorigin, delta );

View File

@ -85,7 +85,7 @@ static qboolean CL_QuakeEntityTeleported( cl_entity_t *ent, entity_state_t *news
VectorSubtract( newstate->origin, ent->prevstate.origin, delta );
// compute potential max movement in units per frame and compare with entity movement
maxlen = ( clgame.movevars.maxvelocity * ( 1.0 / GAME_FPS ));
maxlen = ( clgame.movevars.maxvelocity * ( 1.0f / GAME_FPS ));
len = VectorLength( delta );
return (len > maxlen);

View File

@ -45,7 +45,7 @@ void V_CalcViewRect( void )
sb_lines = 24; // no inventory
else sb_lines = 48;
if( scr_viewsize->value >= 100.0 )
if( scr_viewsize->value >= 100.0f )
{
full = true;
size = 100.0f;
@ -58,7 +58,7 @@ void V_CalcViewRect( void )
sb_lines = 0;
full = true;
}
size /= 100.0;
size /= 100.0f;
clgame.viewport[2] = refState.width * size;
clgame.viewport[3] = refState.height * size;
@ -416,7 +416,7 @@ void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes,
void R_ShowTree( void )
{
float x = (float)((refState.width - (int)POINT_SIZE) >> 1);
float y = NODE_INTERVAL_Y(1.0);
float y = NODE_INTERVAL_Y(1.0f);
mleaf_t *viewleaf;
if( !cl.worldmodel || !CVAR_TO_BOOL( r_showtree ))

View File

@ -167,7 +167,7 @@ convar_t *touch_joy_texture;
convar_t *touch_emulate;
// code looks smaller with it
#define B(x) button->x
#define B(x) (button->x)
#define SCR_W ((float)refState.width)
#define SCR_H ((float)refState.height)
#define TO_SCRN_Y(x) (refState.height * (x))
@ -1065,7 +1065,7 @@ void Touch_DrawTexture ( float x1, float y1, float x2, float y2, int texture, by
#define GRID_COUNT_X ((int)touch_grid_count->value)
#define GRID_COUNT_Y (((int)touch_grid_count->value) * SCR_H / SCR_W)
#define GRID_X (1.0/GRID_COUNT_X)
#define GRID_X (1.0f/GRID_COUNT_X)
#define GRID_Y (SCR_W/SCR_H/GRID_COUNT_X)
#define GRID_ROUND_X(x) ((float)round( x * GRID_COUNT_X ) / GRID_COUNT_X)
#define GRID_ROUND_Y(x) ((float)round( x * GRID_COUNT_Y ) / GRID_COUNT_Y)
@ -1846,14 +1846,14 @@ int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx
{
static float y1 = 0;
y1 += dy;
if( dy > 0.4 )
if( dy > 0.4f )
Con_Bottom();
if( y1 > 0.01 )
if( y1 > 0.01f )
{
Con_PageUp( 1 );
y1 = 0;
}
if( y1 < -0.01 )
if( y1 < -0.01f )
{
Con_PageDown( 1 );
y1 = 0;

View File

@ -512,45 +512,45 @@ static void IN_JoyAppendMove( usercmd_t *cmd, float forwardmove, float sidemove
moveflags |= S;
}
if ( forwardmove > 0.7 && !( moveflags & F ))
if ( forwardmove > 0.7f && !( moveflags & F ))
{
moveflags |= F;
Cmd_ExecuteString( "+forward" );
}
else if ( forwardmove < 0.7 && ( moveflags & F ))
else if ( forwardmove < 0.7f && ( moveflags & F ))
{
moveflags &= ~F;
Cmd_ExecuteString( "-forward" );
}
if ( forwardmove < -0.7 && !( moveflags & B ))
if ( forwardmove < -0.7f && !( moveflags & B ))
{
moveflags |= B;
Cmd_ExecuteString( "+back" );
}
else if ( forwardmove > -0.7 && ( moveflags & B ))
else if ( forwardmove > -0.7f && ( moveflags & B ))
{
moveflags &= ~B;
Cmd_ExecuteString( "-back" );
}
if ( sidemove > 0.9 && !( moveflags & R ))
if ( sidemove > 0.9f && !( moveflags & R ))
{
moveflags |= R;
Cmd_ExecuteString( "+moveright" );
}
else if ( sidemove < 0.9 && ( moveflags & R ))
else if ( sidemove < 0.9f && ( moveflags & R ))
{
moveflags &= ~R;
Cmd_ExecuteString( "-moveright" );
}
if ( sidemove < -0.9 && !( moveflags & L ))
if ( sidemove < -0.9f && !( moveflags & L ))
{
moveflags |= L;
Cmd_ExecuteString( "+moveleft" );
}
else if ( sidemove > -0.9 && ( moveflags & L ))
else if ( sidemove > -0.9f && ( moveflags & L ))
{
moveflags &= ~L;
Cmd_ExecuteString( "-moveleft" );

View File

@ -321,13 +321,13 @@ static winding_t *winding_clip( winding_t *in, const mplane_t *split, qboolean k
for( j = 0; j < 3; j++ )
{
// avoid round off error when possible
if( in->plane->normal[j] == 1.0 )
if( in->plane->normal[j] == 1.0f )
mid[j] = in->plane->dist;
else if( in->plane->normal[j] == -1.0 )
else if( in->plane->normal[j] == -1.0f )
mid[j] = -in->plane->dist;
else if( split->normal[j] == 1.0 )
else if( split->normal[j] == 1.0f )
mid[j] = split->dist;
else if( split->normal[j] == -1.0 )
else if( split->normal[j] == -1.0f )
mid[j] = -split->dist;
else mid[j] = p1[j] + dot * (p2[j] - p1[j]);
}
@ -438,13 +438,13 @@ static void winding_split( winding_t *in, const mplane_t *split, winding_t **pfr
for( j = 0; j < 3; j++ )
{
// avoid round off error when possible
if( in->plane->normal[j] == 1.0 )
if( in->plane->normal[j] == 1.0f )
mid[j] = in->plane->dist;
else if( in->plane->normal[j] == -1.0 )
else if( in->plane->normal[j] == -1.0f )
mid[j] = -in->plane->dist;
else if( split->normal[j] == 1.0 )
else if( split->normal[j] == 1.0f )
mid[j] = split->dist;
else if( split->normal[j] == -1.0 )
else if( split->normal[j] == -1.0f )
mid[j] = -split->dist;
else mid[j] = p1[j] + dot * (p2[j] - p1[j]);
}