mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-29 16:24:16 +00:00
engine: common: explicitly cast literals to floats, include tgmath when needed
This commit is contained in:
parent
c67f065d90
commit
edf3fcd398
@ -122,13 +122,13 @@ typedef enum
|
||||
#define XASH_VERSION "0.99" // engine current version
|
||||
|
||||
// PERFORMANCE INFO
|
||||
#define MIN_FPS 20.0 // host minimum fps value for maxfps.
|
||||
#define MAX_FPS 200.0 // upper limit for maxfps.
|
||||
#define HOST_FPS 100.0 // multiplayer games typical fps
|
||||
#define MIN_FPS 20.0f // host minimum fps value for maxfps.
|
||||
#define MAX_FPS 200.0f // upper limit for maxfps.
|
||||
#define HOST_FPS 100.0f // multiplayer games typical fps
|
||||
|
||||
#define MAX_FRAMETIME 0.25
|
||||
#define MIN_FRAMETIME 0.0001
|
||||
#define GAME_FPS 20.0
|
||||
#define MAX_FRAMETIME 0.25f
|
||||
#define MIN_FRAMETIME 0.0001f
|
||||
#define GAME_FPS 20.0f
|
||||
|
||||
#define MAX_CMD_TOKENS 80 // cmd tokens
|
||||
#define MAX_ENTNUMBER 99999 // for server and client parsing
|
||||
|
@ -14,7 +14,10 @@ GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <mathlib.h>
|
||||
#include "mathlib.h"
|
||||
#ifdef HAVE_TGMATH_H
|
||||
#include <tgmath.h>
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gamma conversion support
|
||||
@ -54,7 +57,7 @@ void BuildGammaTable( float lightgamma, float brightness )
|
||||
else f = 0.125f + ((f - g3) / (1.0f - g3)) * 0.875f;
|
||||
|
||||
// convert linear space to desired gamma space
|
||||
inf = (int)( 255.0 * pow( f, g ));
|
||||
inf = (int)( 255.0f * pow( f, g ));
|
||||
|
||||
lightgammatable[i] = bound( 0, inf, 255 );
|
||||
}
|
||||
@ -69,10 +72,10 @@ void BuildGammaTable( float lightgamma, float brightness )
|
||||
for( i = 0; i < 1024; i++ )
|
||||
{
|
||||
// convert from screen gamma space to linear space
|
||||
lineargammatable[i] = 1023 * pow( i / 1023.0, g1 );
|
||||
lineargammatable[i] = 1023 * pow( i / 1023.0f, g1 );
|
||||
|
||||
// convert from linear gamma space to screen space
|
||||
screengammatable[i] = 1023 * pow( i / 1023.0, 1.0 / g1 );
|
||||
screengammatable[i] = 1023 * pow( i / 1023.0f, 1.0f / g1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1004,11 +1004,11 @@ static void Mod_LightMatrixFromTexMatrix( const mtexinfo_t *tx, float lmvecs[2][
|
||||
}
|
||||
|
||||
// put the lighting origin at center the of poly
|
||||
VectorScale( lmvecs[0], (1.0 / lmscale), lmvecs[0] );
|
||||
VectorScale( lmvecs[1], -(1.0 / lmscale), lmvecs[1] );
|
||||
VectorScale( lmvecs[0], (1.0f / lmscale), lmvecs[0] );
|
||||
VectorScale( lmvecs[1], -(1.0f / lmscale), lmvecs[1] );
|
||||
|
||||
lmvecs[0][3] = lmscale * 0.5;
|
||||
lmvecs[1][3] = -lmscale * 0.5;
|
||||
lmvecs[0][3] = lmscale * 0.5f;
|
||||
lmvecs[1][3] = -lmscale * 0.5f;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -340,7 +340,7 @@ static void Mod_StudioCalcBoneAdj( float *adj, const byte *pcontroller )
|
||||
case STUDIO_XR:
|
||||
case STUDIO_YR:
|
||||
case STUDIO_ZR:
|
||||
adj[j] = value * (M_PI / 180.0f);
|
||||
adj[j] = value * (M_PI_F / 180.0f);
|
||||
break;
|
||||
case STUDIO_X:
|
||||
case STUDIO_Y:
|
||||
|
@ -25,7 +25,7 @@ GNU General Public License for more details.
|
||||
|
||||
#define UDP_HEADER_SIZE 28
|
||||
|
||||
#define FLOW_AVG ( 2.0 / 3.0 ) // how fast to converge flow estimates
|
||||
#define FLOW_AVG ( 2.0f / 3.0f ) // how fast to converge flow estimates
|
||||
#define FLOW_INTERVAL 0.1 // don't compute more often than this
|
||||
#define MAX_RELIABLE_PAYLOAD 1400 // biggest packet that has frag and or reliable data
|
||||
|
||||
@ -1678,7 +1678,7 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
|
||||
NET_SendPacketEx( chan->sock, MSG_GetNumBytesWritten( &send ), MSG_GetData( &send ), chan->remote_address, splitsize );
|
||||
}
|
||||
|
||||
if( SV_Active() && sv_lan.value && sv_lan_rate.value > 1000.0 )
|
||||
if( SV_Active() && sv_lan.value && sv_lan_rate.value > 1000.0f )
|
||||
fRate = 1.0f / sv_lan_rate.value;
|
||||
else fRate = 1.0f / chan->rate;
|
||||
|
||||
|
@ -888,7 +888,7 @@ static void NET_AdjustLag( void )
|
||||
converge = dt * 200.0f;
|
||||
if( fabs( diff ) < converge )
|
||||
converge = fabs( diff );
|
||||
if( diff < 0.0 )
|
||||
if( diff < 0.0f )
|
||||
converge = -converge;
|
||||
net.fakelag += converge;
|
||||
}
|
||||
@ -959,7 +959,7 @@ static qboolean NET_LagPacket( qboolean newdata, netsrc_t sock, netadr_t *from,
|
||||
|
||||
while( pPacket != &net.lagdata[sock] )
|
||||
{
|
||||
if( pPacket->receivedtime <= curtime - ( net.fakelag / 1000.0 ))
|
||||
if( pPacket->receivedtime <= curtime - ( net.fakelag / 1000.0f ))
|
||||
break;
|
||||
|
||||
pPacket = pPacket->next;
|
||||
@ -2054,8 +2054,10 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
|
||||
// as after it will run in same frame
|
||||
if( curfile->checktime > 5 )
|
||||
{
|
||||
float speed = (float)curfile->lastchecksize / ( 5.0f * 1024 );
|
||||
|
||||
curfile->checktime = 0;
|
||||
Con_Reportf( "download speed %f KB/s\n", (float)curfile->lastchecksize / ( 5.0 * 1024 ) );
|
||||
Con_Reportf( "download speed %f KB/s\n", speed );
|
||||
curfile->lastchecksize = 0;
|
||||
}
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ loc0:
|
||||
|
||||
side = (front < 0);
|
||||
frac = front / (front - back);
|
||||
frac = bound( 0.0, frac, 1.0 );
|
||||
frac = bound( 0.0f, frac, 1.0f );
|
||||
|
||||
VectorLerp( start, frac, stop, mid );
|
||||
midf = p1f + ( p2f - p1f ) * frac;
|
||||
|
@ -35,7 +35,7 @@ static _inline int16_t ftoi16( float x )
|
||||
#define REAL_TO_SHORT_ACCURATE( x ) ftoi16(x)
|
||||
#else
|
||||
// the "proper" rounding, plain C, a bit slow.
|
||||
#define REAL_TO_SHORT_ACCURATE( x ) (short)((x) > 0.0 ? (x) + 0.5 : (x) - 0.5)
|
||||
#define REAL_TO_SHORT_ACCURATE( x ) (short)((x) > 0.0f ? (x) + 0.5f : (x) - 0.5f)
|
||||
#endif
|
||||
|
||||
// now define the normal rounding.
|
||||
@ -45,4 +45,4 @@ static _inline int16_t ftoi16( float x )
|
||||
#define REAL_TO_SHORT( x ) (short)( x )
|
||||
#endif
|
||||
|
||||
#endif//SAMPLE_H
|
||||
#endif//SAMPLE_H
|
||||
|
@ -20,8 +20,8 @@ GNU General Public License for more details.
|
||||
#define BLOCK 0x40 // one decoding block is 64 samples.
|
||||
|
||||
#define WRITE_SHORT_SAMPLE( samples, sum, clip ) \
|
||||
if(( sum ) > 32767.0 ) { *(samples) = 0x7fff; (clip)++; } \
|
||||
else if(( sum ) < -32768.0 ) { *(samples) = -0x8000; (clip)++; } \
|
||||
if(( sum ) > 32767.0f ) { *(samples) = 0x7fff; (clip)++; } \
|
||||
else if(( sum ) < -32768.0f ) { *(samples) = -0x8000; (clip)++; } \
|
||||
else { *(samples) = REAL_TO_SHORT( sum ); }
|
||||
|
||||
// main synth function, uses the plain dct64
|
||||
@ -308,4 +308,4 @@ int set_synth_functions( mpg123_handle_t *fr )
|
||||
fr->make_decode_tables( fr );
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user