Browse Source

engine: more double promotion fixes

pull/2/head
Alibek Omarov 5 years ago
parent
commit
78baf568ae
  1. 3
      engine/client/cl_main.c
  2. 24
      engine/client/in_touch.c
  3. 2
      engine/common/gamma.c
  4. 2
      engine/common/net_chan.c
  5. 2
      engine/server/sv_client.c
  6. 2
      engine/server/sv_main.c
  7. 2
      engine/server/sv_pmove.c
  8. 6
      public/crtlib.c
  9. 9
      public/mathlib.h
  10. 2
      ref_gl/gl_rsurf.c
  11. 4
      ref_gl/gl_studio.c

3
engine/client/cl_main.c

@ -2939,7 +2939,8 @@ void CL_AdjustClock( void )
if( fabs( cl.timedelta ) >= 0.001f ) if( fabs( cl.timedelta ) >= 0.001f )
{ {
double msec, adjust, sign; double msec, adjust;
float sign;
msec = ( cl.timedelta * 1000.0f ); msec = ( cl.timedelta * 1000.0f );
sign = ( msec < 0 ) ? 1.0f : -1.0f; sign = ( msec < 0 ) ? 1.0f : -1.0f;

24
engine/client/in_touch.c

@ -876,18 +876,18 @@ void Touch_DeleteProfile_f( void )
void Touch_InitEditor( void ) void Touch_InitEditor( void )
{ {
float x = 0.1 * (SCR_H/SCR_W); float x = 0.1f * (SCR_H/SCR_W);
float y = 0.05; float y = 0.05f;
Touch_ClearList( &touch.list_edit ); Touch_ClearList( &touch.list_edit );
Touch_AddButton( &touch.list_edit, "close", "touch_default/edit_close.tga", "touch_disableedit", 0, y, x, y + 0.1, (byte*)"\xff\xff\xff\xff" )->flags |= TOUCH_FL_NOEDIT; Touch_AddButton( &touch.list_edit, "close", "touch_default/edit_close.tga", "touch_disableedit", 0, y, x, y + 0.1f, (byte*)"\xff\xff\xff\xff" )->flags |= TOUCH_FL_NOEDIT;
Touch_AddButton( &touch.list_edit, "close", "#Close and save", "", x, y, x + 0.2, y + 0.1, (byte*)"\xff\xff\xff\xff" )->flags |= TOUCH_FL_NOEDIT; Touch_AddButton( &touch.list_edit, "close", "#Close and save", "", x, y, x + 0.2f, y + 0.1f, (byte*)"\xff\xff\xff\xff" )->flags |= TOUCH_FL_NOEDIT;
y += 0.2; y += 0.2f;
Touch_AddButton( &touch.list_edit, "cancel", "touch_default/edit_reset.tga", "touch_reloadconfig", 0, y, x, y + 0.1, (byte*)"\xff\xff\xff\xff" )->flags |= TOUCH_FL_NOEDIT; Touch_AddButton( &touch.list_edit, "cancel", "touch_default/edit_reset.tga", "touch_reloadconfig", 0, y, x, y + 0.1f, (byte*)"\xff\xff\xff\xff" )->flags |= TOUCH_FL_NOEDIT;
Touch_AddButton( &touch.list_edit, "close", "#Cancel and reset", "", x, y, x + 0.2, y + 0.1, (byte*)"\xff\xff\xff\xff" )->flags |= TOUCH_FL_NOEDIT; Touch_AddButton( &touch.list_edit, "close", "#Cancel and reset", "", x, y, x + 0.2f, y + 0.1f, (byte*)"\xff\xff\xff\xff" )->flags |= TOUCH_FL_NOEDIT;
y += 0.2; y += 0.2f;
touch.hidebutton = Touch_AddButton( &touch.list_edit, "showhide", "touch_default/edit_hide.tga", "touch_toggleselection", 0, y, x, y + 0.1, (byte*)"\xff\xff\xff\xff" ); touch.hidebutton = Touch_AddButton( &touch.list_edit, "showhide", "touch_default/edit_hide.tga", "touch_toggleselection", 0, y, x, y + 0.1f, (byte*)"\xff\xff\xff\xff" );
touch.hidebutton->flags |= TOUCH_FL_HIDE | TOUCH_FL_NOEDIT; touch.hidebutton->flags |= TOUCH_FL_HIDE | TOUCH_FL_NOEDIT;
} }
@ -1439,13 +1439,13 @@ static void Touch_Motion( touchEventType type, int fingerID, float x, float y, f
{ {
touch.wheel_amount += touch.wheel_horizontal ? dx : dy; touch.wheel_amount += touch.wheel_horizontal ? dx : dy;
if( touch.wheel_amount > 0.1 ) if( touch.wheel_amount > 0.1f )
{ {
Cbuf_AddText( touch.wheel_down ); Cbuf_AddText( touch.wheel_down );
touch.wheel_count++; touch.wheel_count++;
touch.wheel_amount = 0; touch.wheel_amount = 0;
} }
if( touch.wheel_amount < -0.1 ) if( touch.wheel_amount < -0.1f )
{ {
Cbuf_AddText( touch.wheel_up ); Cbuf_AddText( touch.wheel_up );
touch.wheel_count++; touch.wheel_count++;
@ -1499,7 +1499,7 @@ static void Touch_Motion( touchEventType type, int fingerID, float x, float y, f
// save angle, modify only velocity // save angle, modify only velocity
dabs = sqrt( dx * dx + dy * dy ); dabs = sqrt( dx * dx + dy * dy );
if( dabs < 0.000001 ) if( dabs < 0.000001f )
return; // no motion, avoid division by zero return; // no motion, avoid division by zero
dcos = dx / dabs; dcos = dx / dabs;

2
engine/common/gamma.c

@ -64,7 +64,7 @@ void BuildGammaTable( float lightgamma, float brightness )
for( i = 0; i < 256; i++ ) for( i = 0; i < 256; i++ )
{ {
f = 255.0 * pow(( float )i / 255.0f, TEXGAMMA ); f = 255.0f * pow(( float )i / 255.0f, TEXGAMMA );
inf = (int)(f + 0.5f); inf = (int)(f + 0.5f);
texgammatable[i] = bound( 0, inf, 255 ); texgammatable[i] = bound( 0, inf, 255 );
} }

2
engine/common/net_chan.c

@ -605,7 +605,7 @@ void Netchan_UpdateFlow( netchan_t *chan )
} }
pflow->kbytespersec = (faccumulatedtime == 0.0f) ? 0.0f : bytes / faccumulatedtime / 1024.0f; pflow->kbytespersec = (faccumulatedtime == 0.0f) ? 0.0f : bytes / faccumulatedtime / 1024.0f;
pflow->avgkbytespersec = pflow->avgkbytespersec * FLOW_AVG + pflow->kbytespersec * (1.0 - FLOW_AVG); pflow->avgkbytespersec = pflow->avgkbytespersec * FLOW_AVG + pflow->kbytespersec * (1.0f - FLOW_AVG);
} }
} }

2
engine/server/sv_client.c

@ -2527,7 +2527,7 @@ void SV_ExecuteClientMessage( sv_client_t *cl, sizebuf_t *msg )
if( frame->senttime == 0.0f ) frame->ping_time = 0.0f; if( frame->senttime == 0.0f ) frame->ping_time = 0.0f;
// don't skew ping based on signon stuff either // don't skew ping based on signon stuff either
if(( host.realtime - cl->connection_started ) < 2.0f && ( frame->ping_time > 0.0 )) if(( host.realtime - cl->connection_started ) < 2.0f && ( frame->ping_time > 0.0f ))
frame->ping_time = 0.0f; frame->ping_time = 0.0f;
cl->latency = SV_CalcClientTime( cl ); cl->latency = SV_CalcClientTime( cl );

2
engine/server/sv_main.c

@ -579,7 +579,7 @@ qboolean SV_RunGameFrame( void )
if( sv_fps.value != 0.0f ) if( sv_fps.value != 0.0f )
{ {
double fps = (1.0 / (double)( sv_fps.value - 0.01 )); // FP issues double fps = (1.0 / (double)( sv_fps.value - 0.01f )); // FP issues
int numFrames = 0; int numFrames = 0;
while( sv.time_residual >= fps ) while( sv.time_residual >= fps )

2
engine/server/sv_pmove.c

@ -917,7 +917,7 @@ void SV_SetupMoveInterpolant( sv_client_t *cl )
break; break;
} }
if( i == SV_UPDATE_BACKUP || finalpush - frame->senttime > 1.0 ) if( i == SV_UPDATE_BACKUP || finalpush - frame->senttime > 1.0f )
{ {
memset( svgame.interp, 0, sizeof( svgame.interp )); memset( svgame.interp, 0, sizeof( svgame.interp ));
has_update = false; has_update = false;

6
public/crtlib.c

@ -21,6 +21,10 @@ GNU General Public License for more details.
#include <time.h> #include <time.h>
#include "stdio.h" #include "stdio.h"
#include "crtlib.h" #include "crtlib.h"
#ifdef HAVE_TGMATH_H
#include <tgmath.h>
#endif
void Q_strnupr( const char *in, char *out, size_t size_out ) void Q_strnupr( const char *in, char *out, size_t size_out )
{ {
if( size_out == 0 ) return; if( size_out == 0 ) return;
@ -652,7 +656,7 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
digitsafterdecimal = max( digitsafterdecimal, 0 ); digitsafterdecimal = max( digitsafterdecimal, 0 );
// if it's basically integral, don't do any decimals // if it's basically integral, don't do any decimals
if( fabs( value - (int)value ) < 0.00001 ) if( fabs( value - (int)value ) < 0.00001f )
{ {
Q_sprintf( val, "%i%s", (int)value, suffix ); Q_sprintf( val, "%i%s", (int)value, suffix );
} }

9
public/mathlib.h

@ -33,7 +33,7 @@ GNU General Public License for more details.
#endif #endif
#ifndef M_PI2 #ifndef M_PI2
#define M_PI2 (float)6.28318530717958647692 #define M_PI2 ((float)(M_PI * 2))
#endif #endif
#define M_PI_F ((float)(M_PI)) #define M_PI_F ((float)(M_PI))
@ -73,8 +73,13 @@ GNU General Public License for more details.
#define Q_floor( a ) ((float)(int)(a)) #define Q_floor( a ) ((float)(int)(a))
#define Q_ceil( a ) ((float)(int)((a) + 1)) #define Q_ceil( a ) ((float)(int)((a) + 1))
#define Q_round( x, y ) (floor( x / y + 0.5f ) * y ) #define Q_round( x, y ) (floor( x / y + 0.5f ) * y )
#define Q_rint(x) ((x) < 0 ? ((int)((x)-0.5f)) : ((int)((x)+0.5f))) #define Q_rint(x) ((x) < 0.0f ? ((int)((x)-0.5f)) : ((int)((x)+0.5f)))
#ifdef isnan // check for C99 isnan
#define IS_NAN isnan
#else
#define IS_NAN(x) (((*(int *)&x) & (255<<23)) == (255<<23)) #define IS_NAN(x) (((*(int *)&x) & (255<<23)) == (255<<23))
#endif
#define ALIGN( x, a ) ((( x ) + (( size_t )( a ) - 1 )) & ~(( size_t )( a ) - 1 )) #define ALIGN( x, a ) ((( x ) + (( size_t )( a ) - 1 )) & ~(( size_t )( a ) - 1 ))

2
ref_gl/gl_rsurf.c

@ -805,7 +805,7 @@ void DrawGLPoly( glpoly_t *p, float xScale, float yScale )
} }
texture = R_GetTexture( glState.currentTextures[glState.activeTMU] ); texture = R_GetTexture( glState.currentTextures[glState.activeTMU] );
flRate = abs( flConveyorSpeed ) / (float)texture->srcWidth; flRate = fabs( flConveyorSpeed ) / (float)texture->srcWidth;
flAngle = ( flConveyorSpeed >= 0 ) ? 180 : 0; flAngle = ( flConveyorSpeed >= 0 ) ? 180 : 0;
SinCos( flAngle * ( M_PI_F / 180.0f ), &sy, &cy ); SinCos( flAngle * ( M_PI_F / 180.0f ), &sy, &cy );

4
ref_gl/gl_studio.c

@ -883,7 +883,7 @@ void R_StudioMergeBones( cl_entity_t *e, model_t *m_pSubModel )
matrix3x4 bonematrix; matrix3x4 bonematrix;
static vec4_t q[MAXSTUDIOBONES]; static vec4_t q[MAXSTUDIOBONES];
static float pos[MAXSTUDIOBONES][3]; static float pos[MAXSTUDIOBONES][3];
double f; float f;
if( e->curstate.sequence >= m_pStudioHeader->numseq ) if( e->curstate.sequence >= m_pStudioHeader->numseq )
e->curstate.sequence = 0; e->curstate.sequence = 0;
@ -936,7 +936,7 @@ StudioSetupBones
*/ */
void R_StudioSetupBones( cl_entity_t *e ) void R_StudioSetupBones( cl_entity_t *e )
{ {
double f; float f;
mstudiobone_t *pbones; mstudiobone_t *pbones;
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
mstudioanim_t *panim; mstudioanim_t *panim;

Loading…
Cancel
Save