More header fixes, whitespace cleanups.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-08-27 21:00:37 +00:00
parent 9a678a5e63
commit 500b5c09d3
3 changed files with 85 additions and 124 deletions

View File

@ -29,38 +29,41 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#ifdef HAVE_STRING_H
#include <stdio.h> # include <string.h>
#include <stdlib.h> #endif
#include <errno.h> #ifdef HAVE_STRINGS_H
#include <fcntl.h> # include <strings.h>
#include <limits.h>
#ifdef HAVE_IO_H
# include <io.h>
#endif #endif
#ifdef HAVE_CONIO_H #ifdef HAVE_CONIO_H
# include <conio.h> # include <conio.h>
#endif #endif
#ifdef HAVE_IO_H
# include <io.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifndef _WIN32 #ifndef _WIN32
# include <unistd.h>
# include <stdarg.h> # include <stdarg.h>
# include <string.h>
# include <ctype.h> # include <ctype.h>
# include <fcntl.h>
# include <signal.h> # include <signal.h>
# include <limits.h>
# include <sys/types.h> # include <sys/types.h>
# include <sys/mman.h> # include <sys/mman.h>
#endif #endif
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <SDL.h> #include <SDL.h>
#include <SDL_main.h> #include <SDL_main.h>
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/qargs.h"
#include "client.h" #include "client.h"
#include "compat.h" #include "compat.h"
@ -74,8 +77,7 @@ 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
@ -110,8 +112,7 @@ Sys_Init (void)
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
// make sure the timer is high precision, otherwise // make sure the timer is high precision, otherwise NT gets 18ms resolution
// NT gets 18ms resolution
timeBeginPeriod (1); timeBeginPeriod (1);
vinfo.dwOSVersionInfoSize = sizeof (vinfo); vinfo.dwOSVersionInfoSize = sizeof (vinfo);
@ -127,9 +128,6 @@ Sys_Init (void)
#endif #endif
} }
/*
Sys_Quit
*/
void void
Sys_Quit (void) Sys_Quit (void)
{ {
@ -137,15 +135,11 @@ Sys_Quit (void)
exit (0); exit (0);
} }
/*
Sys_Error
*/
void void
Sys_Error (const char *error, ...) Sys_Error (const char *error, ...)
{ {
va_list argptr;
char text[1024]; char text[1024];
va_list argptr;
#ifndef _WIN32 #ifndef _WIN32
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK); fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
@ -180,7 +174,6 @@ Sys_DebugLog (const char *file, const char *fmt, ...)
close (fd); close (fd);
}; };
/* /*
Sys_ConsoleInput Sys_ConsoleInput
@ -193,39 +186,32 @@ 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)
{ {
} }
#endif #endif
void void
Sys_Sleep (void) Sys_Sleep (void)
{ {
} }
#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;
int j; int j;
double time, oldtime, newtime;
#ifndef WIN32 #ifndef WIN32
signal (SIGFPE, SIG_IGN); signal (SIGFPE, SIG_IGN);

View File

@ -30,19 +30,26 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <signal.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/types.h>
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/qargs.h" #include "QF/qargs.h"
@ -79,9 +86,6 @@ Sys_Init (void)
#endif #endif
} }
/*
Sys_Quit
*/
void void
Sys_Quit (void) Sys_Quit (void)
{ {
@ -93,16 +97,13 @@ Sys_Quit (void)
exit (0); exit (0);
} }
/*
Sys_Error
*/
void void
Sys_Error (const char *error, ...) Sys_Error (const char *error, ...)
{ {
va_list argptr;
char string[1024]; char string[1024];
va_list argptr;
// change stdin to non blocking // change stdin to non blocking
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK); fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
va_start (argptr, error); va_start (argptr, error);
@ -142,7 +143,6 @@ Sys_DebugLog (const char *file, const char *fmt, ...)
close (fd); close (fd);
} }
void void
floating_point_exception_handler (int whatever) floating_point_exception_handler (int whatever)
{ {
@ -150,7 +150,6 @@ floating_point_exception_handler (int whatever)
signal (SIGFPE, floating_point_exception_handler); signal (SIGFPE, floating_point_exception_handler);
} }
/* /*
Sys_ConsoleInput Sys_ConsoleInput
@ -176,14 +175,12 @@ 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)
{ {
@ -192,14 +189,11 @@ Sys_LowFPPrecision (void)
int skipframes; int skipframes;
/*
main
*/
int int
main (int c, const char *v[]) main (int c, const char *v[])
{ {
double time, oldtime, newtime;
int j; int j;
double time, oldtime, newtime;
// static char cwd[1024]; // static char cwd[1024];

View File

@ -29,13 +29,17 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#ifdef HAVE_CONIO_H
# include <conio.h>
#endif
#ifdef HAVE_IO_H
# include <io.h>
#endif
#include <stdio.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <io.h> #include <stdio.h>
#include <conio.h>
#include <windows.h> #include <windows.h>
#include "QF/console.h" #include "QF/console.h"
@ -52,35 +56,32 @@
#include "net.h" #include "net.h"
#include "resource.h" #include "resource.h"
qboolean is_server = false;
char *svs_info;
#define MINIMUM_WIN_MEMORY 0x0c00000
#define MAXIMUM_WIN_MEMORY 0x1000000 #define MAXIMUM_WIN_MEMORY 0x1000000
#define MINIMUM_WIN_MEMORY 0x0c00000
#define PAUSE_SLEEP 50 // sleep time on pause or #define PAUSE_SLEEP 50 // sleep time on pause or
// minimization // minimization
#define NOT_FOCUS_SLEEP 20 // sleep time when not focus #define NOT_FOCUS_SLEEP 20 // sleep time when not focus
char *svs_info;
int starttime; int starttime;
qboolean ActiveApp, Minimized;
qboolean WinNT; qboolean ActiveApp, Minimized, WinNT;
qboolean is_server = false;
HWND hwnd_dialog; // startup dialog box HWND hwnd_dialog; // startup dialog box
static HANDLE hinput, houtput;
HANDLE qwclsemaphore; HANDLE qwclsemaphore;
static HANDLE tevent; static HANDLE hinput, houtput, tevent;
extern cvar_t *sys_nostdout; extern cvar_t *sys_nostdout;
void Sys_InitFloatTime (void);
void MaskExceptions (void); void MaskExceptions (void);
void Sys_PopFPCW (void); void Sys_PopFPCW (void);
void Sys_PushFPCW_SetHigh (void); void Sys_PushFPCW_SetHigh (void);
void Sys_InitFloatTime (void);
/* /*
@ -92,8 +93,8 @@ void Sys_PushFPCW_SetHigh (void);
void void
Sys_Init_Cvars (void) Sys_Init_Cvars (void)
{ {
sys_nostdout = Cvar_Get ("sys_nostdout", "1", CVAR_NONE, NULL, sys_nostdout = Cvar_Get ("sys_nostdout", "1", CVAR_NONE, NULL, "unset to "
"unset to enable std out - windows does NOT support this"); "enable std out - windows does NOT support this");
} }
void void
@ -101,8 +102,7 @@ Sys_Init (void)
{ {
OSVERSIONINFO vinfo; OSVERSIONINFO vinfo;
// allocate a named semaphore on the client so the // allocate named semaphore on client so front end can tell if it's alive
// front end can tell if it is alive
// mutex will fail if semephore allready exists // mutex will fail if semephore allready exists
qwclsemaphore = CreateMutex (NULL, /* Security attributes */ qwclsemaphore = CreateMutex (NULL, /* Security attributes */
@ -122,8 +122,7 @@ Sys_Init (void)
Sys_SetFPCW (); Sys_SetFPCW ();
#endif #endif
// make sure the timer is high precision, otherwise // make sure the timer is high precision, otherwise NT gets 18ms resolution
// NT gets 18ms resolution
timeBeginPeriod (1); timeBeginPeriod (1);
vinfo.dwOSVersionInfoSize = sizeof (vinfo); vinfo.dwOSVersionInfoSize = sizeof (vinfo);
@ -143,9 +142,6 @@ Sys_Init (void)
WinNT = false; WinNT = false;
} }
/*
Sys_Quit
*/
void void
Sys_Quit (void) Sys_Quit (void)
{ {
@ -164,15 +160,11 @@ Sys_Quit (void)
exit (0); exit (0);
} }
/*
Sys_Error
*/
void void
Sys_Error (const char *error, ...) Sys_Error (const char *error, ...)
{ {
va_list argptr;
char text[1024]; // , text2[1024]; char text[1024]; // , text2[1024];
va_list argptr;
// DWORD dummy; // DWORD dummy;
Host_Shutdown (); Host_Shutdown ();
@ -191,9 +183,9 @@ Sys_Error (const char *error, ...)
void void
Sys_DebugLog (const char *file, const char *fmt, ...) Sys_DebugLog (const char *file, const char *fmt, ...)
{ {
va_list argptr;
static char data[1024]; static char data[1024];
int fd; int fd;
va_list argptr;
va_start (argptr, fmt); va_start (argptr, fmt);
vsnprintf (data, sizeof (data), fmt, argptr); vsnprintf (data, sizeof (data), fmt, argptr);
@ -203,12 +195,10 @@ Sys_DebugLog (const char *file, const char *fmt, ...)
close (fd); close (fd);
}; };
int int
wfilelength (VFile *f) wfilelength (VFile *f)
{ {
int pos; int end, pos;
int end;
pos = Qtell (f); pos = Qtell (f);
Qseek (f, 0, SEEK_END); Qseek (f, 0, SEEK_END);
@ -227,16 +217,13 @@ wfilelength (VFile *f)
const char * const char *
Sys_ConsoleInput (void) Sys_ConsoleInput (void)
{ {
char *clipText, *textCopied;
int ch, i; // , count;
static char text[256]; static char text[256];
static int len; static int len;
INPUT_RECORD recs[1024]; INPUT_RECORD recs[1024];
// int count;
int i;
int ch;
DWORD numread, numevents, dummy; DWORD numread, numevents, dummy;
HANDLE th; HANDLE th;
char *clipText, *textCopied;
for (;;) { for (;;) {
if (!GetNumberOfConsoleInputEvents (hinput, &numevents)) if (!GetNumberOfConsoleInputEvents (hinput, &numevents))
@ -296,7 +283,7 @@ Sys_ConsoleInput (void)
textCopied = textCopied =
malloc (GlobalSize (th) + 1); malloc (GlobalSize (th) + 1);
strcpy (textCopied, clipText); strcpy (textCopied, clipText);
/* Substitutes a NULL for every token */ // Substitutes a NULL for every token
strtok (textCopied, "\n\r\b"); strtok (textCopied, "\n\r\b");
i = strlen (textCopied); i = strlen (textCopied);
if (i + len >= 256) if (i + len >= 256)
@ -344,25 +331,20 @@ SleepUntilInput (int time)
MsgWaitForMultipleObjects (1, &tevent, FALSE, time, QS_ALLINPUT); MsgWaitForMultipleObjects (1, &tevent, FALSE, time, QS_ALLINPUT);
} }
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;
MEMORYSTATUS lpBuffer;
static char cwd[1024]; static char cwd[1024];
int t; int t;
double time, oldtime, newtime;
MEMORYSTATUS lpBuffer;
#ifdef SPLASH_SCREEN #ifdef SPLASH_SCREEN
RECT rect; RECT rect;
#endif #endif
@ -412,8 +394,8 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
host_parms.argv = com_argv; host_parms.argv = com_argv;
#ifdef SPLASH_SCREEN #ifdef SPLASH_SCREEN
hwnd_dialog = hwnd_dialog = CreateDialog (hInstance, MAKEINTRESOURCE (IDD_DIALOG1),
CreateDialog (hInstance, MAKEINTRESOURCE (IDD_DIALOG1), NULL, NULL); NULL, NULL);
if (hwnd_dialog) { if (hwnd_dialog) {
if (GetWindowRect (hwnd_dialog, &rect)) { if (GetWindowRect (hwnd_dialog, &rect)) {
@ -430,9 +412,9 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
} }
#endif #endif
// take the greater of all the available memory or half the total memory, // take the greater of all the available memory or half the total memory,
// but at least 8 Mb and no more than 16 Mb, unless they explicitly // but at least 8 Mb and no more than 16 Mb, unless they explicitly
// request otherwise // request otherwise
host_parms.memsize = lpBuffer.dwAvailPhys; host_parms.memsize = lpBuffer.dwAvailPhys;
if (host_parms.memsize < MINIMUM_WIN_MEMORY) if (host_parms.memsize < MINIMUM_WIN_MEMORY)
@ -462,7 +444,7 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
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
//XXX S_BlockSound (); // XXX S_BlockSound ();
Sys_Printf ("Host_Init\n"); Sys_Printf ("Host_Init\n");
Host_Init (); Host_Init ();
@ -471,8 +453,7 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
/* main window message loop */ /* main window message loop */
while (1) { while (1) {
// yield the CPU for a little while when paused, minimized, or not // yield CPU for a little bit when paused, minimized, or not the focus
// the focus
if ((cl.paused && (!ActiveApp && !DDActive)) || Minimized if ((cl.paused && (!ActiveApp && !DDActive)) || Minimized
|| block_drawing) { || block_drawing) {
SleepUntilInput (PAUSE_SLEEP); SleepUntilInput (PAUSE_SLEEP);