mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-02-23 11:50:55 +00:00
Done a pathetic attempt at cleaning some code up. :P
This commit is contained in:
parent
afd8217d2d
commit
7630423d40
1 changed files with 1 additions and 121 deletions
|
@ -185,7 +185,6 @@ void Sys_Init (void)
|
||||||
// unsigned int lowpart, highpart;
|
// unsigned int lowpart, highpart;
|
||||||
OSVERSIONINFO vinfo;
|
OSVERSIONINFO vinfo;
|
||||||
|
|
||||||
#ifndef SERVERONLY
|
|
||||||
// allocate a named semaphore on the client so the
|
// allocate a named semaphore on the client so the
|
||||||
// front end can tell if it is alive
|
// front end can tell if it is alive
|
||||||
|
|
||||||
|
@ -203,33 +202,10 @@ void Sys_Init (void)
|
||||||
0, /* Initial count */
|
0, /* Initial count */
|
||||||
1, /* Maximum count */
|
1, /* Maximum count */
|
||||||
"qwcl"); /* Semaphore name */
|
"qwcl"); /* Semaphore name */
|
||||||
#endif
|
|
||||||
|
|
||||||
MaskExceptions ();
|
MaskExceptions ();
|
||||||
Sys_SetFPCW ();
|
Sys_SetFPCW ();
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (!QueryPerformanceFrequency (&PerformanceFreq))
|
|
||||||
Sys_Error ("No hardware timer available");
|
|
||||||
|
|
||||||
// get 32 out of the 64 time bits such that we have around
|
|
||||||
// 1 microsecond resolution
|
|
||||||
lowpart = (unsigned int)PerformanceFreq.LowPart;
|
|
||||||
highpart = (unsigned int)PerformanceFreq.HighPart;
|
|
||||||
lowshift = 0;
|
|
||||||
|
|
||||||
while (highpart || (lowpart > 2000000.0))
|
|
||||||
{
|
|
||||||
lowshift++;
|
|
||||||
lowpart >>= 1;
|
|
||||||
lowpart |= (highpart & 1) << 31;
|
|
||||||
highpart >>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pfreq = 1.0 / (double)lowpart;
|
|
||||||
|
|
||||||
Sys_InitFloatTime ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// make sure the timer is high precision, otherwise
|
// make sure the timer is high precision, otherwise
|
||||||
// NT gets 18ms resolution
|
// NT gets 18ms resolution
|
||||||
|
@ -267,9 +243,7 @@ void Sys_Error (char *error, ...)
|
||||||
|
|
||||||
MessageBox(NULL, text, "Error", 0 /* MB_OK */ );
|
MessageBox(NULL, text, "Error", 0 /* MB_OK */ );
|
||||||
|
|
||||||
#ifndef SERVERONLY
|
|
||||||
CloseHandle (qwclsemaphore);
|
CloseHandle (qwclsemaphore);
|
||||||
#endif
|
|
||||||
|
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
@ -290,111 +264,17 @@ void Sys_Quit (void)
|
||||||
VID_ForceUnlockedAndReturnState ();
|
VID_ForceUnlockedAndReturnState ();
|
||||||
|
|
||||||
Host_Shutdown();
|
Host_Shutdown();
|
||||||
#ifndef SERVERONLY
|
|
||||||
if (tevent)
|
if (tevent)
|
||||||
CloseHandle (tevent);
|
CloseHandle (tevent);
|
||||||
|
|
||||||
if (qwclsemaphore)
|
if (qwclsemaphore)
|
||||||
CloseHandle (qwclsemaphore);
|
CloseHandle (qwclsemaphore);
|
||||||
#endif
|
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
================
|
|
||||||
Sys_DoubleTime
|
|
||||||
================
|
|
||||||
*/
|
|
||||||
double Sys_DoubleTime (void)
|
|
||||||
{
|
|
||||||
static int sametimecount;
|
|
||||||
static unsigned int oldtime;
|
|
||||||
static int first = 1;
|
|
||||||
LARGE_INTEGER PerformanceCount;
|
|
||||||
unsigned int temp, t2;
|
|
||||||
double time;
|
|
||||||
|
|
||||||
Sys_PushFPCW_SetHigh ();
|
|
||||||
|
|
||||||
QueryPerformanceCounter (&PerformanceCount);
|
|
||||||
|
|
||||||
temp = ((unsigned int)PerformanceCount.LowPart >> lowshift) |
|
|
||||||
((unsigned int)PerformanceCount.HighPart << (32 - lowshift));
|
|
||||||
|
|
||||||
if (first)
|
|
||||||
{
|
|
||||||
oldtime = temp;
|
|
||||||
first = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// check for turnover or backward time
|
|
||||||
if ((temp <= oldtime) && ((oldtime - temp) < 0x10000000))
|
|
||||||
{
|
|
||||||
oldtime = temp; // so we can't get stuck
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
t2 = temp - oldtime;
|
|
||||||
|
|
||||||
time = (double)t2 * pfreq;
|
|
||||||
oldtime = temp;
|
|
||||||
|
|
||||||
curtime += time;
|
|
||||||
|
|
||||||
if (curtime == lastcurtime)
|
|
||||||
{
|
|
||||||
sametimecount++;
|
|
||||||
|
|
||||||
if (sametimecount > 100000)
|
|
||||||
{
|
|
||||||
curtime += 1.0;
|
|
||||||
sametimecount = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sametimecount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastcurtime = curtime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Sys_PopFPCW ();
|
|
||||||
|
|
||||||
return curtime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
================
|
|
||||||
Sys_InitFloatTime
|
|
||||||
================
|
|
||||||
*/
|
|
||||||
void Sys_InitFloatTime (void)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
Sys_DoubleTime ();
|
|
||||||
|
|
||||||
j = COM_CheckParm("-starttime");
|
|
||||||
|
|
||||||
if (j)
|
|
||||||
{
|
|
||||||
curtime = (double) (Q_atof(com_argv[j+1]));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
curtime = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastcurtime = curtime;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
double Sys_DoubleTime (void)
|
double Sys_DoubleTime (void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue