engine: turn Platform_Sleep into an inline function that directly calls platform-specific delay functions
This commit is contained in:
parent
de1361d99d
commit
e14cd758ad
9 changed files with 30 additions and 35 deletions
|
@ -652,10 +652,10 @@ static qboolean Host_Autosleep( double dt, double scale )
|
|||
// if we have allocated time window, try to sleep
|
||||
if( timewindow > realsleeptime )
|
||||
{
|
||||
// Sys_Sleep isn't guaranteed to sleep an exact amount of milliseconds
|
||||
// Platform_Sleep isn't guaranteed to sleep an exact amount of milliseconds
|
||||
// so we measure the real sleep time and use it to decrease the window
|
||||
double t1 = Sys_DoubleTime(), t2;
|
||||
Sys_Sleep( sleep ); // in msec!
|
||||
Platform_Sleep( sleep ); // in msec!
|
||||
t2 = Sys_DoubleTime();
|
||||
realsleeptime = t2 - t1;
|
||||
|
||||
|
|
|
@ -1523,7 +1523,7 @@ static int NET_SendLong( netsrc_t sock, int net_socket, const char *buf, size_t
|
|||
total_sent += size;
|
||||
len -= size;
|
||||
packet_number++;
|
||||
Sys_Sleep( 1 );
|
||||
Platform_Sleep( 1 );
|
||||
}
|
||||
|
||||
return total_sent;
|
||||
|
|
|
@ -117,22 +117,6 @@ char *Sys_GetClipboardData( void )
|
|||
}
|
||||
#endif // XASH_DEDICATED
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_Sleep
|
||||
|
||||
freeze application for some time
|
||||
================
|
||||
*/
|
||||
void Sys_Sleep( int msec )
|
||||
{
|
||||
if( !msec )
|
||||
return;
|
||||
|
||||
msec = Q_min( msec, 1000 );
|
||||
Platform_Sleep( msec );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_GetCurrentUser
|
||||
|
@ -370,7 +354,7 @@ static void Sys_WaitForQuit( void )
|
|||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
else Sys_Sleep( 20 );
|
||||
else Platform_Sleep( 20 );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -420,7 +404,7 @@ void Sys_Error( const char *error, ... )
|
|||
return; // don't multiple executes
|
||||
|
||||
// make sure that console received last message
|
||||
if( host.change_game ) Sys_Sleep( 200 );
|
||||
if( host.change_game ) Platform_Sleep( 200 );
|
||||
|
||||
error_on_exit = 1;
|
||||
host.status = HOST_ERR_FATAL;
|
||||
|
|
|
@ -42,7 +42,6 @@ writes into struct by offsets not names
|
|||
========================================================================
|
||||
*/
|
||||
extern int error_on_exit;
|
||||
void Sys_Sleep( int msec );
|
||||
double Sys_DoubleTime( void );
|
||||
char *Sys_GetClipboardData( void );
|
||||
const char *Sys_GetCurrentUser( void );
|
||||
|
|
|
@ -40,12 +40,8 @@ double Platform_DoubleTime( void )
|
|||
{
|
||||
return 0.005*ticks;
|
||||
}
|
||||
|
||||
void Platform_Sleep( int msec )
|
||||
{
|
||||
//usleep( msec * 1000 );
|
||||
}
|
||||
#endif // XASH_TIMER == TIMER_DOS
|
||||
|
||||
#define PIT_FREQUENCY 0x1234DDL
|
||||
#define frequency 140
|
||||
#define counter PIT_FREQUENCY/frequency
|
||||
|
|
|
@ -31,7 +31,6 @@ GNU General Public License for more details.
|
|||
==============================================================================
|
||||
*/
|
||||
double Platform_DoubleTime( void );
|
||||
void Platform_Sleep( int msec );
|
||||
void Platform_ShellExecute( const char *path, const char *parms );
|
||||
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow );
|
||||
void Platform_SetStatus( const char *status );
|
||||
|
@ -52,11 +51,13 @@ void IOS_LaunchDialog( void );
|
|||
#if XASH_POSIX
|
||||
void Posix_Daemonize( void );
|
||||
void Posix_SetupSigtermHandling( void );
|
||||
void Posix_Sleep( int msec );
|
||||
#endif
|
||||
|
||||
#if XASH_SDL
|
||||
void SDLash_Init( void );
|
||||
void SDLash_Shutdown( void );
|
||||
void SDLash_Sleep( int msec );
|
||||
#endif
|
||||
|
||||
#if XASH_ANDROID
|
||||
|
@ -77,6 +78,7 @@ void Wcon_ShowConsole( qboolean show );
|
|||
void Wcon_DisableInput( void );
|
||||
char *Wcon_Input( void );
|
||||
void Wcon_WinPrint( const char *pMsg );
|
||||
void Win32_Sleep( int msec );
|
||||
#endif
|
||||
|
||||
#if XASH_NSWITCH
|
||||
|
@ -165,6 +167,19 @@ static inline void Platform_SetupSigtermHandling( void )
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline void Platform_Sleep( int msec )
|
||||
{
|
||||
#if XASH_TIMER == TIMER_SDL
|
||||
SDLash_Sleep( msec );
|
||||
#elif XASH_TIMER == TIMER_POSIX
|
||||
Posix_Sleep( msec );
|
||||
#elif XASH_TIMER == TIMER_WIN32
|
||||
Win32_Sleep( msec );
|
||||
#else
|
||||
// stub
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ static void Posix_SigtermCallback( int signal )
|
|||
|
||||
void Posix_SetupSigtermHandling( void )
|
||||
{
|
||||
#if !XASH_PSVITA
|
||||
#if !XASH_PSVITA
|
||||
struct sigaction act = { 0 };
|
||||
act.sa_handler = Posix_SigtermCallback;
|
||||
act.sa_flags = 0;
|
||||
|
@ -172,9 +172,10 @@ double Platform_DoubleTime( void )
|
|||
#endif
|
||||
return (double) ts.tv_sec + (double) ts.tv_nsec/1000000000.0;
|
||||
}
|
||||
#endif // XASH_TIMER == TIMER_POSIX
|
||||
|
||||
void Platform_Sleep( int msec )
|
||||
void Posix_Sleep( int msec )
|
||||
{
|
||||
usleep( msec * 1000 );
|
||||
}
|
||||
#endif // XASH_TIMER == TIMER_POSIX
|
||||
|
||||
|
|
|
@ -32,12 +32,12 @@ double Platform_DoubleTime( void )
|
|||
CurrentTime = SDL_GetPerformanceCounter();
|
||||
return (double)( CurrentTime - g_ClockStart ) / (double)( g_PerformanceFrequency );
|
||||
}
|
||||
#endif // XASH_TIMER == TIMER_SDL
|
||||
|
||||
void Platform_Sleep( int msec )
|
||||
void SDLash_Sleep( int msec )
|
||||
{
|
||||
SDL_Delay( msec );
|
||||
}
|
||||
#endif // XASH_TIMER == TIMER_SDL
|
||||
|
||||
#if XASH_MESSAGEBOX == MSGBOX_SDL
|
||||
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow )
|
||||
|
|
|
@ -34,12 +34,12 @@ double Platform_DoubleTime( void )
|
|||
|
||||
return (double)( CurrentTime.QuadPart - g_ClockStart.QuadPart ) / (double)( g_PerformanceFrequency.QuadPart );
|
||||
}
|
||||
#endif // XASH_TIMER == TIMER_WIN32
|
||||
|
||||
void Platform_Sleep( int msec )
|
||||
void Win32_Sleep( int msec )
|
||||
{
|
||||
Sleep( msec );
|
||||
}
|
||||
#endif // XASH_TIMER == TIMER_WIN32
|
||||
|
||||
qboolean Platform_DebuggerPresent( void )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue