mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-06-02 01:51:37 +00:00
backport 0.5's sys stuff. much saner linking.
This commit is contained in:
parent
4fa410afef
commit
1ed975edd5
13 changed files with 554 additions and 808 deletions
|
@ -236,9 +236,10 @@ AC_FUNC_MMAP
|
||||||
AC_TYPE_SIGNAL
|
AC_TYPE_SIGNAL
|
||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
AC_CHECK_FUNCS(
|
AC_CHECK_FUNCS(
|
||||||
|
access _access \
|
||||||
connect dlopen fcntl ftime getaddrinfo gethostname gethostbyname \
|
connect dlopen fcntl ftime getaddrinfo gethostname gethostbyname \
|
||||||
getnameinfo gettimeofday mkdir select socket stat strerror \
|
getnameinfo gettimeofday mkdir _mkdir select socket stat strerror \
|
||||||
strstr snprintf vsnprintf _snprintf _vsnprintf
|
strstr snprintf vsnprintf _snprintf _vsnprintf mprotect
|
||||||
)
|
)
|
||||||
|
|
||||||
dnl Checks for stricmp/strcasecmp
|
dnl Checks for stricmp/strcasecmp
|
||||||
|
|
|
@ -26,49 +26,30 @@
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_H
|
#ifndef __sys_h
|
||||||
#define _SYS_H
|
#define __sys_h
|
||||||
|
|
||||||
#include "gcc_attr.h"
|
#include <stdarg.h>
|
||||||
|
|
||||||
//
|
#include "QF/gcc_attr.h"
|
||||||
// file IO
|
|
||||||
//
|
|
||||||
|
|
||||||
// returns the file size
|
extern struct cvar_s *sys_nostdout;
|
||||||
// return -1 if file is not present
|
|
||||||
// the file should be in BINARY mode for stupid OSs that care
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl);
|
|
||||||
|
|
||||||
int Sys_FileOpenWrite (char *path);
|
extern const char sys_char_map[256];
|
||||||
void Sys_FileClose (int handle);
|
|
||||||
void Sys_FileSeek (int handle, int position);
|
|
||||||
int Sys_FileRead (int handle, void *dest, int count);
|
|
||||||
int Sys_FileWrite (int handle, void *data, int count);
|
|
||||||
int Sys_FileTime (char *path);
|
|
||||||
void Sys_mkdir (char *path);
|
|
||||||
|
|
||||||
//
|
int Sys_FileTime (const char *path);
|
||||||
// memory protection
|
void Sys_mkdir (const char *path);
|
||||||
//
|
|
||||||
void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length);
|
|
||||||
|
|
||||||
//
|
typedef void (*sys_printf_t) (const char *fmt, va_list args);
|
||||||
// system IO
|
|
||||||
//
|
|
||||||
void Sys_DebugLog(char *file, char *fmt, ...) __attribute__((format(printf,2,3)));
|
|
||||||
|
|
||||||
void Sys_Error (char *error, ...) __attribute__((format(printf,1,2)));
|
void Sys_SetPrintf (sys_printf_t func);
|
||||||
// an error will cause the entire program to exit
|
|
||||||
|
|
||||||
void Sys_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
|
||||||
// send text to the console
|
|
||||||
|
|
||||||
|
void Sys_Printf (const char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
|
void Sys_Error (const char *error, ...) __attribute__((format(printf,1,2), noreturn));
|
||||||
void Sys_Quit (void);
|
void Sys_Quit (void);
|
||||||
|
|
||||||
double Sys_DoubleTime (void);
|
double Sys_DoubleTime (void);
|
||||||
|
|
||||||
char *Sys_ConsoleInput (void);
|
const char *Sys_ConsoleInput (void);
|
||||||
|
|
||||||
void Sys_Sleep (void);
|
void Sys_Sleep (void);
|
||||||
// called to yield for a little bit so as
|
// called to yield for a little bit so as
|
||||||
|
@ -78,11 +59,19 @@ void Sys_LowFPPrecision (void);
|
||||||
void Sys_HighFPPrecision (void);
|
void Sys_HighFPPrecision (void);
|
||||||
void Sys_SetFPCW (void);
|
void Sys_SetFPCW (void);
|
||||||
|
|
||||||
void Sys_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
|
||||||
// send text to the console
|
// send text to the console
|
||||||
|
|
||||||
void Sys_Init (void);
|
void Sys_Init (void);
|
||||||
void Sys_Init_Cvars (void);
|
void Sys_Init_Cvars (void);
|
||||||
|
|
||||||
#endif // _SYS_H
|
//
|
||||||
|
// memory protection
|
||||||
|
//
|
||||||
|
void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length);
|
||||||
|
|
||||||
|
//
|
||||||
|
// system IO
|
||||||
|
//
|
||||||
|
void Sys_DebugLog(const char *file, const char *fmt, ...) __attribute__((format(printf,2,3)));
|
||||||
|
|
||||||
|
#endif // __sys_h
|
||||||
|
|
|
@ -31,7 +31,7 @@ AUTOMAKE_OPTIONS= foreign
|
||||||
#
|
#
|
||||||
# Stuff that is common to both client and server
|
# Stuff that is common to both client and server
|
||||||
#
|
#
|
||||||
INCLUDES= -I$(top_srcdir)/include $(GGI_CFLAGS) $(MGL_CFLAGS) $(SDL_CFLAGS) $(SVGA_CFLAGS) $(X_CFLAGS) $(GLX_CFLAGS) $(TDFXGL_CFLAGS)
|
INCLUDES= -I$(top_srcdir)/include $(GGI_CFLAGS) $(MGL_CFLAGS) $(SVGA_CFLAGS) $(X_CFLAGS) $(GLX_CFLAGS) $(TDFXGL_CFLAGS)
|
||||||
|
|
||||||
bin_PROGRAMS = @TARGETS@
|
bin_PROGRAMS = @TARGETS@
|
||||||
|
|
||||||
|
@ -71,11 +71,11 @@ EXTRA_libqfnet_a_SOURCES= net_chan.c net_com.c net_udp.c net_udp6.c
|
||||||
# ... System type
|
# ... System type
|
||||||
#
|
#
|
||||||
if SYSTYPE_WIN32
|
if SYSTYPE_WIN32
|
||||||
libqfsys_sv_a_SOURCES= fnmatch.c dirent.c sv_sys_win.c sys_win.c
|
libqfsys_sv_a_SOURCES= fnmatch.c dirent.c sv_sys_win.c sys.c
|
||||||
else
|
else
|
||||||
libqfsys_sv_a_SOURCES= sv_sys_unix.c sys_unix.c
|
libqfsys_sv_a_SOURCES= sv_sys_unix.c sys.c
|
||||||
endif
|
endif
|
||||||
EXTRA_libqfsys_sv_a_SOURCES= fnmatch.c dirent.c sv_sys_unix.c sv_sys_win.c sys_unix.c sys_win.c
|
EXTRA_libqfsys_sv_a_SOURCES= fnmatch.c dirent.c sv_sys_unix.c sv_sys_win.c sys.c sys.c
|
||||||
|
|
||||||
server_SOURCES= pr_edict.c pr_exec.c pr_offs.c sv_ccmds.c sv_cvar.c \
|
server_SOURCES= pr_edict.c pr_exec.c pr_offs.c sv_ccmds.c sv_cvar.c \
|
||||||
sv_ents.c sv_init.c sv_main.c sv_misc.c sv_model.c \
|
sv_ents.c sv_init.c sv_main.c sv_misc.c sv_model.c \
|
||||||
|
@ -92,11 +92,11 @@ qf_server_DEPENDENCIES= libqfnet.a libqfsys_sv.a
|
||||||
# ... System type
|
# ... System type
|
||||||
#
|
#
|
||||||
if SYSTYPE_WIN32
|
if SYSTYPE_WIN32
|
||||||
libqfsys_cl_a_SOURCES= cl_sys_win.c fnmatch.c dirent.c sys_win.c
|
libqfsys_cl_a_SOURCES= cl_sys_win.c fnmatch.c dirent.c sys.c
|
||||||
else
|
else
|
||||||
libqfsys_cl_a_SOURCES= cl_sys_unix.c sys_unix.c
|
libqfsys_cl_a_SOURCES= cl_sys_unix.c sys.c
|
||||||
endif
|
endif
|
||||||
EXTRA_libqfsys_cl_a_SOURCES= cl_sys_sdl.c cl_sys_unix.c cl_sys_win.c sys_win.c sys_unix.c fnmatch.c dirent.c
|
EXTRA_libqfsys_cl_a_SOURCES= cl_sys_sdl.c cl_sys_unix.c cl_sys_win.c sys.c sys.c fnmatch.c dirent.c
|
||||||
|
|
||||||
#
|
#
|
||||||
# ... Digital audio
|
# ... Digital audio
|
||||||
|
@ -115,6 +115,7 @@ libqfsnd_a_SOURCES= snd_dma.c snd_mem.c snd_mix.c snd_oss.c
|
||||||
endif
|
endif
|
||||||
if SNDTYPE_SDL
|
if SNDTYPE_SDL
|
||||||
libqfsnd_a_SOURCES= snd_dma.c snd_mem.c snd_mix.c snd_sdl.c
|
libqfsnd_a_SOURCES= snd_dma.c snd_mem.c snd_mix.c snd_sdl.c
|
||||||
|
libqfsnd_a_INCLUDES= $(SDL_CFLAGS)
|
||||||
endif
|
endif
|
||||||
if SNDTYPE_SGI
|
if SNDTYPE_SGI
|
||||||
libqfsnd_a_SOURCES= snd_dma.c snd_mem.c snd_mix.c snd_sgi.c
|
libqfsnd_a_SOURCES= snd_dma.c snd_mem.c snd_mix.c snd_sgi.c
|
||||||
|
@ -140,6 +141,7 @@ libqfcd_a_SOURCES= cd_linux.c
|
||||||
endif
|
endif
|
||||||
if CDTYPE_SDL
|
if CDTYPE_SDL
|
||||||
libqfcd_a_SOURCES= cd_sdl.c
|
libqfcd_a_SOURCES= cd_sdl.c
|
||||||
|
libqfcd_a_INCLUDES=$(SDL_CFLAGS)
|
||||||
endif
|
endif
|
||||||
if CDTYPE_SGI
|
if CDTYPE_SGI
|
||||||
libqfcd_a_SOURCES= cd_sgi.c
|
libqfcd_a_SOURCES= cd_sgi.c
|
||||||
|
@ -319,3 +321,39 @@ EXTRA_DIST= makefile.mgw makefile.win \
|
||||||
|
|
||||||
# Kill the temp files, hopefully.
|
# Kill the temp files, hopefully.
|
||||||
CLEANFILES = *.i *.s $(YACCLEX_CLEANFILES)
|
CLEANFILES = *.i *.s $(YACCLEX_CLEANFILES)
|
||||||
|
|
||||||
|
cl_sys_sdl.o: cl_sys_sdl.c
|
||||||
|
@echo '$(COMPILE) $(SDL_CFLAGS) -c $<'; \
|
||||||
|
$(COMPILE) $(SDL_CFLAGS) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||||
|
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||||
|
tr ' ' '\012' < .deps/$(*F).pp \
|
||||||
|
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||||
|
>> .deps/$(*F).P; \
|
||||||
|
rm .deps/$(*F).pp
|
||||||
|
|
||||||
|
in_sdl.o: in_sdl.c
|
||||||
|
@echo '$(COMPILE) $(SDL_CFLAGS) -c $<'; \
|
||||||
|
$(COMPILE) $(SDL_CFLAGS) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||||
|
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||||
|
tr ' ' '\012' < .deps/$(*F).pp \
|
||||||
|
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||||
|
>> .deps/$(*F).P; \
|
||||||
|
rm .deps/$(*F).pp
|
||||||
|
|
||||||
|
vid_sdl.o: vid_sdl.c
|
||||||
|
@echo '$(COMPILE) $(SDL_CFLAGS) -c $<'; \
|
||||||
|
$(COMPILE) $(SDL_CFLAGS) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||||
|
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||||
|
tr ' ' '\012' < .deps/$(*F).pp \
|
||||||
|
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||||
|
>> .deps/$(*F).P; \
|
||||||
|
rm .deps/$(*F).pp
|
||||||
|
|
||||||
|
vid_sgl.o: vid_sgl.c
|
||||||
|
@echo '$(COMPILE) $(SDL_CFLAGS) -c $<'; \
|
||||||
|
$(COMPILE) $(SDL_CFLAGS) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||||
|
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||||
|
tr ' ' '\012' < .deps/$(*F).pp \
|
||||||
|
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||||
|
>> .deps/$(*F).P; \
|
||||||
|
rm .deps/$(*F).pp
|
||||||
|
|
|
@ -26,15 +26,12 @@
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
@ -60,111 +57,51 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_main.h>
|
#include <SDL_main.h>
|
||||||
|
|
||||||
|
#include "cvar.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "compat.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
|
|
||||||
qboolean is_server = false;
|
qboolean is_server = false;
|
||||||
qboolean noconinput = false;
|
|
||||||
char *svs_info;
|
char *svs_info;
|
||||||
|
|
||||||
int starttime;
|
int starttime;
|
||||||
|
int noconinput;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include "winquake.h"
|
# include "winquake.h"
|
||||||
// fixme: minimized is not currently supported under
|
// FIXME: minimized is not currently supported under
|
||||||
// SDL
|
// SDL
|
||||||
qboolean Minimized = false;
|
qboolean Minimized = false;
|
||||||
void MaskExceptions (void);
|
void MaskExceptions (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
|
||||||
Sys_DebugLog (char *file, 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);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FILE IO
|
Sys_Init_Cvars
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
Quake calls this so the system can register variables before host_hunklevel
|
||||||
Sys_FileTime (char *path)
|
is marked
|
||||||
{
|
|
||||||
QFile *f;
|
|
||||||
int retval;
|
|
||||||
|
|
||||||
f = Qopen (path, "rb");
|
|
||||||
|
|
||||||
if (f) {
|
|
||||||
Qclose (f);
|
|
||||||
retval = 1;
|
|
||||||
} else {
|
|
||||||
retval = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
SYSTEM IO
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_MakeCodeWriteable
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
|
Sys_Init_Cvars (void)
|
||||||
{
|
{
|
||||||
|
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL,
|
||||||
#ifdef _WIN32
|
"set to disable std out");
|
||||||
DWORD flOldProtect;
|
if (COM_CheckParm ("-nostdout"))
|
||||||
|
Cvar_Set (sys_nostdout, "1");
|
||||||
// copy on write or just read-write?
|
|
||||||
if (!VirtualProtect
|
|
||||||
((LPVOID) startaddr, length, PAGE_READWRITE,
|
|
||||||
&flOldProtect)) Sys_Error ("Protection change failed\n");
|
|
||||||
#else
|
|
||||||
int r;
|
|
||||||
unsigned long addr;
|
|
||||||
int psize = getpagesize ();
|
|
||||||
|
|
||||||
addr = (startaddr & ~(psize - 1)) - psize;
|
|
||||||
|
|
||||||
// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
|
|
||||||
// addr, startaddr+length, length);
|
|
||||||
|
|
||||||
r = mprotect ((char *) addr, length + startaddr - addr + psize, 7);
|
|
||||||
|
|
||||||
if (r < 0)
|
|
||||||
Sys_Error ("Protection change failed\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_Init
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
Sys_Init (void)
|
Sys_Init (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
OSVERSIONINFO vinfo;
|
OSVERSIONINFO vinfo;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_INTEL_ASM
|
#ifdef USE_INTEL_ASM
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
MaskExceptions ();
|
MaskExceptions ();
|
||||||
|
@ -190,9 +127,22 @@ Sys_Init (void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sys_Quit
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
Sys_Error (char *error, ...)
|
Sys_Quit (void)
|
||||||
|
{
|
||||||
|
Host_Shutdown ();
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sys_Error
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Sys_Error (const char *error, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char text[1024];
|
char text[1024];
|
||||||
|
@ -213,41 +163,53 @@ Sys_Error (char *error, ...)
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
Sys_Quit (void)
|
|
||||||
{
|
|
||||||
Host_Shutdown ();
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
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)
|
Sys_ConsoleInput (void)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Sys_Sleep (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
|
#ifndef SDL_main
|
||||||
# define SDL_main main
|
# define SDL_main main
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
main
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
SDL_main (int c, char **v)
|
SDL_main (int c, char **v)
|
||||||
{
|
{
|
||||||
|
|
||||||
double time, oldtime, newtime;
|
double time, oldtime, newtime;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
@ -261,7 +223,7 @@ SDL_main (int c, char **v)
|
||||||
host_parms.argc = com_argc;
|
host_parms.argc = com_argc;
|
||||||
host_parms.argv = com_argv;
|
host_parms.argv = com_argv;
|
||||||
|
|
||||||
host_parms.memsize = 16 * 1024 * 1024;
|
host_parms.memsize = 16 * 1024 * 1024; // 16MB default heap
|
||||||
|
|
||||||
j = COM_CheckParm ("-mem");
|
j = COM_CheckParm ("-mem");
|
||||||
if (j)
|
if (j)
|
||||||
|
@ -272,6 +234,7 @@ SDL_main (int c, char **v)
|
||||||
printf ("Can't allocate memory for zone.\n");
|
printf ("Can't allocate memory for zone.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
noconinput = COM_CheckParm ("-noconinput");
|
noconinput = COM_CheckParm ("-noconinput");
|
||||||
if (!noconinput)
|
if (!noconinput)
|
||||||
|
@ -282,17 +245,15 @@ SDL_main (int c, char **v)
|
||||||
|
|
||||||
oldtime = Sys_DoubleTime ();
|
oldtime = Sys_DoubleTime ();
|
||||||
while (1) {
|
while (1) {
|
||||||
// find time spent rendering last frame
|
// find time spent rendering last frame
|
||||||
newtime = Sys_DoubleTime ();
|
newtime = Sys_DoubleTime ();
|
||||||
time = newtime - oldtime;
|
time = newtime - oldtime;
|
||||||
|
|
||||||
Host_Frame (time);
|
Host_Frame (time);
|
||||||
oldtime = newtime;
|
oldtime = newtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fixme: evil stub for directsound crap */
|
|
||||||
void
|
void
|
||||||
IN_Accumulate (void)
|
IN_Accumulate (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,39 +45,28 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
#include "host.h"
|
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
||||||
|
#include "host.h"
|
||||||
|
#include "net.h"
|
||||||
|
|
||||||
int noconinput = 0;
|
int noconinput = 0;
|
||||||
qboolean is_server = false;
|
qboolean is_server = false;
|
||||||
char *svs_info;
|
char *svs_info;
|
||||||
|
|
||||||
#ifdef PACKET_LOGGING
|
|
||||||
void Net_LogStop (void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// =======================================================================
|
/*
|
||||||
// General routines
|
Sys_Init_Cvars
|
||||||
// =======================================================================
|
|
||||||
|
|
||||||
void
|
|
||||||
Sys_Quit (void)
|
|
||||||
{
|
|
||||||
Host_Shutdown ();
|
|
||||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
|
|
||||||
|
|
||||||
#ifdef PACKET_LOGGING
|
|
||||||
Net_LogStop();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Quake calls this so the system can register variables before host_hunklevel
|
||||||
|
is marked
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
Sys_Init_Cvars (void)
|
Sys_Init_Cvars (void)
|
||||||
{
|
{
|
||||||
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL, "set to disable std out");
|
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL,
|
||||||
|
"set to disable std out");
|
||||||
if (COM_CheckParm ("-nostdout"))
|
if (COM_CheckParm ("-nostdout"))
|
||||||
Cvar_Set (sys_nostdout, "1");
|
Cvar_Set (sys_nostdout, "1");
|
||||||
}
|
}
|
||||||
|
@ -90,8 +79,25 @@ Sys_Init (void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sys_Quit
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
Sys_Error (char *error, ...)
|
Sys_Quit (void)
|
||||||
|
{
|
||||||
|
Host_Shutdown ();
|
||||||
|
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
|
||||||
|
|
||||||
|
//Net_LogStop();
|
||||||
|
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sys_Error
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Sys_Error (const char *error, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char string[1024];
|
char string[1024];
|
||||||
|
@ -106,7 +112,6 @@ Sys_Error (char *error, ...)
|
||||||
|
|
||||||
Host_Shutdown ();
|
Host_Shutdown ();
|
||||||
exit (1);
|
exit (1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -122,7 +127,7 @@ Sys_Warn (char *warning, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Sys_DebugLog (char *file, char *fmt, ...)
|
Sys_DebugLog (const char *file, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
static char data[1024]; // why static ?
|
static char data[1024]; // why static ?
|
||||||
|
@ -131,20 +136,28 @@ Sys_DebugLog (char *file, char *fmt, ...)
|
||||||
va_start (argptr, fmt);
|
va_start (argptr, fmt);
|
||||||
vsnprintf (data, sizeof (data), fmt, argptr);
|
vsnprintf (data, sizeof (data), fmt, argptr);
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
// fd = open(file, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, 0666);
|
// fd = open(file, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, 0666);
|
||||||
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
fd = open (file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||||
write (fd, data, strlen (data));
|
write (fd, data, strlen (data));
|
||||||
close (fd);
|
close (fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
floating_point_exception_handler (int whatever)
|
floating_point_exception_handler (int whatever)
|
||||||
{
|
{
|
||||||
// Sys_Warn("floating point exception\n");
|
// Sys_Warn("floating point exception\n");
|
||||||
signal (SIGFPE, floating_point_exception_handler);
|
signal (SIGFPE, floating_point_exception_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
|
||||||
|
/*
|
||||||
|
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)
|
Sys_ConsoleInput (void)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -163,12 +176,14 @@ Sys_ConsoleInput (void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef USE_INTEL_ASM
|
#ifndef USE_INTEL_ASM
|
||||||
void
|
void
|
||||||
Sys_HighFPPrecision (void)
|
Sys_HighFPPrecision (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Sys_LowFPPrecision (void)
|
Sys_LowFPPrecision (void)
|
||||||
{
|
{
|
||||||
|
@ -177,15 +192,18 @@ Sys_LowFPPrecision (void)
|
||||||
|
|
||||||
int skipframes;
|
int skipframes;
|
||||||
|
|
||||||
|
/*
|
||||||
|
main
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
main (int c, char **v)
|
main (int c, char *v[])
|
||||||
{
|
{
|
||||||
double time, oldtime, newtime;
|
double time, oldtime, newtime;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
// static char cwd[1024];
|
// static char cwd[1024];
|
||||||
|
|
||||||
// signal(SIGFPE, floating_point_exception_handler);
|
// signal(SIGFPE, floating_point_exception_handler);
|
||||||
signal (SIGFPE, SIG_IGN);
|
signal (SIGFPE, SIG_IGN);
|
||||||
|
|
||||||
memset (&host_parms, 0, sizeof (host_parms));
|
memset (&host_parms, 0, sizeof (host_parms));
|
||||||
|
@ -194,12 +212,13 @@ main (int c, char **v)
|
||||||
host_parms.argc = com_argc;
|
host_parms.argc = com_argc;
|
||||||
host_parms.argv = com_argv;
|
host_parms.argv = com_argv;
|
||||||
|
|
||||||
host_parms.memsize = 16 * 1024 * 1024; // 8MB default heap
|
host_parms.memsize = 16 * 1024 * 1024; // 16MB default heap
|
||||||
|
|
||||||
j = COM_CheckParm ("-mem");
|
j = COM_CheckParm ("-mem");
|
||||||
if (j)
|
if (j)
|
||||||
host_parms.memsize = (int) (atof (com_argv[j + 1]) * 1024 * 1024);
|
host_parms.memsize = (int) (atof (com_argv[j + 1]) * 1024 * 1024);
|
||||||
host_parms.membase = malloc (host_parms.memsize);
|
host_parms.membase = malloc (host_parms.memsize);
|
||||||
|
|
||||||
if (!host_parms.membase) {
|
if (!host_parms.membase) {
|
||||||
printf ("Can't allocate memory for zone.\n");
|
printf ("Can't allocate memory for zone.\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -221,27 +240,3 @@ main (int c, char **v)
|
||||||
oldtime = newtime;
|
oldtime = newtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_MakeCodeWriteable
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
|
|
||||||
{
|
|
||||||
|
|
||||||
int r;
|
|
||||||
unsigned long addr;
|
|
||||||
int psize = getpagesize ();
|
|
||||||
|
|
||||||
addr = (startaddr & ~(psize - 1)) - psize;
|
|
||||||
|
|
||||||
// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
|
|
||||||
// addr, startaddr+length, length);
|
|
||||||
|
|
||||||
r = mprotect ((char *) addr, length + startaddr - addr + psize, 7);
|
|
||||||
|
|
||||||
if (r < 0)
|
|
||||||
Sys_Error ("Protection change failed\n");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -38,16 +38,20 @@
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include "client.h"
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "host.h"
|
#include "cvar.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
#include "resource.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
|
|
||||||
|
#include "client.h"
|
||||||
|
#include "compat.h"
|
||||||
|
#include "host.h"
|
||||||
|
#include "net.h"
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
qboolean is_server = false;
|
qboolean is_server = false;
|
||||||
char *svs_info;
|
char *svs_info;
|
||||||
|
|
||||||
|
@ -78,92 +82,18 @@ void MaskExceptions (void);
|
||||||
void Sys_PopFPCW (void);
|
void Sys_PopFPCW (void);
|
||||||
void Sys_PushFPCW_SetHigh (void);
|
void Sys_PushFPCW_SetHigh (void);
|
||||||
|
|
||||||
void
|
|
||||||
Sys_DebugLog (char *file, 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
wfilelength
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
wfilelength (QFile *f)
|
|
||||||
{
|
|
||||||
int pos;
|
|
||||||
int end;
|
|
||||||
|
|
||||||
pos = Qtell (f);
|
|
||||||
Qseek (f, 0, SEEK_END);
|
|
||||||
end = Qtell (f);
|
|
||||||
Qseek (f, pos, SEEK_SET);
|
|
||||||
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
Sys_FileTime (char *path)
|
|
||||||
{
|
|
||||||
QFile *f;
|
|
||||||
int t, retval;
|
|
||||||
|
|
||||||
t = VID_ForceUnlockedAndReturnState ();
|
|
||||||
|
|
||||||
f = Qopen (path, "rb");
|
|
||||||
|
|
||||||
if (f) {
|
|
||||||
Qclose (f);
|
|
||||||
retval = 1;
|
|
||||||
} else {
|
|
||||||
retval = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
VID_ForceLockState (t);
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
SYSTEM IO
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_MakeCodeWriteable
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
|
|
||||||
{
|
|
||||||
DWORD flOldProtect;
|
|
||||||
|
|
||||||
//@@@ copy on write or just read-write?
|
|
||||||
if (!VirtualProtect
|
|
||||||
((LPVOID) startaddr, length, PAGE_READWRITE,
|
|
||||||
&flOldProtect)) Sys_Error ("Protection change failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_Init
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Sys_Init_Cvars (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");
|
sys_nostdout = Cvar_Get ("sys_nostdout", "1", CVAR_NONE, NULL,
|
||||||
|
"unset to enable std out - windows does NOT support this");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -213,9 +143,32 @@ Sys_Init (void)
|
||||||
WinNT = false;
|
WinNT = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sys_Quit
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
Sys_Error (char *error, ...)
|
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, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char text[1024]; // , text2[1024];
|
char text[1024]; // , text2[1024];
|
||||||
|
@ -236,28 +189,42 @@ Sys_Error (char *error, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
int
|
||||||
CloseHandle (qwclsemaphore);
|
wfilelength (QFile *f)
|
||||||
|
{
|
||||||
|
int pos;
|
||||||
|
int end;
|
||||||
|
|
||||||
#ifdef PACKET_LOGGING
|
pos = Qtell (f);
|
||||||
Net_LogStop();
|
Qseek (f, 0, SEEK_END);
|
||||||
#endif
|
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
|
||||||
char *
|
it to the host command processor
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
Sys_ConsoleInput (void)
|
Sys_ConsoleInput (void)
|
||||||
{
|
{
|
||||||
static char text[256];
|
static char text[256];
|
||||||
|
@ -362,7 +329,6 @@ Sys_ConsoleInput (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,6 +337,13 @@ Sys_Sleep (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SleepUntilInput (int time)
|
||||||
|
{
|
||||||
|
|
||||||
|
MsgWaitForMultipleObjects (1, &tevent, FALSE, time, QS_ALLINPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IN_SendKeyEvents (void)
|
IN_SendKeyEvents (void)
|
||||||
|
@ -389,37 +362,20 @@ IN_SendKeyEvents (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
WINDOWS CRAP
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
WinMain
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
SleepUntilInput (int time)
|
|
||||||
{
|
|
||||||
|
|
||||||
MsgWaitForMultipleObjects (1, &tevent, FALSE, time, QS_ALLINPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
WinMain
|
|
||||||
*/
|
|
||||||
HINSTANCE global_hInstance;
|
HINSTANCE global_hInstance;
|
||||||
int global_nCmdShow;
|
int global_nCmdShow;
|
||||||
char *argv[MAX_NUM_ARGVS];
|
char *argv[MAX_NUM_ARGVS];
|
||||||
static char *empty_string = "";
|
static char *empty_string = "";
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
main
|
||||||
|
*/
|
||||||
int WINAPI
|
int WINAPI
|
||||||
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
||||||
int nCmdShow)
|
int nCmdShow)
|
||||||
{
|
{
|
||||||
// MSG msg;
|
// MSG msg;
|
||||||
double time, oldtime, newtime;
|
double time, oldtime, newtime;
|
||||||
MEMORYSTATUS lpBuffer;
|
MEMORYSTATUS lpBuffer;
|
||||||
static char cwd[1024];
|
static char cwd[1024];
|
||||||
|
@ -462,7 +418,6 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
||||||
*lpCmdLine = 0;
|
*lpCmdLine = 0;
|
||||||
lpCmdLine++;
|
lpCmdLine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,8 +478,8 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
||||||
if (!tevent)
|
if (!tevent)
|
||||||
Sys_Error ("Couldn't create event");
|
Sys_Error ("Couldn't create event");
|
||||||
|
|
||||||
// because sound is off until we become active
|
// because sound is off until we become active
|
||||||
S_BlockSound ();
|
//XXX S_BlockSound ();
|
||||||
|
|
||||||
Sys_Printf ("Host_Init\n");
|
Sys_Printf ("Host_Init\n");
|
||||||
Host_Init ();
|
Host_Init ();
|
||||||
|
|
|
@ -1373,7 +1373,7 @@ SV_GetConsoleCommands (void)
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
cmd = Sys_ConsoleInput ();
|
cmd = (char*)Sys_ConsoleInput ();
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
break;
|
break;
|
||||||
Cbuf_AddText (cmd);
|
Cbuf_AddText (cmd);
|
||||||
|
|
|
@ -47,9 +47,10 @@
|
||||||
|
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
#include "server.h"
|
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
||||||
|
#include "server.h"
|
||||||
|
|
||||||
#ifdef NeXT
|
#ifdef NeXT
|
||||||
# include <libc.h>
|
# include <libc.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -64,14 +65,49 @@ char *svs_info = svs.info;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
REQUIRED SYS FUNCTIONS
|
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)
|
||||||
|
{
|
||||||
|
#ifdef USE_INTEL_ASM
|
||||||
|
Sys_SetFPCW ();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sys_Quit
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Sys_Quit (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
//Net_LogStop();
|
||||||
|
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sys_Error
|
Sys_Error
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Sys_Error (char *error, ...)
|
Sys_Error (const char *error, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char string[1024];
|
char string[1024];
|
||||||
|
@ -85,20 +121,6 @@ Sys_Error (char *error, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_Quit
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Sys_Quit (void)
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef PACKET_LOGGING
|
|
||||||
Net_LogStop();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
exit (0); // appkit isn't running
|
|
||||||
}
|
|
||||||
|
|
||||||
static int do_stdin = 1;
|
static int do_stdin = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -107,7 +129,7 @@ static int do_stdin = 1;
|
||||||
Checks for a complete line of text typed in at the console, then forwards
|
Checks for a complete line of text typed in at the console, then forwards
|
||||||
it to the host command processor
|
it to the host command processor
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
Sys_ConsoleInput (void)
|
Sys_ConsoleInput (void)
|
||||||
{
|
{
|
||||||
static char text[256];
|
static char text[256];
|
||||||
|
@ -130,32 +152,6 @@ Sys_ConsoleInput (void)
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_Init
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
#ifdef USE_INTEL_ASM
|
|
||||||
Sys_SetFPCW ();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
main
|
main
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
sys_win.c
|
sv_sys_win.c
|
||||||
|
|
||||||
(description)
|
(description)
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
@ -49,29 +50,65 @@ char *svs_info = svs.info;
|
||||||
extern cvar_t *sys_nostdout;
|
extern cvar_t *sys_nostdout;
|
||||||
cvar_t *sys_sleep;
|
cvar_t *sys_sleep;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sys_FileTime
|
Sys_Init_Cvars
|
||||||
|
|
||||||
|
Quake calls this so the system can register variables before host_hunklevel
|
||||||
|
is marked
|
||||||
*/
|
*/
|
||||||
int
|
void
|
||||||
Sys_FileTime (char *path)
|
Sys_Init_Cvars (void)
|
||||||
{
|
{
|
||||||
QFile *f;
|
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, NULL,
|
||||||
|
"Toggle console output");
|
||||||
f = Qopen (path, "rb");
|
sys_sleep = Cvar_Get ("sys_sleep", "8", CVAR_NONE, NULL,
|
||||||
if (f) {
|
"Sleep how long in seconds between checking for connections. minimum is 0, maximum is 13");
|
||||||
Qclose (f);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Sys_Init (void)
|
||||||
|
{
|
||||||
|
OSVERSIONINFO vinfo;
|
||||||
|
|
||||||
|
#ifdef USE_INTEL_ASM
|
||||||
|
Sys_SetFPCW ();
|
||||||
|
#endif
|
||||||
|
// make sure the timer is high precision, otherwise
|
||||||
|
// NT gets 18ms resolution
|
||||||
|
timeBeginPeriod (1);
|
||||||
|
|
||||||
|
vinfo.dwOSVersionInfoSize = sizeof (vinfo);
|
||||||
|
|
||||||
|
if (!GetVersionEx (&vinfo))
|
||||||
|
Sys_Error ("Couldn't get OS info");
|
||||||
|
|
||||||
|
if ((vinfo.dwMajorVersion < 4) ||
|
||||||
|
(vinfo.dwPlatformId == VER_PLATFORM_WIN32s)) {
|
||||||
|
Sys_Error (PROGRAM " requires at least Win95 or NT 4.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||||
|
WinNT = true;
|
||||||
|
else
|
||||||
|
WinNT = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sys_Quit
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Sys_Quit (void)
|
||||||
|
{
|
||||||
|
//Net_LogStop();
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sys_Error
|
Sys_Error
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Sys_Error (char *error, ...)
|
Sys_Error (const char *error, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char text[1024];
|
char text[1024];
|
||||||
|
@ -89,8 +126,11 @@ Sys_Error (char *error, ...)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sys_ConsoleInput
|
Sys_ConsoleInput
|
||||||
|
|
||||||
|
Checks for a complete line of text typed in at the console, then forwards
|
||||||
|
it to the host command processor
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
Sys_ConsoleInput (void)
|
Sys_ConsoleInput (void)
|
||||||
{
|
{
|
||||||
static char text[256];
|
static char text[256];
|
||||||
|
@ -126,72 +166,11 @@ Sys_ConsoleInput (void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_Quit
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Sys_Quit (void)
|
|
||||||
{
|
|
||||||
#ifdef PACKET_LOGGING
|
|
||||||
Net_LogStop();
|
|
||||||
#endif
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_Init
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
OSVERSIONINFO vinfo;
|
|
||||||
|
|
||||||
#ifdef USE_INTEL_ASM
|
|
||||||
Sys_SetFPCW ();
|
|
||||||
#endif
|
|
||||||
// make sure the timer is high precision, otherwise
|
|
||||||
// NT gets 18ms resolution
|
|
||||||
timeBeginPeriod (1);
|
|
||||||
|
|
||||||
vinfo.dwOSVersionInfoSize = sizeof (vinfo);
|
|
||||||
|
|
||||||
if (!GetVersionEx (&vinfo))
|
|
||||||
Sys_Error ("Couldn't get OS info");
|
|
||||||
|
|
||||||
if ((vinfo.dwMajorVersion < 4) ||
|
|
||||||
(vinfo.dwPlatformId == VER_PLATFORM_WIN32s)) {
|
|
||||||
Sys_Error (PROGRAM " requires at least Win95 or NT 4.0");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
|
||||||
WinNT = true;
|
|
||||||
else
|
|
||||||
WinNT = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
main
|
main
|
||||||
*/
|
*/
|
||||||
char *newargv[256];
|
char *newargv[256];
|
||||||
|
|
||||||
#ifdef main
|
|
||||||
# if main == SDL_main
|
|
||||||
# undef main
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
/*
|
/*
|
||||||
sys_unix.c
|
sys.c
|
||||||
|
|
||||||
(description)
|
virtual filesystem functions
|
||||||
|
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
Copyright (C) 2000 Marcus Sundberg [mackan@stacken.kth.se]
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
@ -26,34 +25,48 @@
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <stdarg.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
#include <string.h>
|
# include <string.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_STRINGS_H
|
#ifdef HAVE_STRINGS_H
|
||||||
#include <strings.h>
|
# include <strings.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LIMITS_H
|
||||||
|
# include <limits.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_IO_H
|
||||||
|
# include <io.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
# include <windows.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_MMAN_H
|
||||||
|
# include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
#include "host.h"
|
|
||||||
#include "qargs.h"
|
|
||||||
#include "server.h"
|
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
||||||
|
static void Sys_StdPrintf (const char *fmt, va_list args);
|
||||||
|
|
||||||
cvar_t *sys_nostdout;
|
cvar_t *sys_nostdout;
|
||||||
|
static sys_printf_t sys_printf_function = Sys_StdPrintf;
|
||||||
|
|
||||||
/* The translation table between the graphical font and plain ASCII --KB */
|
/* The translation table between the graphical font and plain ASCII --KB */
|
||||||
static char qfont_table[256] = {
|
const char sys_char_map[256] = {
|
||||||
'\0', '#', '#', '#', '#', '.', '#', '#',
|
'\0', '#', '#', '#', '#', '.', '#', '#',
|
||||||
'#', 9, 10, '#', ' ', 13, '.', '.',
|
'#', 9, 10, '#', ' ', 13, '.', '.',
|
||||||
'[', ']', '0', '1', '2', '3', '4', '5',
|
'[', ']', '0', '1', '2', '3', '4', '5',
|
||||||
|
@ -90,13 +103,65 @@ static char qfont_table[256] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAXPRINTMSG 4096
|
#define MAXPRINTMSG 4096
|
||||||
|
|
||||||
|
void
|
||||||
|
Sys_mkdir (const char *path)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_MKDIR
|
||||||
|
# ifdef _WIN32
|
||||||
|
if (mkdir (path) == 0)
|
||||||
|
return;
|
||||||
|
# else
|
||||||
|
if (mkdir (path, 0777) == 0)
|
||||||
|
return;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# ifdef HAVE__MKDIR
|
||||||
|
if (_mkdir (path) == 0)
|
||||||
|
return;
|
||||||
|
# else
|
||||||
|
# error do not know how to make directories
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
if (errno != EEXIST)
|
||||||
|
Sys_Error ("mkdir %s: %s", path, strerror (errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Sys_FileTime (const char *path)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_ACCESS
|
||||||
|
if (access (path, R_OK) == 0)
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
# ifdef HAVE__ACCESS
|
||||||
|
if (_access (path, R_OK) == 0)
|
||||||
|
return 0;
|
||||||
|
# else
|
||||||
|
# error do not know how to check access
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sys_SetPrintf
|
||||||
|
|
||||||
|
for want of a better name, but it sets the function pointer for the
|
||||||
|
actual implementation of Sys_Printf.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Sys_SetPrintf (sys_printf_t func)
|
||||||
|
{
|
||||||
|
sys_printf_function = func;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sys_Printf
|
Sys_Printf
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
Sys_Printf (char *fmt, ...)
|
Sys_StdPrintf (const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
|
||||||
char msg[MAXPRINTMSG];
|
char msg[MAXPRINTMSG];
|
||||||
|
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
|
@ -104,64 +169,92 @@ Sys_Printf (char *fmt, ...)
|
||||||
if (sys_nostdout && sys_nostdout->int_val)
|
if (sys_nostdout && sys_nostdout->int_val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_start (argptr, fmt);
|
vsnprintf (msg, sizeof (msg), fmt, args);
|
||||||
vsnprintf (msg, sizeof (msg), fmt, argptr);
|
|
||||||
va_end (argptr);
|
|
||||||
|
|
||||||
/* translate to ASCII instead of printing [xx] --KB */
|
/* translate to ASCII instead of printing [xx] --KB */
|
||||||
for (p = (unsigned char *) msg; *p; p++)
|
for (p = (unsigned char *) msg; *p; p++)
|
||||||
putc (qfont_table[*p], stdout);
|
putc (sys_char_map[*p], stdout);
|
||||||
|
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_FileTime
|
|
||||||
|
|
||||||
returns -1 if not present
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
Sys_FileTime (char *path)
|
|
||||||
{
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
if (stat (path, &buf) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return buf.st_mtime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_mkdir
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
Sys_mkdir (char *path)
|
Sys_Printf (const char *fmt, ...)
|
||||||
{
|
{
|
||||||
if (mkdir (path, 0777) == 0)
|
va_list args;
|
||||||
return;
|
va_start (args, fmt);
|
||||||
if (errno != EEXIST)
|
sys_printf_function (fmt, args);
|
||||||
Sys_Error ("mkdir %s: %s", path, strerror (errno));
|
va_end (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sys_DoubleTime
|
Sys_DoubleTime
|
||||||
*/
|
*/
|
||||||
double
|
double
|
||||||
Sys_DoubleTime (void)
|
Sys_DoubleTime (void)
|
||||||
{
|
{
|
||||||
struct timeval tp;
|
static qboolean first = true;
|
||||||
struct timezone tzp;
|
#ifdef _WIN32
|
||||||
static int secbase;
|
static DWORD starttime;
|
||||||
|
DWORD now;
|
||||||
|
|
||||||
gettimeofday (&tp, &tzp);
|
now = timeGetTime ();
|
||||||
|
|
||||||
if (!secbase) {
|
if (first) {
|
||||||
secbase = tp.tv_sec;
|
first = false;
|
||||||
return tp.tv_usec / 1000000.0;
|
starttime = now;
|
||||||
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0;
|
if (now < starttime) // wrapped?
|
||||||
|
return (now / 1000.0) + (LONG_MAX - starttime / 1000.0);
|
||||||
|
|
||||||
|
if (now - starttime == 0)
|
||||||
|
return 0.0;
|
||||||
|
|
||||||
|
return (now - starttime) / 1000.0;
|
||||||
|
#else
|
||||||
|
struct timeval tp;
|
||||||
|
struct timezone tzp;
|
||||||
|
double now;
|
||||||
|
static double start_time;
|
||||||
|
|
||||||
|
gettimeofday (&tp, &tzp);
|
||||||
|
now = tp.tv_sec + tp.tv_usec / 1e6;
|
||||||
|
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
start_time = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
return now - start_time;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
DWORD flOldProtect;
|
||||||
|
|
||||||
|
if (!VirtualProtect
|
||||||
|
((LPVOID) startaddr, length, PAGE_READWRITE,
|
||||||
|
&flOldProtect)) Sys_Error ("Protection change failed\n");
|
||||||
|
#else
|
||||||
|
# ifdef HAVE_MPROTECT
|
||||||
|
int r;
|
||||||
|
unsigned long addr;
|
||||||
|
int psize = getpagesize ();
|
||||||
|
|
||||||
|
addr = (startaddr & ~(psize - 1)) - psize;
|
||||||
|
|
||||||
|
// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
|
||||||
|
// addr, startaddr+length, length);
|
||||||
|
|
||||||
|
r = mprotect ((char *) addr, length + startaddr - addr + psize, 7);
|
||||||
|
|
||||||
|
if (r < 0)
|
||||||
|
Sys_Error ("Protection change failed\n");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
}
|
}
|
50
source/sys_error.c
Normal file
50
source/sys_error.c
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
sys.c
|
||||||
|
|
||||||
|
virtual filesystem functions
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
|
#include "sys.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
QFutil_Sys_Error (const char *error, ...)
|
||||||
|
{
|
||||||
|
va_list argptr;
|
||||||
|
char string[1024];
|
||||||
|
|
||||||
|
va_start (argptr, error);
|
||||||
|
vsnprintf (string, sizeof (string), error, argptr);
|
||||||
|
fprintf (stderr, "Error: %s\n", string);
|
||||||
|
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sys_Error (const char *error, ...) __attribute ((weak, alias ("QFutil_Sys_Error")));
|
|
@ -1,173 +0,0 @@
|
||||||
/*
|
|
||||||
sys_null.c
|
|
||||||
|
|
||||||
null system driver to aid porting efforts
|
|
||||||
|
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to:
|
|
||||||
|
|
||||||
Free Software Foundation, Inc.
|
|
||||||
59 Temple Place - Suite 330
|
|
||||||
Boston, MA 02111-1307, USA
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
filelength
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
filelength (QFile *f)
|
|
||||||
{
|
|
||||||
int pos;
|
|
||||||
int end;
|
|
||||||
|
|
||||||
pos = Qtell (f);
|
|
||||||
Qseek (f, 0, SEEK_END);
|
|
||||||
end = Qtell (f);
|
|
||||||
Qseek (f, pos, SEEK_SET);
|
|
||||||
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
Sys_FileTime (char *path)
|
|
||||||
{
|
|
||||||
QFile *f;
|
|
||||||
|
|
||||||
f = Qopen (path, "rb");
|
|
||||||
if (f) {
|
|
||||||
Qclose (f);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Sys_mkdir (char *path)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
SYSTEM IO
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
|
||||||
Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Sys_DebugLog (char *file, char *fmt, ...)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Sys_Error (char *error, ...)
|
|
||||||
{
|
|
||||||
va_list argptr;
|
|
||||||
|
|
||||||
printf ("I_Error: ");
|
|
||||||
va_start (argptr, error);
|
|
||||||
vprintf (error, argptr);
|
|
||||||
va_end (argptr);
|
|
||||||
printf ("\n");
|
|
||||||
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Sys_Printf (char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list argptr;
|
|
||||||
|
|
||||||
va_start (argptr, fmt);
|
|
||||||
vprintf (fmt, argptr);
|
|
||||||
va_end (argptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Sys_Quit (void)
|
|
||||||
{
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
Sys_FloatTime (void)
|
|
||||||
{
|
|
||||||
static double t;
|
|
||||||
|
|
||||||
t += 0.1;
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
Sys_ConsoleInput (void)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Sys_Sleep (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
IN_SendKeyEvents (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Sys_HighFPPrecision (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Sys_LowFPPrecision (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void
|
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
host_parms.memsize = 5861376;
|
|
||||||
host_parms.membase = malloc (host_parms.memsize);
|
|
||||||
|
|
||||||
COM_InitArgv (argc, argv);
|
|
||||||
|
|
||||||
host_parms.argc = com_argc;
|
|
||||||
host_parms.argv = com_argv;
|
|
||||||
|
|
||||||
printf ("Host_Init\n");
|
|
||||||
Host_Init ();
|
|
||||||
while (1) {
|
|
||||||
Host_Frame (0.1);
|
|
||||||
}
|
|
||||||
}
|
|
138
source/sys_win.c
138
source/sys_win.c
|
@ -1,138 +0,0 @@
|
||||||
/*
|
|
||||||
sys_win.c
|
|
||||||
|
|
||||||
(description)
|
|
||||||
|
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to:
|
|
||||||
|
|
||||||
Free Software Foundation, Inc.
|
|
||||||
59 Temple Place - Suite 330
|
|
||||||
Boston, MA 02111-1307, USA
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
#include <direct.h>
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include "server.h"
|
|
||||||
|
|
||||||
cvar_t *sys_nostdout;
|
|
||||||
|
|
||||||
/* The translation table between the graphical font and plain ASCII --KB */
|
|
||||||
static char qfont_table[256] = {
|
|
||||||
'\0', '#', '#', '#', '#', '.', '#', '#',
|
|
||||||
'#', 9, 10, '#', ' ', 13, '.', '.',
|
|
||||||
'[', ']', '0', '1', '2', '3', '4', '5',
|
|
||||||
'6', '7', '8', '9', '.', '<', '=', '>',
|
|
||||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
|
||||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
|
||||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
|
||||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
|
||||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
|
||||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
|
||||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
|
||||||
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
|
||||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
|
||||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
|
||||||
'x', 'y', 'z', '{', '|', '}', '~', '<',
|
|
||||||
|
|
||||||
'<', '=', '>', '#', '#', '.', '#', '#',
|
|
||||||
'#', '#', ' ', '#', ' ', '>', '.', '.',
|
|
||||||
'[', ']', '0', '1', '2', '3', '4', '5',
|
|
||||||
'6', '7', '8', '9', '.', '<', '=', '>',
|
|
||||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
|
||||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
|
||||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
|
||||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
|
||||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
|
||||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
|
||||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
|
||||||
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
|
||||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
|
||||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
|
||||||
'x', 'y', 'z', '{', '|', '}', '~', '<'
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_DoubleTime
|
|
||||||
*/
|
|
||||||
double
|
|
||||||
Sys_DoubleTime (void)
|
|
||||||
{
|
|
||||||
static DWORD starttime;
|
|
||||||
static qboolean first = true;
|
|
||||||
DWORD now;
|
|
||||||
|
|
||||||
now = timeGetTime ();
|
|
||||||
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
starttime = now;
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (now < starttime) // wrapped?
|
|
||||||
return (now / 1000.0) + (LONG_MAX - starttime / 1000.0);
|
|
||||||
|
|
||||||
if (now - starttime == 0)
|
|
||||||
return 0.0;
|
|
||||||
|
|
||||||
return (now - starttime) / 1000.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MAXPRINTMSG 4096
|
|
||||||
/*
|
|
||||||
Sys_Printf
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Sys_Printf (char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list argptr;
|
|
||||||
char msg[MAXPRINTMSG];
|
|
||||||
|
|
||||||
unsigned char *p;
|
|
||||||
|
|
||||||
if (sys_nostdout && sys_nostdout->int_val)
|
|
||||||
return;
|
|
||||||
|
|
||||||
va_start (argptr, fmt);
|
|
||||||
vsnprintf (msg, sizeof (msg), fmt, argptr);
|
|
||||||
va_end (argptr);
|
|
||||||
|
|
||||||
/* translate to ASCII instead of printing [xx] --KB */
|
|
||||||
for (p = (unsigned char *) msg; *p; p++)
|
|
||||||
putc (qfont_table[*p], stdout);
|
|
||||||
|
|
||||||
fflush (stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sys_mkdir
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Sys_mkdir (char *path)
|
|
||||||
{
|
|
||||||
_mkdir (path);
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue