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);
|
||||
|
||||
// check time
|
||||
time = Sys_FloatTime ();
|
||||
time = Sys_DoubleTime ();
|
||||
if (time - lastmsg < 5)
|
||||
return;
|
||||
lastmsg = time;
|
||||
|
|
|
@ -1235,10 +1235,10 @@ void Con_NotifyBox (const char *text)
|
|||
|
||||
do
|
||||
{
|
||||
t1 = Sys_FloatTime ();
|
||||
t1 = Sys_DoubleTime ();
|
||||
SCR_UpdateScreen ();
|
||||
Sys_SendKeyEvents ();
|
||||
t2 = Sys_FloatTime ();
|
||||
t2 = Sys_DoubleTime ();
|
||||
realtime += t2-t1; // make the cursor blink
|
||||
} while (key_count < 0);
|
||||
|
||||
|
|
|
@ -790,7 +790,7 @@ void R_RenderView (void)
|
|||
if (r_speeds.value)
|
||||
{
|
||||
glFinish ();
|
||||
time1 = Sys_FloatTime ();
|
||||
time1 = Sys_DoubleTime ();
|
||||
|
||||
//johnfitz -- rendering statistics
|
||||
rs_brushpolys = rs_aliaspolys = rs_skypolys = rs_particles = rs_fogpolys = rs_megatexels =
|
||||
|
@ -838,7 +838,7 @@ void R_RenderView (void)
|
|||
//johnfitz
|
||||
|
||||
//johnfitz -- modified r_speeds output
|
||||
time2 = Sys_FloatTime ();
|
||||
time2 = Sys_DoubleTime ();
|
||||
if (r_speeds.value == 2)
|
||||
Con_Printf ("%3i ms %4i/%4i wpoly %4i/%4i epoly %3i lmap %4i/%4i sky %1.1f mtex\n",
|
||||
(int)((time2-time1)*1000),
|
||||
|
|
|
@ -386,7 +386,7 @@ void R_TimeRefresh_f (void)
|
|||
glDrawBuffer (GL_FRONT);
|
||||
glFinish ();
|
||||
|
||||
start = Sys_FloatTime ();
|
||||
start = Sys_DoubleTime ();
|
||||
for (i=0 ; i<128 ; i++)
|
||||
{
|
||||
r_refdef.viewangles[1] = i/128.0*360.0;
|
||||
|
@ -394,7 +394,7 @@ void R_TimeRefresh_f (void)
|
|||
}
|
||||
|
||||
glFinish ();
|
||||
stop = Sys_FloatTime ();
|
||||
stop = Sys_DoubleTime ();
|
||||
time = stop-start;
|
||||
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
|
||||
|
||||
time1 = Sys_FloatTime () + timeout; //johnfitz -- timeout
|
||||
time1 = Sys_DoubleTime () + timeout; //johnfitz -- timeout
|
||||
time2 = 0.0f; //johnfitz -- timeout
|
||||
|
||||
do
|
||||
{
|
||||
key_count = -1; // wait for a key down and up
|
||||
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' &&
|
||||
key_lastpress != 'n' &&
|
||||
key_lastpress != K_ESCAPE &&
|
||||
|
|
14
Quake/host.c
14
Quake/host.c
|
@ -482,7 +482,7 @@ void Host_ShutdownServer(qboolean crash)
|
|||
CL_Disconnect ();
|
||||
|
||||
// flush any pending messages - like the score!!!
|
||||
start = Sys_FloatTime();
|
||||
start = Sys_DoubleTime();
|
||||
do
|
||||
{
|
||||
count = 0;
|
||||
|
@ -502,7 +502,7 @@ void Host_ShutdownServer(qboolean crash)
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((Sys_FloatTime() - start) > 3.0)
|
||||
if ((Sys_DoubleTime() - start) > 3.0)
|
||||
break;
|
||||
}
|
||||
while (count);
|
||||
|
@ -728,14 +728,14 @@ void _Host_Frame (float time)
|
|||
|
||||
// update video
|
||||
if (host_speeds.value)
|
||||
time1 = Sys_FloatTime ();
|
||||
time1 = Sys_DoubleTime ();
|
||||
|
||||
SCR_UpdateScreen ();
|
||||
|
||||
CL_RunParticles (); //johnfitz -- seperated from rendering
|
||||
|
||||
if (host_speeds.value)
|
||||
time2 = Sys_FloatTime ();
|
||||
time2 = Sys_DoubleTime ();
|
||||
|
||||
// update audio
|
||||
BGM_Update(); // adds music raw samples and/or advances midi driver
|
||||
|
@ -752,7 +752,7 @@ void _Host_Frame (float time)
|
|||
if (host_speeds.value)
|
||||
{
|
||||
pass1 = (time1 - time3)*1000;
|
||||
time3 = Sys_FloatTime ();
|
||||
time3 = Sys_DoubleTime ();
|
||||
pass2 = (time2 - time1)*1000;
|
||||
pass3 = (time3 - time2)*1000;
|
||||
Con_Printf ("%3i tot %3i server %3i gfx %3i snd\n",
|
||||
|
@ -776,9 +776,9 @@ void Host_Frame (float time)
|
|||
return;
|
||||
}
|
||||
|
||||
time1 = Sys_FloatTime ();
|
||||
time1 = Sys_DoubleTime ();
|
||||
_Host_Frame (time);
|
||||
time2 = Sys_FloatTime ();
|
||||
time2 = Sys_DoubleTime ();
|
||||
|
||||
timetotal += time2 - time1;
|
||||
timecount++;
|
||||
|
|
|
@ -1626,7 +1626,7 @@ void Host_Spawn_f (void)
|
|||
pr_global_struct->self = EDICT_TO_PROG(sv_player);
|
||||
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);
|
||||
|
||||
PR_ExecuteProgram (pr_global_struct->PutClientInServer);
|
||||
|
|
|
@ -73,18 +73,18 @@ int main(int argc, char *argv[])
|
|||
Sys_Printf("Host_Init\n");
|
||||
Host_Init();
|
||||
|
||||
oldtime = Sys_FloatTime();
|
||||
oldtime = Sys_DoubleTime();
|
||||
if (isDedicated)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
newtime = Sys_FloatTime ();
|
||||
newtime = Sys_DoubleTime ();
|
||||
time = newtime - oldtime;
|
||||
|
||||
while (time < sys_ticrate.value )
|
||||
{
|
||||
SDL_Delay(1);
|
||||
newtime = Sys_FloatTime ();
|
||||
newtime = Sys_DoubleTime ();
|
||||
time = newtime - oldtime;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
newtime = Sys_FloatTime();
|
||||
newtime = Sys_DoubleTime();
|
||||
time = newtime - oldtime;
|
||||
Host_Frame(time);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ double net_time;
|
|||
|
||||
double SetNetTime (void)
|
||||
{
|
||||
net_time = Sys_FloatTime();
|
||||
net_time = Sys_DoubleTime();
|
||||
return net_time;
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ void NET_Slist_f (void)
|
|||
}
|
||||
|
||||
slistInProgress = true;
|
||||
slistStartTime = Sys_FloatTime();
|
||||
slistStartTime = Sys_DoubleTime();
|
||||
|
||||
SchedulePollProcedure(&slistSendProcedure, 0.0);
|
||||
SchedulePollProcedure(&slistPollProcedure, 0.1);
|
||||
|
@ -311,7 +311,7 @@ static void Slist_Send (void *unused)
|
|||
dfunc.SearchForHosts (true);
|
||||
}
|
||||
|
||||
if ((Sys_FloatTime() - slistStartTime) < 0.5)
|
||||
if ((Sys_DoubleTime() - slistStartTime) < 0.5)
|
||||
SchedulePollProcedure(&slistSendProcedure, 0.75);
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ static void Slist_Poll (void *unused)
|
|||
if (! slistSilent)
|
||||
PrintSlist();
|
||||
|
||||
if ((Sys_FloatTime() - slistStartTime) < 1.5)
|
||||
if ((Sys_DoubleTime() - slistStartTime) < 1.5)
|
||||
{
|
||||
SchedulePollProcedure(&slistPollProcedure, 0.1);
|
||||
return;
|
||||
|
@ -648,7 +648,7 @@ int NET_SendToAll (sizebuf_t *data, double blocktime)
|
|||
}
|
||||
}
|
||||
|
||||
start = Sys_FloatTime();
|
||||
start = Sys_DoubleTime();
|
||||
while (count)
|
||||
{
|
||||
count = 0;
|
||||
|
@ -683,7 +683,7 @@ int NET_SendToAll (sizebuf_t *data, double blocktime)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if ((Sys_FloatTime() - start) > blocktime)
|
||||
if ((Sys_DoubleTime() - start) > blocktime)
|
||||
break;
|
||||
}
|
||||
return count;
|
||||
|
@ -826,7 +826,7 @@ void SchedulePollProcedure(PollProcedure *proc, double timeOffset)
|
|||
{
|
||||
PollProcedure *pp, *prev;
|
||||
|
||||
proc->nextTime = Sys_FloatTime() + timeOffset;
|
||||
proc->nextTime = Sys_DoubleTime() + timeOffset;
|
||||
for (pp = pollProcedureList, prev = NULL; pp; pp = pp->next)
|
||||
{
|
||||
if (pp->nextTime >= proc->nextTime)
|
||||
|
|
|
@ -50,7 +50,7 @@ static INT_PTR PASCAL FAR BlockingHook (void)
|
|||
MSG msg;
|
||||
BOOL ret;
|
||||
|
||||
if ((Sys_FloatTime() - blocktime) > 2.0)
|
||||
if ((Sys_DoubleTime() - blocktime) > 2.0)
|
||||
{
|
||||
WSACancelBlockingCall();
|
||||
return FALSE;
|
||||
|
@ -90,7 +90,7 @@ static void WINS_GetLocalAddress (void)
|
|||
}
|
||||
|
||||
buff[MAXHOSTNAMELEN - 1] = 0;
|
||||
blocktime = Sys_FloatTime();
|
||||
blocktime = Sys_DoubleTime();
|
||||
WSASetBlockingHook(BlockingHook);
|
||||
local = gethostbyname(buff);
|
||||
err = WSAGetLastError();
|
||||
|
|
10
Quake/sys.h
10
Quake/sys.h
|
@ -29,8 +29,7 @@ void Sys_Init (void);
|
|||
// file IO
|
||||
//
|
||||
|
||||
// returns the file size
|
||||
// return -1 if file is not present
|
||||
// returns the file size or -1 if file is not present.
|
||||
// the file should be in BINARY mode for stupid OSs that care
|
||||
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__));
|
||||
|
||||
double Sys_FloatTime (void);
|
||||
double Sys_DoubleTime (void);
|
||||
|
||||
const char *Sys_ConsoleInput (void);
|
||||
|
||||
void Sys_Sleep (void);
|
||||
// called to yield for a little bit so as
|
||||
// not to hog cpu when paused or debugging
|
||||
void Sys_Sleep (unsigned long msecs);
|
||||
// yield for about 'msecs' milliseconds.
|
||||
|
||||
void Sys_SendKeyEvents (void);
|
||||
// Perform Key_Event () callbacks until the input que is empty
|
||||
|
|
|
@ -197,7 +197,7 @@ void Sys_Quit (void)
|
|||
exit (0);
|
||||
}
|
||||
|
||||
double Sys_FloatTime (void)
|
||||
double Sys_DoubleTime (void)
|
||||
{
|
||||
return SDL_GetTicks() / 1000.0;
|
||||
}
|
||||
|
@ -253,8 +253,9 @@ const char *Sys_ConsoleInput (void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void Sys_Sleep (void)
|
||||
void Sys_Sleep (unsigned long msecs)
|
||||
{
|
||||
usleep (msecs * 1000);
|
||||
}
|
||||
|
||||
void Sys_SendKeyEvents (void)
|
||||
|
|
|
@ -272,7 +272,7 @@ void Sys_Quit (void)
|
|||
exit (0);
|
||||
}
|
||||
|
||||
double Sys_FloatTime (void)
|
||||
double Sys_DoubleTime (void)
|
||||
{
|
||||
return SDL_GetTicks() / 1000.0;
|
||||
}
|
||||
|
@ -346,8 +346,9 @@ const char *Sys_ConsoleInput (void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void Sys_Sleep (void)
|
||||
void Sys_Sleep (unsigned long msecs)
|
||||
{
|
||||
Sleep (msecs);
|
||||
}
|
||||
|
||||
void Sys_SendKeyEvents (void)
|
||||
|
|
Loading…
Reference in a new issue