diff --git a/Quake/cl_parse.c b/Quake/cl_parse.c index 233675e3..c769973a 100644 --- a/Quake/cl_parse.c +++ b/Quake/cl_parse.c @@ -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; diff --git a/Quake/console.c b/Quake/console.c index 6245f243..5b5d846f 100644 --- a/Quake/console.c +++ b/Quake/console.c @@ -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); diff --git a/Quake/gl_rmain.c b/Quake/gl_rmain.c index bb4baf98..6dfc2627 100644 --- a/Quake/gl_rmain.c +++ b/Quake/gl_rmain.c @@ -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), diff --git a/Quake/gl_rmisc.c b/Quake/gl_rmisc.c index 521656fe..0b9cf8ad 100644 --- a/Quake/gl_rmisc.c +++ b/Quake/gl_rmisc.c @@ -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); diff --git a/Quake/gl_screen.c b/Quake/gl_screen.c index d1f73649..2748ca36 100644 --- a/Quake/gl_screen.c +++ b/Quake/gl_screen.c @@ -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 && diff --git a/Quake/host.c b/Quake/host.c index 8762d8b8..7fff5435 100644 --- a/Quake/host.c +++ b/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++; diff --git a/Quake/host_cmd.c b/Quake/host_cmd.c index 76963080..2943f433 100644 --- a/Quake/host_cmd.c +++ b/Quake/host_cmd.c @@ -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); diff --git a/Quake/main_sdl.c b/Quake/main_sdl.c index deace66f..647b286d 100644 --- a/Quake/main_sdl.c +++ b/Quake/main_sdl.c @@ -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); diff --git a/Quake/net_main.c b/Quake/net_main.c index f2d7e98a..e636134c 100644 --- a/Quake/net_main.c +++ b/Quake/net_main.c @@ -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) diff --git a/Quake/net_wins.c b/Quake/net_wins.c index b3e17676..53aa67d6 100644 --- a/Quake/net_wins.c +++ b/Quake/net_wins.c @@ -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(); diff --git a/Quake/sys.h b/Quake/sys.h index 5d4594cd..9ee8f0ba 100644 --- a/Quake/sys.h +++ b/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 diff --git a/Quake/sys_sdl_unix.c b/Quake/sys_sdl_unix.c index 141e6ee3..502c87ee 100644 --- a/Quake/sys_sdl_unix.c +++ b/Quake/sys_sdl_unix.c @@ -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) diff --git a/Quake/sys_sdl_win.c b/Quake/sys_sdl_win.c index 36765eb8..1c891db7 100644 --- a/Quake/sys_sdl_win.c +++ b/Quake/sys_sdl_win.c @@ -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)