compile fixes for win32 and take the pruning shears to *sys*.c in qw and nq

(they're not done yet, though)
This commit is contained in:
Bill Currie 2001-08-29 17:45:53 +00:00
parent 5aceb0435e
commit 3656d6fd59
17 changed files with 53 additions and 293 deletions

View File

@ -34,6 +34,9 @@
#include "QF/gcc_attr.h"
extern struct cvar_s *sys_nostdout;
extern struct cvar_s *sys_extrasleep;
extern struct cvar_s *sys_dead_sleep;
extern struct cvar_s *sys_sleep;
extern const char sys_char_map[256];

View File

@ -51,6 +51,8 @@
#include "QF/va.h"
#include "QF/zone.h"
#include "compat.h"
#define RETURN_EDICT(p, e) ((p)->pr_globals[OFS_RETURN].integer_var = EDICT_TO_PROG(p, e))
#define RETURN_STRING(p, s) ((p)->pr_globals[OFS_RETURN].integer_var = PR_SetString((p), s))

View File

@ -65,6 +65,10 @@
static void Sys_StdPrintf (const char *fmt, va_list args);
cvar_t *sys_nostdout;
cvar_t *sys_extrasleep;
cvar_t *sys_dead_sleep;
cvar_t *sys_sleep;
static sys_printf_t sys_printf_function = Sys_StdPrintf;
/* The translation table between the graphical font and plain ASCII --KB */
@ -255,3 +259,23 @@ Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
# endif
#endif
}
void
Sys_Init_Cvars (void)
{
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL,
"Set to disable std out");
sys_extrasleep = Cvar_Get ("sys_extrasleep", "0", CVAR_NONE, NULL,
"Set to cause whatever amount delay in "
"microseconds you want. Mostly "
"useful to generate simulated bad "
"connections.");
sys_dead_sleep = Cvar_Get ("sys_dead_sleep", "1", CVAR_NONE, NULL,
"When set, the server gets NO cpu if no "
"clients are connected and there's no other "
"activity. *MIGHT* cause problems with some "
"mods.");
sys_sleep = Cvar_Get ("sys_sleep", "8", CVAR_NONE, NULL, "Sleep how long "
"in seconds between checking for connections. "
"Minimum is 0, maximum is 13");
}

View File

@ -32,6 +32,7 @@
# include "config.h"
#endif
#include "winquake.h" // must come first due to nasties in windows headers
#include <dinput.h>
#include "QF/cmd.h"
@ -42,7 +43,6 @@
#include "QF/sys.h"
#include "compat.h"
#include "winquake.h"
#define DINPUT_BUFFERSIZE 16
#define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)

View File

@ -213,7 +213,7 @@ JOY_Open (void)
{
return JOY_StartupJoystick();
// Cmd_AddCommand ("joyadvancedupdate", JOY_AdvancedUpdate_f, "FIXME: This "
"appears to update the joystick poll? No Description");
// "appears to update the joystick poll? No Description");
}
void

View File

@ -191,11 +191,6 @@ Sys_ConsoleInput (void)
return NULL;
}
void
Sys_Sleep (void)
{
}
void
IN_SendKeyEvents (void)
{

View File

@ -62,7 +62,6 @@
#include <SDL.h>
#include <SDL_main.h>
#include "QF/cvar.h"
#include "QF/qargs.h"
#include "QF/qargs.h"
#include "QF/sys.h"
@ -72,9 +71,7 @@
#include "host.h"
qboolean isDedicated = false;
char *svs_info;
int starttime;
int noconinput;
#ifdef _WIN32
@ -84,22 +81,6 @@ qboolean Minimized = false;
void MaskExceptions (void);
#endif
/*
Sys_Init_Cvars
Quake calls this so the system can register variables before host_hunklevel
is marked
*/
void
Sys_Init_Cvars (void)
{
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL,
"Set to disable std out");
if (COM_CheckParm ("-nostdout"))
Cvar_Set (sys_nostdout, "1");
}
void
Sys_Init (void)
{
@ -198,11 +179,6 @@ Sys_LowFPPrecision (void)
}
#endif
void
Sys_Sleep (void)
{
}
#ifndef SDL_main
# define SDL_main main
#endif
@ -242,6 +218,9 @@ SDL_main (int c, char **v)
Host_Init (&host_parms);
Sys_Init_Cvars ();
Sys_Init ();
oldtime = Sys_DoubleTime ();
while (1) {
// find time spent rendering last frame

View File

@ -50,19 +50,14 @@
#include <sys/stat.h>
#include <sys/time.h>
#include "QF/sys.h"
#include "QF/qargs.h"
#include "QF/cvar.h"
#include "QF/qargs.h"
#include "QF/sys.h"
#include "host.h"
#include "server.h"
qboolean isDedicated;
cvar_t *sys_linerefresh;
cvar_t *timestamps;
cvar_t *timeformat;
qboolean isDedicated = false;
void
Sys_Init (void)
@ -196,13 +191,10 @@ main (int c, const char *v[])
Host_Init (&parms);
Sys_Init_Cvars ();
Sys_Init ();
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL,
"set to disable std out");
if (COM_CheckParm ("-nostdout"))
Cvar_Set (sys_nostdout, "1");
else {
if (!sys_nostdout->int_val) {
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
printf ("Quake -- Version %s\n", NQ_VERSION);
}

View File

@ -67,11 +67,6 @@ qboolean isDedicated;
int nostdout = 0;
cvar_t *sys_linerefresh;
cvar_t *timestamps;
cvar_t *timeformat;
int
Sys_FileOpenRead (char *path, int *handle)
{
@ -144,44 +139,6 @@ Sys_DebugLog (char *file, char *fmt, ...)
close (fd);
}
#define MAX_PRINT_MSG 4096
void
Sys_Printf (char *fmt, ...)
{
va_list argptr;
char start[MAX_PRINT_MSG]; // String we started with
char stamp[MAX_PRINT_MSG]; // Time stamp
char final[MAX_PRINT_MSG]; // String we print
time_t mytime = 0;
struct tm *local = NULL;
unsigned char *p;
va_start (argptr, fmt);
vsnprintf (start, sizeof (start), fmt, argptr);
va_end (argptr);
if (nostdout)
return;
if (timestamps && timeformat && timestamps && timeformat
&& timeformat->string && timestamps->int_val) {
mytime = time (NULL);
local = localtime (&mytime);
strftime (stamp, sizeof (stamp), timeformat->string, local);
snprintf (final, sizeof (final), "%s%s", stamp, start);
} else {
snprintf (final, sizeof (final), "%s", start);
}
for (p = (unsigned char *) final; *p; p++) {
putc (qfont_table[*p], stdout);
}
fflush (stdout);
}
void
Sys_Error (char *error, ...)
{
@ -218,23 +175,6 @@ Sys_Init (void)
#endif
}
double
Sys_DoubleTime (void)
{
struct timeval tp;
struct timezone tzp;
static int secbase;
gettimeofday (&tp, &tzp);
if (!secbase) {
secbase = tp.tv_sec;
return tp.tv_usec / 1000000.0;
}
return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0;
}
char *
Sys_ConsoleInput (void)
{
@ -314,6 +254,9 @@ main (int argc, char *argv[])
printf ("Host_Init\n");
Host_Init (&parms);
Sys_Init_Cvars ();
Sys_Init ();
oldtime = Sys_DoubleTime () - 0.1;
while (1) { // Main message loop

View File

@ -55,13 +55,10 @@
// minimization
#define NOT_FOCUS_SLEEP 20 // sleep time when not focus
int starttime;
qboolean ActiveApp, Minimized;
qboolean WinNT;
static double pfreq;
static double curtime = 0.0;
static double lastcurtime = 0.0;
static int lowshift;
qboolean isDedicated;
static qboolean sc_return_on_enter = false;
@ -75,7 +72,6 @@ static HANDLE heventParent;
static HANDLE heventChild;
void MaskExceptions (void);
void Sys_InitFloatTime (void);
void Sys_PushFPCW_SetHigh (void);
void Sys_PopFPCW (void);
@ -172,8 +168,6 @@ Sys_Init (void)
pfreq = 1.0 / (double) lowpart;
Sys_InitFloatTime ();
vinfo.dwOSVersionInfoSize = sizeof (vinfo);
if (!GetVersionEx (&vinfo))
@ -279,24 +273,6 @@ Sys_Quit (void)
exit (0);
}
void
Sys_InitFloatTime (void)
{
int j;
Sys_DoubleTime ();
j = COM_CheckParm ("-starttime");
if (j) {
curtime = (double) (atof (com_argv[j + 1]));
} else {
curtime = 0.0;
}
lastcurtime = curtime;
}
const char *
Sys_ConsoleInput (void)
{
@ -370,12 +346,6 @@ Sys_ConsoleInput (void)
return NULL;
}
void
Sys_Sleep (void)
{
Sleep (1);
}
// WINDOWS CRAP ===============================================================
void
@ -534,6 +504,9 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
Sys_Printf ("Host_Init\n");
Host_Init (&parms);
Sys_Init_Cvars ();
Sys_Init ();
oldtime = Sys_DoubleTime ();
/* main window message loop */
@ -543,7 +516,7 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
time = newtime - oldtime;
while (time < sys_ticrate->value) {
Sys_Sleep ();
Sleep (1);
newtime = Sys_DoubleTime ();
time = newtime - oldtime;
}

View File

@ -186,27 +186,6 @@ Sys_Quit (void)
exit (0);
}
double
Sys_DoubleTime (void)
{
double t;
struct _timeb tstruct;
static int starttime;
_ftime (&tstruct);
if (!starttime)
starttime = tstruct.time;
t = (tstruct.time - starttime) + tstruct.millitm * 0.001;
return t;
}
void
Sys_Sleep (void)
{
}
void
IN_SendKeyEvents (void)
{
@ -295,6 +274,9 @@ main (int argc, char **argv)
printf ("Host_Init\n");
Host_Init (&parms);
Sys_Init_Cvars ();
Sys_Init ();
oldtime = Sys_DoubleTime ();
/* main window message loop */

View File

@ -58,7 +58,7 @@
int cl_timeframes_isactive;
int cl_timeframes_index;
int demotime_cached;
struct timeval *cl_timeframes_array;
double *cl_timeframes_array;
#define CL_TIMEFRAMES_ARRAYBLOCK 4096
extern cvar_t *cl_timeframes;
@ -825,18 +825,15 @@ CL_TimeFrames_Reset (void)
void
CL_TimeFrames_AddTimestamp (void)
{
int retval;
if (cl_timeframes_isactive) {
if (!(cl_timeframes_index % CL_TIMEFRAMES_ARRAYBLOCK))
cl_timeframes_array = realloc
(cl_timeframes_array, sizeof(struct timeval) *
(cl_timeframes_array, sizeof(cl_timeframes_array[0]) *
((cl_timeframes_index / CL_TIMEFRAMES_ARRAYBLOCK) + 1) *
CL_TIMEFRAMES_ARRAYBLOCK);
if (cl_timeframes_array == NULL)
Sys_Error ("Unable to allocate timeframes buffer\n");
retval = gettimeofday(cl_timeframes_array + cl_timeframes_index, NULL);
if (retval)
Sys_Error ("CL_TimeFrames_Addtimestamp: gettimeofday() failed.\n");
cl_timeframes_array[cl_timeframes_index] = Sys_DoubleTime ();
cl_timeframes_index++;
}
return;
@ -861,15 +858,7 @@ void CL_TimeFrames_DumpLog (void)
return;
}
for (i = 1; i < cl_timeframes_index; i++) {
frame = (cl_timeframes_array[i].tv_sec -
cl_timeframes_array[i - 1].tv_sec);
if (frame < 999) {
frame *= 1000000;
frame += cl_timeframes_array[i].tv_usec -
cl_timeframes_array[i - 1].tv_usec;
} else
frame = 999999999;
frame = (cl_timeframes_array[i] - cl_timeframes_array[i - 1]) * 1e6;
Qprintf (outputfile, "%09ld\n", frame);
}
Qclose (outputfile);

View File

@ -61,7 +61,6 @@
#include <SDL.h>
#include <SDL_main.h>
#include "QF/cvar.h"
#include "QF/sys.h"
#include "QF/qargs.h"
@ -72,7 +71,6 @@
qboolean is_server = false;
char *svs_info;
int starttime;
int noconinput;
#ifdef _WIN32
@ -83,21 +81,6 @@ void MaskExceptions (void);
#endif
/*
Sys_Init_Cvars
Quake calls this so the system can register variables before host_hunklevel
is marked
*/
void
Sys_Init_Cvars (void)
{
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL,
"set to disable std out");
if (COM_CheckParm ("-nostdout"))
Cvar_Set (sys_nostdout, "1");
}
void
Sys_Init (void)
{
@ -198,11 +181,6 @@ Sys_LowFPPrecision (void)
}
#endif
void
Sys_Sleep (void)
{
}
#ifndef SDL_main
# define SDL_main main
#endif

View File

@ -51,7 +51,6 @@
#include <sys/mman.h>
#include <sys/types.h>
#include "QF/cvar.h"
#include "QF/qargs.h"
#include "QF/sys.h"
@ -62,22 +61,6 @@ int noconinput = 0;
qboolean is_server = false;
char *svs_info;
/*
Sys_Init_Cvars
Quake calls this so the system can register variables before host_hunklevel
is marked
*/
void
Sys_Init_Cvars (void)
{
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL,
"set to disable std out");
if (COM_CheckParm ("-nostdout"))
Cvar_Set (sys_nostdout, "1");
}
void
Sys_Init (void)
{

View File

@ -43,7 +43,6 @@
#include <windows.h>
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/qargs.h"
#include "QF/screen.h"
#include "QF/sound.h"
@ -65,8 +64,6 @@
char *svs_info;
int starttime;
qboolean ActiveApp, Minimized, WinNT;
qboolean is_server = false;
@ -81,21 +78,6 @@ void Sys_PopFPCW (void);
void Sys_PushFPCW_SetHigh (void);
void Sys_InitFloatTime (void);
extern cvar_t *sys_nostdout;
/*
Sys_Init_Cvars
Quake calls this so the system can register variables before host_hunklevel
is marked
*/
void
Sys_Init_Cvars (void)
{
sys_nostdout = Cvar_Get ("sys_nostdout", "1", CVAR_NONE, NULL, "unset to "
"enable std out - windows does NOT support this");
}
void
Sys_Init (void)
@ -195,19 +177,6 @@ Sys_DebugLog (const char *file, const char *fmt, ...)
close (fd);
};
int
wfilelength (VFile *f)
{
int end, pos;
pos = Qtell (f);
Qseek (f, 0, SEEK_END);
end = Qtell (f);
Qseek (f, pos, SEEK_SET);
return end;
}
/*
Sys_ConsoleInput
@ -319,15 +288,9 @@ Sys_ConsoleInput (void)
return NULL;
}
void
Sys_Sleep (void)
{
}
void
SleepUntilInput (int time)
{
MsgWaitForMultipleObjects (1, &tevent, FALSE, time, QS_ALLINPUT);
}

View File

@ -57,37 +57,11 @@
# include <libc.h>
#endif
cvar_t *sys_extrasleep;
cvar_t *sys_dead_sleep;
qboolean is_server = true;
qboolean stdin_ready;
server_static_t svs;
char *svs_info = svs.info;
/*
Sys_Init_Cvars
Quake calls this so the system can register variables before host_hunklevel
is marked
*/
void
Sys_Init_Cvars (void)
{
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL,
"Toggles console screen output");
sys_extrasleep = Cvar_Get ("sys_extrasleep", "0", CVAR_NONE, NULL,
"Set to cause whatever amount delay in microseconds you want. Mostly "
"useful to generate simulated bad "
"connections.");
sys_dead_sleep = Cvar_Get ("sys_dead_sleep", "1", CVAR_NONE, NULL,
"When set, the server gets NO cpu if no "
"clients are connected and there's no other "
"activity. *MIGHT* cause problems with some "
"mods.");
}
void
Sys_Init (void)
{
@ -99,7 +73,6 @@ Sys_Init (void)
void
Sys_Quit (void)
{
Net_LogStop();
exit (0);

View File

@ -47,25 +47,6 @@ qboolean WinNT;
server_static_t svs;
char *svs_info = svs.info;
extern cvar_t *sys_nostdout;
cvar_t *sys_sleep;
/*
Sys_Init_Cvars
Quake calls this so the system can register variables before host_hunklevel
is marked
*/
void
Sys_Init_Cvars (void)
{
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL,
"Toggle console output");
sys_sleep = Cvar_Get ("sys_sleep", "8", CVAR_NONE, NULL, "Sleep how long "
"in seconds between checking for connections. "
"Minimum is 0, maximum is 13");
}
void
Sys_Init (void)