mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 18:01:15 +00:00
Major diff reduction in *sys_*.c files. Don't think I broke anything,
but hard to test it all.. I skipped a couple files, because they contained *alot* of platform-specific functions.
This commit is contained in:
parent
1c9918fe48
commit
d5fa2cc321
7 changed files with 358 additions and 329 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
cl_sys_sdl.c
|
||||
sys_sdl.c
|
||||
|
||||
(description)
|
||||
|
||||
|
@ -26,15 +26,12 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
|
@ -84,26 +81,20 @@ void MaskExceptions (void);
|
|||
#endif
|
||||
|
||||
|
||||
void
|
||||
Sys_DebugLog (const char *file, const char *fmt, ...)
|
||||
{
|
||||
int fd;
|
||||
static char data[1024]; // why static ?
|
||||
va_list argptr;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsnprintf (data, sizeof (data), fmt, argptr);
|
||||
va_end (argptr);
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||
write (fd, data, strlen (data));
|
||||
close (fd);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
SYSTEM IO
|
||||
*/
|
||||
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)
|
||||
|
@ -136,7 +127,19 @@ Sys_Init (void)
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Quit
|
||||
*/
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
Host_Shutdown ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Error
|
||||
*/
|
||||
void
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
|
@ -159,37 +162,38 @@ Sys_Error (const char *error, ...)
|
|||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sys_Quit (void)
|
||||
Sys_DebugLog (const char *file, const char *fmt, ...)
|
||||
{
|
||||
Host_Shutdown ();
|
||||
exit (0);
|
||||
}
|
||||
int fd;
|
||||
static char data[1024]; // why static ?
|
||||
va_list argptr;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsnprintf (data, sizeof (data), fmt, argptr);
|
||||
va_end (argptr);
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||
write (fd, data, strlen (data));
|
||||
close (fd);
|
||||
};
|
||||
|
||||
/*
|
||||
Sys_ConsoleInput
|
||||
|
||||
Checks for a complete line of text typed in at the console, then forwards
|
||||
it to the host command processor
|
||||
*/
|
||||
const char *
|
||||
Sys_ConsoleInput (void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sys_Sleep (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
#ifndef SDL_main
|
||||
# define SDL_main main
|
||||
#endif
|
||||
|
|
|
@ -54,8 +54,6 @@
|
|||
#include "server.h"
|
||||
#include "host.h"
|
||||
|
||||
|
||||
|
||||
qboolean isDedicated;
|
||||
|
||||
char *basedir = ".";
|
||||
|
@ -65,28 +63,30 @@ cvar_t *sys_linerefresh;
|
|||
cvar_t *timestamps;
|
||||
cvar_t *timeformat;
|
||||
|
||||
|
||||
void
|
||||
Sys_DebugLog (const char *file, const char *fmt, ...)
|
||||
Sys_Init (void)
|
||||
{
|
||||
va_list argptr;
|
||||
static char data[1024];
|
||||
int fd;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsnprintf (data, sizeof (data), fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||
write (fd, data, strlen (data));
|
||||
close (fd);
|
||||
#ifdef USE_INTEL_ASM
|
||||
Sys_SetFPCW ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Quit
|
||||
*/
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
Host_Shutdown ();
|
||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
|
||||
fflush (stdout);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* System I/O
|
||||
*/
|
||||
|
||||
|
||||
Sys_Error
|
||||
*/
|
||||
void
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
|
@ -107,22 +107,20 @@ Sys_Error (const char *error, ...)
|
|||
}
|
||||
|
||||
void
|
||||
Sys_Quit (void)
|
||||
Sys_DebugLog (const char *file, const char *fmt, ...)
|
||||
{
|
||||
Host_Shutdown ();
|
||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
|
||||
fflush (stdout);
|
||||
exit (0);
|
||||
}
|
||||
va_list argptr;
|
||||
static char data[1024];
|
||||
int fd;
|
||||
|
||||
void
|
||||
Sys_Init (void)
|
||||
{
|
||||
#ifdef USE_INTEL_ASM
|
||||
Sys_SetFPCW ();
|
||||
#endif
|
||||
}
|
||||
va_start (argptr, fmt);
|
||||
vsnprintf (data, sizeof (data), fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||
write (fd, data, strlen (data));
|
||||
close (fd);
|
||||
}
|
||||
|
||||
void
|
||||
floating_point_exception_handler (int whatever)
|
||||
|
@ -131,6 +129,12 @@ floating_point_exception_handler (int whatever)
|
|||
signal (SIGFPE, floating_point_exception_handler);
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_ConsoleInput
|
||||
|
||||
Checks for a complete line of text typed in at the console, then forwards
|
||||
it to the host command processor
|
||||
*/
|
||||
const char *
|
||||
Sys_ConsoleInput (void)
|
||||
{
|
||||
|
|
|
@ -26,15 +26,12 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
|
@ -84,26 +81,20 @@ void MaskExceptions (void);
|
|||
#endif
|
||||
|
||||
|
||||
void
|
||||
Sys_DebugLog (const char *file, const char *fmt, ...)
|
||||
{
|
||||
int fd;
|
||||
static char data[1024]; // why static ?
|
||||
va_list argptr;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsnprintf (data, sizeof (data), fmt, argptr);
|
||||
va_end (argptr);
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||
write (fd, data, strlen (data));
|
||||
close (fd);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
SYSTEM IO
|
||||
*/
|
||||
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)
|
||||
|
@ -136,7 +127,20 @@ Sys_Init (void)
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Quit
|
||||
*/
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
Host_Shutdown ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Sys_Error
|
||||
*/
|
||||
void
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
|
@ -160,14 +164,29 @@ Sys_Error (const char *error, ...)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
Sys_Quit (void)
|
||||
Sys_DebugLog (const char *file, const char *fmt, ...)
|
||||
{
|
||||
Host_Shutdown ();
|
||||
exit (0);
|
||||
}
|
||||
int fd;
|
||||
static char data[1024]; // why static ?
|
||||
va_list argptr;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsnprintf (data, sizeof (data), fmt, argptr);
|
||||
va_end (argptr);
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||
write (fd, data, strlen (data));
|
||||
close (fd);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Sys_ConsoleInput
|
||||
|
||||
Checks for a complete line of text typed in at the console, then forwards
|
||||
it to the host command processor
|
||||
*/
|
||||
const char *
|
||||
Sys_ConsoleInput (void)
|
||||
{
|
||||
|
@ -181,19 +200,13 @@ Sys_Sleep (void)
|
|||
}
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
#ifndef SDL_main
|
||||
# define SDL_main main
|
||||
#endif
|
||||
|
||||
/*
|
||||
main
|
||||
*/
|
||||
int
|
||||
SDL_main (int c, char **v)
|
||||
{
|
||||
|
@ -210,7 +223,7 @@ SDL_main (int c, char **v)
|
|||
host_parms.argc = com_argc;
|
||||
host_parms.argv = com_argv;
|
||||
|
||||
host_parms.memsize = 16 * 1024 * 1024;
|
||||
host_parms.memsize = 16 * 1024 * 1024; // 16MB default heap
|
||||
|
||||
j = COM_CheckParm ("-mem");
|
||||
if (j)
|
||||
|
@ -221,6 +234,7 @@ SDL_main (int c, char **v)
|
|||
printf ("Can't allocate memory for zone.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
noconinput = COM_CheckParm ("-noconinput");
|
||||
if (!noconinput)
|
||||
|
@ -231,7 +245,7 @@ SDL_main (int c, char **v)
|
|||
|
||||
oldtime = Sys_DoubleTime ();
|
||||
while (1) {
|
||||
// find time spent rendering last frame
|
||||
// find time spent rendering last frame
|
||||
newtime = Sys_DoubleTime ();
|
||||
time = newtime - oldtime;
|
||||
|
||||
|
|
|
@ -55,9 +55,33 @@ int noconinput = 0;
|
|||
qboolean is_server = false;
|
||||
char *svs_info;
|
||||
|
||||
// General routines ======================================================
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
#ifdef USE_INTEL_ASM
|
||||
Sys_SetFPCW ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Quit
|
||||
*/
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
|
@ -69,26 +93,9 @@ Sys_Quit (void)
|
|||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
#ifdef USE_INTEL_ASM
|
||||
Sys_SetFPCW ();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Sys_Error
|
||||
*/
|
||||
void
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
|
@ -107,7 +114,6 @@ Sys_Error (const char *error, ...)
|
|||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sys_Warn (char *warning, ...)
|
||||
{
|
||||
|
@ -120,7 +126,6 @@ Sys_Warn (char *warning, ...)
|
|||
fprintf (stderr, "Warning: %s", string);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sys_DebugLog (const char *file, const char *fmt, ...)
|
||||
{
|
||||
|
@ -146,6 +151,12 @@ floating_point_exception_handler (int whatever)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
Sys_ConsoleInput
|
||||
|
||||
Checks for a complete line of text typed in at the console, then forwards
|
||||
it to the host command processor
|
||||
*/
|
||||
const char *
|
||||
Sys_ConsoleInput (void)
|
||||
{
|
||||
|
@ -181,6 +192,9 @@ Sys_LowFPPrecision (void)
|
|||
|
||||
int skipframes;
|
||||
|
||||
/*
|
||||
main
|
||||
*/
|
||||
int
|
||||
main (int c, const char *v[])
|
||||
{
|
||||
|
@ -204,6 +218,7 @@ main (int c, const char *v[])
|
|||
if (j)
|
||||
host_parms.memsize = (int) (atof (com_argv[j + 1]) * 1024 * 1024);
|
||||
host_parms.membase = malloc (host_parms.memsize);
|
||||
|
||||
if (!host_parms.membase) {
|
||||
printf ("Can't allocate memory for zone.\n");
|
||||
return 1;
|
||||
|
|
|
@ -83,60 +83,19 @@ void Sys_PopFPCW (void);
|
|||
void Sys_PushFPCW_SetHigh (void);
|
||||
|
||||
|
||||
void
|
||||
Sys_DebugLog (const char *file, const char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char data[1024];
|
||||
int fd;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsnprintf (data, sizeof (data), fmt, argptr);
|
||||
va_end (argptr);
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||
write (fd, data, strlen (data));
|
||||
close (fd);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
FILE IO
|
||||
Sys_Init_Cvars
|
||||
|
||||
Quake calls this so the system can register variables before host_hunklevel
|
||||
is marked
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
wfilelength (VFile *f)
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
||||
pos = Qtell (f);
|
||||
Qseek (f, 0, SEEK_END);
|
||||
end = Qtell (f);
|
||||
Qseek (f, pos, SEEK_SET);
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
SYSTEM IO
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Sys_Init
|
||||
*/
|
||||
|
||||
|
||||
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");
|
||||
"unset to enable std out - windows does NOT support this");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sys_Init (void)
|
||||
{
|
||||
|
@ -184,7 +143,30 @@ Sys_Init (void)
|
|||
WinNT = false;
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Quit
|
||||
*/
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
VID_ForceUnlockedAndReturnState ();
|
||||
|
||||
Host_Shutdown ();
|
||||
|
||||
if (tevent)
|
||||
CloseHandle (tevent);
|
||||
|
||||
if (qwclsemaphore)
|
||||
CloseHandle (qwclsemaphore);
|
||||
|
||||
Net_LogStop();
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Error
|
||||
*/
|
||||
void
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
|
@ -206,26 +188,42 @@ Sys_Error (const char *error, ...)
|
|||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sys_Quit (void)
|
||||
Sys_DebugLog (const char *file, const char *fmt, ...)
|
||||
{
|
||||
VID_ForceUnlockedAndReturnState ();
|
||||
va_list argptr;
|
||||
static char data[1024];
|
||||
int fd;
|
||||
|
||||
Host_Shutdown ();
|
||||
va_start (argptr, fmt);
|
||||
vsnprintf (data, sizeof (data), fmt, argptr);
|
||||
va_end (argptr);
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||
write (fd, data, strlen (data));
|
||||
close (fd);
|
||||
};
|
||||
|
||||
if (tevent)
|
||||
CloseHandle (tevent);
|
||||
|
||||
if (qwclsemaphore)
|
||||
CloseHandle (qwclsemaphore);
|
||||
int
|
||||
wfilelength (VFile *f)
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
||||
Net_LogStop();
|
||||
pos = Qtell (f);
|
||||
Qseek (f, 0, SEEK_END);
|
||||
end = Qtell (f);
|
||||
Qseek (f, pos, SEEK_SET);
|
||||
|
||||
exit (0);
|
||||
return end;
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_ConsoleInput
|
||||
|
||||
Checks for a complete line of text typed in at the console, then forwards
|
||||
it to the host command processor
|
||||
*/
|
||||
const char *
|
||||
Sys_ConsoleInput (void)
|
||||
{
|
||||
|
@ -334,18 +332,11 @@ Sys_ConsoleInput (void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sys_Sleep (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
WINDOWS CRAP
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
SleepUntilInput (int time)
|
||||
{
|
||||
|
@ -360,6 +351,9 @@ char *argv[MAX_NUM_ARGVS];
|
|||
static char *empty_string = "";
|
||||
|
||||
|
||||
/*
|
||||
main
|
||||
*/
|
||||
int WINAPI
|
||||
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
|
|
|
@ -65,72 +65,7 @@ char *svs_info = svs.info;
|
|||
|
||||
|
||||
/*
|
||||
REQUIRED SYS FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
Sys_Error
|
||||
*/
|
||||
void
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
||||
va_start (argptr, error);
|
||||
vsnprintf (string, sizeof (string), error, argptr);
|
||||
va_end (argptr);
|
||||
printf ("Fatal error: %s\n", string);
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Sys_Quit
|
||||
*/
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
|
||||
Net_LogStop();
|
||||
|
||||
exit (0); // appkit isn't running
|
||||
}
|
||||
|
||||
static int do_stdin = 1;
|
||||
|
||||
/*
|
||||
Sys_ConsoleInput
|
||||
|
||||
Checks for a complete line of text typed in at the console, then forwards
|
||||
it to the host command processor
|
||||
*/
|
||||
const char *
|
||||
Sys_ConsoleInput (void)
|
||||
{
|
||||
static char text[256];
|
||||
int len;
|
||||
|
||||
if (!stdin_ready || !do_stdin)
|
||||
return NULL; // the select didn't say it was ready
|
||||
stdin_ready = false;
|
||||
|
||||
len = read (0, text, sizeof (text));
|
||||
if (len == 0) {
|
||||
// end of file
|
||||
do_stdin = 0;
|
||||
return NULL;
|
||||
}
|
||||
if (len < 1)
|
||||
return NULL;
|
||||
text[len - 1] = 0; // rip off the /n and terminate
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Init
|
||||
Sys_Init_Cvars
|
||||
|
||||
Quake calls this so the system can register variables before host_hunklevel
|
||||
is marked
|
||||
|
@ -156,6 +91,67 @@ Sys_Init (void)
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Quit
|
||||
*/
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
|
||||
Net_LogStop();
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Error
|
||||
*/
|
||||
void
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
||||
va_start (argptr, error);
|
||||
vsnprintf (string, sizeof (string), error, argptr);
|
||||
va_end (argptr);
|
||||
printf ("Fatal error: %s\n", string);
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
static int do_stdin = 1;
|
||||
|
||||
/*
|
||||
Sys_ConsoleInput
|
||||
|
||||
Checks for a complete line of text typed in at the console, then forwards
|
||||
it to the host command processor
|
||||
*/
|
||||
const char *
|
||||
Sys_ConsoleInput (void)
|
||||
{
|
||||
static char text[256];
|
||||
int len;
|
||||
|
||||
if (!stdin_ready || !do_stdin)
|
||||
return NULL; // the select didn't say it was ready
|
||||
stdin_ready = false;
|
||||
|
||||
len = read (0, text, sizeof (text));
|
||||
if (len == 0) {
|
||||
// end of file
|
||||
do_stdin = 0;
|
||||
return NULL;
|
||||
}
|
||||
if (len < 1)
|
||||
return NULL;
|
||||
text[len - 1] = 0; // rip off the /n and terminate
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/*
|
||||
main
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
sys_win.c
|
||||
sv_sys_win.c
|
||||
|
||||
(description)
|
||||
|
||||
|
@ -52,81 +52,11 @@ cvar_t *sys_sleep;
|
|||
|
||||
|
||||
/*
|
||||
Sys_Error
|
||||
*/
|
||||
void
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char text[1024];
|
||||
|
||||
va_start (argptr, error);
|
||||
vsnprintf (text, sizeof (text), error, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
// MessageBox(NULL, text, "Error", 0 /* MB_OK */ );
|
||||
printf ("ERROR: %s\n", text);
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Sys_ConsoleInput
|
||||
*/
|
||||
const char *
|
||||
Sys_ConsoleInput (void)
|
||||
{
|
||||
static char text[256];
|
||||
static int len;
|
||||
int c;
|
||||
|
||||
// read a line out
|
||||
while (kbhit ()) {
|
||||
c = _getch ();
|
||||
putch (c);
|
||||
if (c == '\r') {
|
||||
text[len] = 0;
|
||||
putch ('\n');
|
||||
len = 0;
|
||||
return text;
|
||||
}
|
||||
if (c == 8) {
|
||||
if (len) {
|
||||
putch (' ');
|
||||
putch (c);
|
||||
len--;
|
||||
text[len] = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
text[len] = c;
|
||||
len++;
|
||||
text[len] = 0;
|
||||
if (len == sizeof (text))
|
||||
len = 0;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Quit
|
||||
*/
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
Net_LogStop();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Init
|
||||
Sys_Init_Cvars
|
||||
|
||||
Quake calls this so the system can register variables before host_hunklevel
|
||||
is marked
|
||||
*/
|
||||
|
||||
void
|
||||
Sys_Init_Cvars (void)
|
||||
{
|
||||
|
@ -164,6 +94,78 @@ Sys_Init (void)
|
|||
WinNT = false;
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Quit
|
||||
*/
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
Net_LogStop();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Error
|
||||
*/
|
||||
void
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char text[1024];
|
||||
|
||||
va_start (argptr, error);
|
||||
vsnprintf (text, sizeof (text), error, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
// MessageBox(NULL, text, "Error", 0 /* MB_OK */ );
|
||||
printf ("ERROR: %s\n", text);
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Sys_ConsoleInput
|
||||
|
||||
Checks for a complete line of text typed in at the console, then forwards
|
||||
it to the host command processor
|
||||
*/
|
||||
const char *
|
||||
Sys_ConsoleInput (void)
|
||||
{
|
||||
static char text[256];
|
||||
static int len;
|
||||
int c;
|
||||
|
||||
// read a line out
|
||||
while (kbhit ()) {
|
||||
c = _getch ();
|
||||
putch (c);
|
||||
if (c == '\r') {
|
||||
text[len] = 0;
|
||||
putch ('\n');
|
||||
len = 0;
|
||||
return text;
|
||||
}
|
||||
if (c == 8) {
|
||||
if (len) {
|
||||
putch (' ');
|
||||
putch (c);
|
||||
len--;
|
||||
text[len] = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
text[len] = c;
|
||||
len++;
|
||||
text[len] = 0;
|
||||
if (len == sizeof (text))
|
||||
len = 0;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
main
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue