engine: replace Sys_DoubleTime with Platform_DoubleTime in internal code, only use Sys_DoubleTime in APIs

As Sys_DoubleTime is marked with GAME_EXPORT attribute that helps us to
maintain compatible binary interface.
This commit is contained in:
Alibek Omarov
2026-01-13 05:40:53 +05:00
parent 5cdb58431a
commit cb7f2ad8af
18 changed files with 52 additions and 52 deletions

View File

@@ -223,7 +223,7 @@ static void CL_CheckClientState( void )
CL_ServerCommand(true, "specmode 4\n");
}
Con_DPrintf( "client connected at %.2f sec\n", Sys_DoubleTime() - cls.timestart );
Con_DPrintf( "client connected at %.2f sec\n", Platform_DoubleTime() - cls.timestart );
}
}
@@ -1157,7 +1157,7 @@ static void CL_SendConnectPacket( connprotocol_t proto, int challenge )
Con_Printf( "Trying to connect with modern protocol\n" );
}
cls.timestart = Sys_DoubleTime();
cls.timestart = Platform_DoubleTime();
}
/*
@@ -2740,7 +2740,7 @@ static void CL_ReadPackets( void )
return;
// if in the debugger last frame, don't timeout
if( host.frametime > 5.0f ) cls.netchan.last_received = Sys_DoubleTime();
if( host.frametime > 5.0f ) cls.netchan.last_received = Platform_DoubleTime();
// check timeout
if( cls.state >= ca_connected && cls.state != ca_cinematic && !cls.demoplayback )

View File

@@ -172,7 +172,7 @@ get frame data info, like chokes, packet losses, also update graph, packet and c
static void NetGraph_GetFrameData( float *latency, int *latency_count )
{
int i, choke_count = 0, loss_count = 0;
double newtime = Sys_DoubleTime();
double newtime = Platform_DoubleTime();
static double nexttime = 0;
float loss, choke;

View File

@@ -876,7 +876,7 @@ void CL_ParseServerData( sizebuf_t *msg, connprotocol_t proto )
break;
}
cls.timestart = Sys_DoubleTime();
cls.timestart = Platform_DoubleTime();
cls.demowaiting = false; // server is changed
// wipe the client_t struct

View File

@@ -188,7 +188,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
int i;
Con_Reportf( "Serverdata packet received.\n" );
cls.timestart = Sys_DoubleTime();
cls.timestart = Platform_DoubleTime();
cls.demowaiting = false; // server is changed

View File

@@ -73,7 +73,7 @@ void SCR_DrawFPS( int height )
default: return;
}
newtime = Sys_DoubleTime();
newtime = Platform_DoubleTime();
if( newtime >= nexttime )
{
framerate = framecount / (newtime - lasttime);

View File

@@ -1782,7 +1782,7 @@ void Con_DrawDebug( void )
{
int length;
Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs",
host.downloadcount, host.downloadfile, scr_download.value, Sys_DoubleTime() - timeStart );
host.downloadcount, host.downloadfile, scr_download.value, Platform_DoubleTime() - timeStart );
Con_DrawStringLen( dlstring, &length, NULL );
length = Q_max( length, 300 );

View File

@@ -707,7 +707,7 @@ static void Mod_CreatePolygonsForHull( int hullnum )
Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc)
Con_Printf( "generating polygons for hull %u...\n", hullnum );
start = Sys_DoubleTime();
start = Platform_DoubleTime();
// rebuild hulls list
for( i = 0; i < world.num_hull_models; i++ )
@@ -718,7 +718,7 @@ static void Mod_CreatePolygonsForHull( int hullnum )
Q_snprintf( name, sizeof( name ), "*%i", i + 1 );
mod = Mod_FindName( name, false );
}
end = Sys_DoubleTime();
end = Platform_DoubleTime();
Con_Printf( "build time %.3f secs\n", end - start );
}

View File

@@ -935,12 +935,12 @@ static void SX_Profiling_f( void )
Con_Printf( "Profiling 10000 calls to DSP. Sample count is 512, room_type is %i\n", idsp_room );
start = Sys_DoubleTime();
start = Platform_DoubleTime();
for( calls = 10000; calls; calls-- )
{
DSP_Process( testbuffer, 512 );
}
end = Sys_DoubleTime();
end = Platform_DoubleTime();
Con_Printf( "----------\nTook %g seconds.\n", end - start );

View File

@@ -430,7 +430,7 @@ static uint Voice_GetOpusCompressedData( byte *out, uint maxsize, uint *frames )
if( voice.input_file )
{
uint numbytes;
double updateInterval, curtime = Sys_DoubleTime();
double updateInterval, curtime = Platform_DoubleTime();
updateInterval = curtime - voice.start_time;
voice.start_time = curtime;
@@ -505,7 +505,7 @@ static uint Voice_GetGSCompressedData( byte *out, uint maxsize, uint *frames )
if( voice.input_file )
{
uint numbytes;
double updateInterval, curtime = Sys_DoubleTime();
double updateInterval, curtime = Platform_DoubleTime();
updateInterval = curtime - voice.start_time;
voice.start_time = curtime;
@@ -875,7 +875,7 @@ void Voice_RecordStart( void )
Sound_Process( &voice.input_file, voice.samplerate, voice.width, VOICE_PCM_CHANNELS, SOUND_RESAMPLE );
voice.input_file_pos = 0;
voice.start_time = Sys_DoubleTime();
voice.start_time = Platform_DoubleTime();
voice.is_recording = true;
}
else

View File

@@ -298,7 +298,7 @@ void BaseCmd_Test_f( void )
stats.valid = true;
stats.lookups = 0;
start = Sys_DoubleTime() * 1000;
start = Platform_DoubleTime() * 1000;
for( i = 0; i < 1000; i++ )
{
@@ -328,7 +328,7 @@ void BaseCmd_Test_f( void )
Cvar_LookupVars( 0, NULL, &stats.valid, (setpair_t)BaseCmd_CheckCvars );
}
end = Sys_DoubleTime() * 1000;
end = Platform_DoubleTime() * 1000;
dt = end - start;

View File

@@ -886,17 +886,6 @@ int GAME_EXPORT COM_CheckParm( char *parm, char **ppnext )
return i;
}
/*
=============
pfnTime
=============
*/
float GAME_EXPORT pfnTime( void )
{
return (float)Sys_DoubleTime();
}
qboolean COM_IsSafeFileToDownload( const char *filename )
{
char lwrfilename[4096];

View File

@@ -107,17 +107,17 @@ static const feature_message_t engine_features[] =
{ ENGINE_STEP_POSHISTORY_LERP, "MOVETYPE_STEP Position History Based Lerping" },
};
static void Sys_MakeVersionString( char *out, size_t len )
static void Host_MakeVersionString( char *out, size_t len )
{
Q_snprintf( out, len, XASH_ENGINE_NAME " %i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
}
static void Sys_PrintUsage( const char *exename )
static void Host_PrintUsage( const char *exename )
{
string version_str;
const char *usage_str;
Sys_MakeVersionString( version_str, sizeof( version_str ));
Host_MakeVersionString( version_str, sizeof( version_str ));
#if XASH_MESSAGEBOX != MSGBOX_STDERR
#if XASH_WIN32
@@ -224,14 +224,14 @@ static void Sys_PrintUsage( const char *exename )
Sys_Quit( NULL );
}
static void Sys_PrintBugcompUsage( const char *exename )
static void Host_PrintBugcompUsage( const char *exename )
{
string version_str;
char usage_str[4096];
char *p = usage_str;
int i;
Sys_MakeVersionString( version_str, sizeof( version_str ));
Host_MakeVersionString( version_str, sizeof( version_str ));
p += Q_snprintf( p, sizeof( usage_str ) - ( usage_str - p ), "Known bugcomp flags are:\n" );
for( i = 0; i < ARRAYSIZE( bugcomp_features ); i++ )
@@ -691,9 +691,9 @@ static qboolean Host_Autosleep( double dt, double scale )
{
// Platform_Sleep isn't guaranteed to sleep an exact amount of microseconds
// so we measure the real sleep time and use it to decrease the window
double t1 = Sys_DoubleTime(), t2;
double t1 = Platform_DoubleTime(), t2;
Platform_NanoSleep( sleep * 1000 ); // in usec!
t2 = Sys_DoubleTime();
t2 = Platform_DoubleTime();
realsleeptime = t2 - t1;
timewindow -= realsleeptime;
@@ -777,7 +777,7 @@ void Host_Frame( double time )
if( !Host_FilterTime( time ))
return;
t1 = Sys_DoubleTime();
t1 = Platform_DoubleTime();
if( host.framecount == 0 )
Con_DPrintf( "Time to first frame: %.3f seconds\n", t1 - host.starttime );
@@ -790,7 +790,7 @@ void Host_Frame( double time )
HTTP_Run(); // both server and client
host.framecount++;
host.pureframetime = Sys_DoubleTime() - t1;
host.pureframetime = Platform_DoubleTime() - t1;
}
/*
@@ -1021,10 +1021,10 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
string arg;
if( Sys_CheckParm( "-help" ) || Sys_CheckParm( "-h" ) || Sys_CheckParm( "--help" ))
Sys_PrintUsage( exename );
Host_PrintUsage( exename );
if( Sys_GetParmFromCmdLine( "-bugcomp", arg ) && !Q_stricmp( arg, "help" ))
Sys_PrintBugcompUsage( exename );
Host_PrintBugcompUsage( exename );
}
host.change_game = bChangeGame || Sys_CheckParm( "-changegame" );
@@ -1187,7 +1187,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
if( setjmp( return_from_main_buf ))
return error_on_exit;
host.starttime = Sys_DoubleTime();
host.starttime = Platform_DoubleTime();
pChangeGame = func; // may be NULL
@@ -1306,7 +1306,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
if( Sys_GetParmFromCmdLine( "-timedemo", demoname ))
Cbuf_AddTextf( "timedemo %s\n", demoname );
oldtime = Sys_DoubleTime() - 0.1;
oldtime = Platform_DoubleTime() - 0.1;
if( Host_IsDedicated( ))
{
@@ -1333,7 +1333,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
// main window message loop
while( host.status != HOST_CRASHED )
{
double newtime = Sys_DoubleTime();
double newtime = Platform_DoubleTime();
COM_Frame( newtime - oldtime );
oldtime = newtime;
}

View File

@@ -117,7 +117,7 @@ static void Image_ReportLookupsCount( const char *name )
static void Image_IncrementLookupTime( void )
{
double t = Sys_DoubleTime();
double t = Platform_DoubleTime();
double dt = t - g_lookup_start;
g_lookup_time += dt;
@@ -125,7 +125,7 @@ static void Image_IncrementLookupTime( void )
g_lookups++;
g_lookups_total++;
g_lookup_start = Sys_DoubleTime();
g_lookup_start = Platform_DoubleTime();
}
#else
static void Image_ReportLookupsCount( const char *name )
@@ -164,7 +164,7 @@ void Image_Reset( void )
#if DEBUG_LOOKUPS_COUNT
g_lookups = 0;
g_lookup_time = 0.0f;
g_lookup_start = Sys_DoubleTime();
g_lookup_start = Platform_DoubleTime();
#endif // DEBUG_LOOKUPS_COUNT
}

View File

@@ -370,7 +370,7 @@ static qboolean Sound_ResampleInternal( wavdata_t *sc, int outrate, int outwidth
if( inrate == outrate && inwidth == outwidth && inchannels == outchannels )
return false;
t1 = Sys_DoubleTime();
t1 = Platform_DoubleTime();
stepscale = (double)inrate / outrate; // this is usually 0.5, 1, or 2
outcount = sc->samples / stepscale;
@@ -404,7 +404,7 @@ static qboolean Sound_ResampleInternal( wavdata_t *sc, int outrate, int outwidth
return false;
}
t2 = Sys_DoubleTime();
t2 = Platform_DoubleTime();
sc->rate = outrate;
sc->width = outwidth;

View File

@@ -67,6 +67,16 @@ double GAME_EXPORT Sys_DoubleTime( void )
return Platform_DoubleTime();
}
/*
===============
Sys_FloatTime
===============
*/
float GAME_EXPORT Sys_FloatTime( void )
{
return (float)Platform_DoubleTime();
}
/*
================
Sys_DebugBreak

View File

@@ -51,7 +51,8 @@ typedef struct dll_info_s
} dll_info_t;
extern int error_on_exit;
double Sys_DoubleTime( void );
double GAME_EXPORT Sys_DoubleTime( void ); // only for binary compatibility, use Platform_DoubleTime instead
float GAME_EXPORT Sys_FloatTime( void ); // only for binary compatibility, use Platform_DoubleTime instead
char *Sys_GetClipboardData( void );
const char *Sys_GetCurrentUser( void );
int Sys_CheckParm( const char *parm );

View File

@@ -664,7 +664,7 @@ void SV_ActivateServer( int runPhysics )
host.movevars_changed = true;
Host_SetServerState( ss_active );
Con_DPrintf( "level loaded at %.2f sec\n", Sys_DoubleTime() - svs.timestart );
Con_DPrintf( "level loaded at %.2f sec\n", Platform_DoubleTime() - svs.timestart );
if( sv.ignored_static_ents )
Con_Printf( S_WARN "%i static entities was rejected due buffer overflow\n", sv.ignored_static_ents );
@@ -1027,7 +1027,7 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot, qboolean ba
Log_Printf( "Loading map \"%s\"\n", mapname );
Log_PrintServerVars();
svs.timestart = Sys_DoubleTime();
svs.timestart = Platform_DoubleTime();
svs.spawncount++; // any partially connected client will be restarted
for( i = 0; i < ARRAYSIZE( svs.challenge_salt ); i++ )

View File

@@ -74,11 +74,11 @@ static void SV_CheckAllEnts( void )
if( !sv_check_errors.value || sv.state != ss_active )
return;
if(( nextcheck - Sys_DoubleTime()) > 0.0 )
if(( nextcheck - Platform_DoubleTime()) > 0.0 )
return;
// don't check entities every frame (but every 5 secs)
nextcheck = Sys_DoubleTime() + 5.0;
nextcheck = Platform_DoubleTime() + 5.0;
// check edicts errors
for( i = svs.maxclients + 1; i < svgame.numEntities; i++ )