mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-02 22:11:22 +00:00
renamed Sys_FloatTime to Sys_DoubleTime (the thing always returned double
you know..) and adjusted all callers accordingly. changed Sys_Sleep() to take a milliseconds argument, added implementations for unix (usleep) and windows (Sleep). git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@512 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
7ee8c348c0
commit
2b919188d6
13 changed files with 40 additions and 40 deletions
|
@ -234,7 +234,7 @@ void CL_KeepaliveMessage (void)
|
||||||
memcpy (net_message.data, olddata, net_message.cursize);
|
memcpy (net_message.data, olddata, net_message.cursize);
|
||||||
|
|
||||||
// check time
|
// check time
|
||||||
time = Sys_FloatTime ();
|
time = Sys_DoubleTime ();
|
||||||
if (time - lastmsg < 5)
|
if (time - lastmsg < 5)
|
||||||
return;
|
return;
|
||||||
lastmsg = time;
|
lastmsg = time;
|
||||||
|
|
|
@ -1235,10 +1235,10 @@ void Con_NotifyBox (const char *text)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
t1 = Sys_FloatTime ();
|
t1 = Sys_DoubleTime ();
|
||||||
SCR_UpdateScreen ();
|
SCR_UpdateScreen ();
|
||||||
Sys_SendKeyEvents ();
|
Sys_SendKeyEvents ();
|
||||||
t2 = Sys_FloatTime ();
|
t2 = Sys_DoubleTime ();
|
||||||
realtime += t2-t1; // make the cursor blink
|
realtime += t2-t1; // make the cursor blink
|
||||||
} while (key_count < 0);
|
} while (key_count < 0);
|
||||||
|
|
||||||
|
|
|
@ -790,7 +790,7 @@ void R_RenderView (void)
|
||||||
if (r_speeds.value)
|
if (r_speeds.value)
|
||||||
{
|
{
|
||||||
glFinish ();
|
glFinish ();
|
||||||
time1 = Sys_FloatTime ();
|
time1 = Sys_DoubleTime ();
|
||||||
|
|
||||||
//johnfitz -- rendering statistics
|
//johnfitz -- rendering statistics
|
||||||
rs_brushpolys = rs_aliaspolys = rs_skypolys = rs_particles = rs_fogpolys = rs_megatexels =
|
rs_brushpolys = rs_aliaspolys = rs_skypolys = rs_particles = rs_fogpolys = rs_megatexels =
|
||||||
|
@ -838,7 +838,7 @@ void R_RenderView (void)
|
||||||
//johnfitz
|
//johnfitz
|
||||||
|
|
||||||
//johnfitz -- modified r_speeds output
|
//johnfitz -- modified r_speeds output
|
||||||
time2 = Sys_FloatTime ();
|
time2 = Sys_DoubleTime ();
|
||||||
if (r_speeds.value == 2)
|
if (r_speeds.value == 2)
|
||||||
Con_Printf ("%3i ms %4i/%4i wpoly %4i/%4i epoly %3i lmap %4i/%4i sky %1.1f mtex\n",
|
Con_Printf ("%3i ms %4i/%4i wpoly %4i/%4i epoly %3i lmap %4i/%4i sky %1.1f mtex\n",
|
||||||
(int)((time2-time1)*1000),
|
(int)((time2-time1)*1000),
|
||||||
|
|
|
@ -386,7 +386,7 @@ void R_TimeRefresh_f (void)
|
||||||
glDrawBuffer (GL_FRONT);
|
glDrawBuffer (GL_FRONT);
|
||||||
glFinish ();
|
glFinish ();
|
||||||
|
|
||||||
start = Sys_FloatTime ();
|
start = Sys_DoubleTime ();
|
||||||
for (i=0 ; i<128 ; i++)
|
for (i=0 ; i<128 ; i++)
|
||||||
{
|
{
|
||||||
r_refdef.viewangles[1] = i/128.0*360.0;
|
r_refdef.viewangles[1] = i/128.0*360.0;
|
||||||
|
@ -394,7 +394,7 @@ void R_TimeRefresh_f (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
glFinish ();
|
glFinish ();
|
||||||
stop = Sys_FloatTime ();
|
stop = Sys_DoubleTime ();
|
||||||
time = stop-start;
|
time = stop-start;
|
||||||
Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
|
Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
|
||||||
|
|
||||||
|
|
|
@ -870,14 +870,14 @@ int SCR_ModalMessage (const char *text, float timeout) //johnfitz -- timeout
|
||||||
|
|
||||||
S_ClearBuffer (); // so dma doesn't loop current sound
|
S_ClearBuffer (); // so dma doesn't loop current sound
|
||||||
|
|
||||||
time1 = Sys_FloatTime () + timeout; //johnfitz -- timeout
|
time1 = Sys_DoubleTime () + timeout; //johnfitz -- timeout
|
||||||
time2 = 0.0f; //johnfitz -- timeout
|
time2 = 0.0f; //johnfitz -- timeout
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
key_count = -1; // wait for a key down and up
|
key_count = -1; // wait for a key down and up
|
||||||
Sys_SendKeyEvents ();
|
Sys_SendKeyEvents ();
|
||||||
if (timeout) time2 = Sys_FloatTime (); //johnfitz -- zero timeout means wait forever.
|
if (timeout) time2 = Sys_DoubleTime (); //johnfitz -- zero timeout means wait forever.
|
||||||
} while (key_lastpress != 'y' &&
|
} while (key_lastpress != 'y' &&
|
||||||
key_lastpress != 'n' &&
|
key_lastpress != 'n' &&
|
||||||
key_lastpress != K_ESCAPE &&
|
key_lastpress != K_ESCAPE &&
|
||||||
|
|
14
Quake/host.c
14
Quake/host.c
|
@ -482,7 +482,7 @@ void Host_ShutdownServer(qboolean crash)
|
||||||
CL_Disconnect ();
|
CL_Disconnect ();
|
||||||
|
|
||||||
// flush any pending messages - like the score!!!
|
// flush any pending messages - like the score!!!
|
||||||
start = Sys_FloatTime();
|
start = Sys_DoubleTime();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@ -502,7 +502,7 @@ void Host_ShutdownServer(qboolean crash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Sys_FloatTime() - start) > 3.0)
|
if ((Sys_DoubleTime() - start) > 3.0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
while (count);
|
while (count);
|
||||||
|
@ -728,14 +728,14 @@ void _Host_Frame (float time)
|
||||||
|
|
||||||
// update video
|
// update video
|
||||||
if (host_speeds.value)
|
if (host_speeds.value)
|
||||||
time1 = Sys_FloatTime ();
|
time1 = Sys_DoubleTime ();
|
||||||
|
|
||||||
SCR_UpdateScreen ();
|
SCR_UpdateScreen ();
|
||||||
|
|
||||||
CL_RunParticles (); //johnfitz -- seperated from rendering
|
CL_RunParticles (); //johnfitz -- seperated from rendering
|
||||||
|
|
||||||
if (host_speeds.value)
|
if (host_speeds.value)
|
||||||
time2 = Sys_FloatTime ();
|
time2 = Sys_DoubleTime ();
|
||||||
|
|
||||||
// update audio
|
// update audio
|
||||||
BGM_Update(); // adds music raw samples and/or advances midi driver
|
BGM_Update(); // adds music raw samples and/or advances midi driver
|
||||||
|
@ -752,7 +752,7 @@ void _Host_Frame (float time)
|
||||||
if (host_speeds.value)
|
if (host_speeds.value)
|
||||||
{
|
{
|
||||||
pass1 = (time1 - time3)*1000;
|
pass1 = (time1 - time3)*1000;
|
||||||
time3 = Sys_FloatTime ();
|
time3 = Sys_DoubleTime ();
|
||||||
pass2 = (time2 - time1)*1000;
|
pass2 = (time2 - time1)*1000;
|
||||||
pass3 = (time3 - time2)*1000;
|
pass3 = (time3 - time2)*1000;
|
||||||
Con_Printf ("%3i tot %3i server %3i gfx %3i snd\n",
|
Con_Printf ("%3i tot %3i server %3i gfx %3i snd\n",
|
||||||
|
@ -776,9 +776,9 @@ void Host_Frame (float time)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
time1 = Sys_FloatTime ();
|
time1 = Sys_DoubleTime ();
|
||||||
_Host_Frame (time);
|
_Host_Frame (time);
|
||||||
time2 = Sys_FloatTime ();
|
time2 = Sys_DoubleTime ();
|
||||||
|
|
||||||
timetotal += time2 - time1;
|
timetotal += time2 - time1;
|
||||||
timecount++;
|
timecount++;
|
||||||
|
|
|
@ -1626,7 +1626,7 @@ void Host_Spawn_f (void)
|
||||||
pr_global_struct->self = EDICT_TO_PROG(sv_player);
|
pr_global_struct->self = EDICT_TO_PROG(sv_player);
|
||||||
PR_ExecuteProgram (pr_global_struct->ClientConnect);
|
PR_ExecuteProgram (pr_global_struct->ClientConnect);
|
||||||
|
|
||||||
if ((Sys_FloatTime() - host_client->netconnection->connecttime) <= sv.time)
|
if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
|
||||||
Sys_Printf ("%s entered the game\n", host_client->name);
|
Sys_Printf ("%s entered the game\n", host_client->name);
|
||||||
|
|
||||||
PR_ExecuteProgram (pr_global_struct->PutClientInServer);
|
PR_ExecuteProgram (pr_global_struct->PutClientInServer);
|
||||||
|
|
|
@ -73,18 +73,18 @@ int main(int argc, char *argv[])
|
||||||
Sys_Printf("Host_Init\n");
|
Sys_Printf("Host_Init\n");
|
||||||
Host_Init();
|
Host_Init();
|
||||||
|
|
||||||
oldtime = Sys_FloatTime();
|
oldtime = Sys_DoubleTime();
|
||||||
if (isDedicated)
|
if (isDedicated)
|
||||||
{
|
{
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
newtime = Sys_FloatTime ();
|
newtime = Sys_DoubleTime ();
|
||||||
time = newtime - oldtime;
|
time = newtime - oldtime;
|
||||||
|
|
||||||
while (time < sys_ticrate.value )
|
while (time < sys_ticrate.value )
|
||||||
{
|
{
|
||||||
SDL_Delay(1);
|
SDL_Delay(1);
|
||||||
newtime = Sys_FloatTime ();
|
newtime = Sys_DoubleTime ();
|
||||||
time = newtime - oldtime;
|
time = newtime - oldtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newtime = Sys_FloatTime();
|
newtime = Sys_DoubleTime();
|
||||||
time = newtime - oldtime;
|
time = newtime - oldtime;
|
||||||
Host_Frame(time);
|
Host_Frame(time);
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ double net_time;
|
||||||
|
|
||||||
double SetNetTime (void)
|
double SetNetTime (void)
|
||||||
{
|
{
|
||||||
net_time = Sys_FloatTime();
|
net_time = Sys_DoubleTime();
|
||||||
return net_time;
|
return net_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ void NET_Slist_f (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
slistInProgress = true;
|
slistInProgress = true;
|
||||||
slistStartTime = Sys_FloatTime();
|
slistStartTime = Sys_DoubleTime();
|
||||||
|
|
||||||
SchedulePollProcedure(&slistSendProcedure, 0.0);
|
SchedulePollProcedure(&slistSendProcedure, 0.0);
|
||||||
SchedulePollProcedure(&slistPollProcedure, 0.1);
|
SchedulePollProcedure(&slistPollProcedure, 0.1);
|
||||||
|
@ -311,7 +311,7 @@ static void Slist_Send (void *unused)
|
||||||
dfunc.SearchForHosts (true);
|
dfunc.SearchForHosts (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Sys_FloatTime() - slistStartTime) < 0.5)
|
if ((Sys_DoubleTime() - slistStartTime) < 0.5)
|
||||||
SchedulePollProcedure(&slistSendProcedure, 0.75);
|
SchedulePollProcedure(&slistSendProcedure, 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ static void Slist_Poll (void *unused)
|
||||||
if (! slistSilent)
|
if (! slistSilent)
|
||||||
PrintSlist();
|
PrintSlist();
|
||||||
|
|
||||||
if ((Sys_FloatTime() - slistStartTime) < 1.5)
|
if ((Sys_DoubleTime() - slistStartTime) < 1.5)
|
||||||
{
|
{
|
||||||
SchedulePollProcedure(&slistPollProcedure, 0.1);
|
SchedulePollProcedure(&slistPollProcedure, 0.1);
|
||||||
return;
|
return;
|
||||||
|
@ -648,7 +648,7 @@ int NET_SendToAll (sizebuf_t *data, double blocktime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
start = Sys_FloatTime();
|
start = Sys_DoubleTime();
|
||||||
while (count)
|
while (count)
|
||||||
{
|
{
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@ -683,7 +683,7 @@ int NET_SendToAll (sizebuf_t *data, double blocktime)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Sys_FloatTime() - start) > blocktime)
|
if ((Sys_DoubleTime() - start) > blocktime)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
|
@ -826,7 +826,7 @@ void SchedulePollProcedure(PollProcedure *proc, double timeOffset)
|
||||||
{
|
{
|
||||||
PollProcedure *pp, *prev;
|
PollProcedure *pp, *prev;
|
||||||
|
|
||||||
proc->nextTime = Sys_FloatTime() + timeOffset;
|
proc->nextTime = Sys_DoubleTime() + timeOffset;
|
||||||
for (pp = pollProcedureList, prev = NULL; pp; pp = pp->next)
|
for (pp = pollProcedureList, prev = NULL; pp; pp = pp->next)
|
||||||
{
|
{
|
||||||
if (pp->nextTime >= proc->nextTime)
|
if (pp->nextTime >= proc->nextTime)
|
||||||
|
|
|
@ -50,7 +50,7 @@ static INT_PTR PASCAL FAR BlockingHook (void)
|
||||||
MSG msg;
|
MSG msg;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
if ((Sys_FloatTime() - blocktime) > 2.0)
|
if ((Sys_DoubleTime() - blocktime) > 2.0)
|
||||||
{
|
{
|
||||||
WSACancelBlockingCall();
|
WSACancelBlockingCall();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -90,7 +90,7 @@ static void WINS_GetLocalAddress (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
buff[MAXHOSTNAMELEN - 1] = 0;
|
buff[MAXHOSTNAMELEN - 1] = 0;
|
||||||
blocktime = Sys_FloatTime();
|
blocktime = Sys_DoubleTime();
|
||||||
WSASetBlockingHook(BlockingHook);
|
WSASetBlockingHook(BlockingHook);
|
||||||
local = gethostbyname(buff);
|
local = gethostbyname(buff);
|
||||||
err = WSAGetLastError();
|
err = WSAGetLastError();
|
||||||
|
|
10
Quake/sys.h
10
Quake/sys.h
|
@ -29,8 +29,7 @@ void Sys_Init (void);
|
||||||
// file IO
|
// file IO
|
||||||
//
|
//
|
||||||
|
|
||||||
// returns the file size
|
// returns the file size or -1 if file is not present.
|
||||||
// return -1 if file is not present
|
|
||||||
// the file should be in BINARY mode for stupid OSs that care
|
// the file should be in BINARY mode for stupid OSs that care
|
||||||
int Sys_FileOpenRead (const char *path, int *hndl);
|
int Sys_FileOpenRead (const char *path, int *hndl);
|
||||||
|
|
||||||
|
@ -53,13 +52,12 @@ void Sys_Printf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2)
|
||||||
|
|
||||||
void Sys_Quit (void) __attribute__((__noreturn__));
|
void Sys_Quit (void) __attribute__((__noreturn__));
|
||||||
|
|
||||||
double Sys_FloatTime (void);
|
double Sys_DoubleTime (void);
|
||||||
|
|
||||||
const char *Sys_ConsoleInput (void);
|
const char *Sys_ConsoleInput (void);
|
||||||
|
|
||||||
void Sys_Sleep (void);
|
void Sys_Sleep (unsigned long msecs);
|
||||||
// called to yield for a little bit so as
|
// yield for about 'msecs' milliseconds.
|
||||||
// not to hog cpu when paused or debugging
|
|
||||||
|
|
||||||
void Sys_SendKeyEvents (void);
|
void Sys_SendKeyEvents (void);
|
||||||
// Perform Key_Event () callbacks until the input que is empty
|
// Perform Key_Event () callbacks until the input que is empty
|
||||||
|
|
|
@ -197,7 +197,7 @@ void Sys_Quit (void)
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Sys_FloatTime (void)
|
double Sys_DoubleTime (void)
|
||||||
{
|
{
|
||||||
return SDL_GetTicks() / 1000.0;
|
return SDL_GetTicks() / 1000.0;
|
||||||
}
|
}
|
||||||
|
@ -253,8 +253,9 @@ const char *Sys_ConsoleInput (void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_Sleep (void)
|
void Sys_Sleep (unsigned long msecs)
|
||||||
{
|
{
|
||||||
|
usleep (msecs * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_SendKeyEvents (void)
|
void Sys_SendKeyEvents (void)
|
||||||
|
|
|
@ -272,7 +272,7 @@ void Sys_Quit (void)
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Sys_FloatTime (void)
|
double Sys_DoubleTime (void)
|
||||||
{
|
{
|
||||||
return SDL_GetTicks() / 1000.0;
|
return SDL_GetTicks() / 1000.0;
|
||||||
}
|
}
|
||||||
|
@ -346,8 +346,9 @@ const char *Sys_ConsoleInput (void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_Sleep (void)
|
void Sys_Sleep (unsigned long msecs)
|
||||||
{
|
{
|
||||||
|
Sleep (msecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_SendKeyEvents (void)
|
void Sys_SendKeyEvents (void)
|
||||||
|
|
Loading…
Reference in a new issue