shithub: qk1

Download patch

ref: 42c95cd58ab07b80d1af936b55b3ed663cc01b8f
parent: 2feac9be1d1bebe1a05a47c0adf0254228ca558d
author: qwx <qwx@sciops.net>
date: Sat Jan 6 11:32:50 EST 2024

fix qwsv/qwcl build

--- a/qw/cd.c
+++ b/qw/cd.c
@@ -1,9 +1,6 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
+#include "quakedef.h"
 #include <thread.h>
 #include <regexp.h>
-#include "quakedef.h"
 
 cvar_t bgmvolume = {"bgmvolume", "1", 1};
 
--- a/qw/cl_cam.c
+++ b/qw/cl_cam.c
@@ -4,9 +4,6 @@
  * Player moves as a spectator, but the camera tracks and enemy player
  */
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define	PM_SPECTATORMAXSPEED	500
@@ -17,7 +14,7 @@
 #define MAX_ANGLE_TURN 10
 
 static vec3_t desired_position; // where the camera wants to be
-static qboolean locked = false;
+static bool locked = false;
 static int oldbuttons;
 
 // track high fragger
@@ -28,7 +25,7 @@
 //cvar_t cl_camera_maxpitch = {"cl_camera_maxpitch", "10" };
 //cvar_t cl_camera_maxyaw = {"cl_camera_maxyaw", "30" };
 
-qboolean cam_forceview;
+bool cam_forceview;
 vec3_t cam_viewangles;
 double cam_lastviewtime;
 
@@ -71,7 +68,7 @@
 }
 
 // returns true if weapon model should be drawn in camera mode
-qboolean Cam_DrawViewModel(void)
+bool Cam_DrawViewModel(void)
 {
 	if (!cl.spectator)
 		return true;
@@ -82,7 +79,7 @@
 }
 
 // returns true if we should draw this player, we don't if we are chase camming
-qboolean Cam_DrawPlayer(int playernum)
+bool Cam_DrawPlayer(int playernum)
 {
 	if (cl.spectator && autocam && locked && cl_chasecam.value && 
 		spec_track == playernum)
@@ -129,7 +126,7 @@
 }
 	
 // Returns distance or 9999 if invalid for some reason
-static float Cam_TryFlyby(player_state_t *self, player_state_t *player, vec3_t vec, qboolean checkvis)
+static float Cam_TryFlyby(player_state_t *self, player_state_t *player, vec3_t vec, bool checkvis)
 {
 	vec3_t v;
 	pmtrace_t trace;
@@ -162,7 +159,7 @@
 }
 
 // Is player visible?
-static qboolean Cam_IsVisible(player_state_t *player, vec3_t vec)
+static bool Cam_IsVisible(player_state_t *player, vec3_t vec)
 {
 	pmtrace_t trace;
 	vec3_t v;
@@ -179,7 +176,7 @@
 	return true;
 }
 
-static qboolean InitFlyby(player_state_t *self, player_state_t *player, int checkvis) 
+static bool InitFlyby(player_state_t *self, player_state_t *player, int checkvis) 
 {
     float f, max;
     vec3_t vec, vec2;
--- a/qw/cl_demo.c
+++ b/qw/cl_demo.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 void CL_FinishTimeDemo (void);
@@ -123,7 +120,7 @@
   FIXME...
 ====================
 */
-qboolean CL_GetDemoMessage (void)
+bool CL_GetDemoMessage (void)
 {
 	int		r, i, j;
 	float	f;
@@ -239,7 +236,7 @@
 Handles recording and playback of demos, on top of NET_ code
 ====================
 */
-qboolean CL_GetMessage (void)
+bool CL_GetMessage (void)
 {
 	if	(cls.demoplayback)
 		return CL_GetDemoMessage ();
--- a/qw/cl_ents.c
+++ b/qw/cl_ents.c
@@ -1,8 +1,5 @@
 // cl_ents.c -- entity parsing and management
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 extern	cvar_t	cl_predict_players;
@@ -11,7 +8,7 @@
 
 static struct predicted_player {
 	int flags;
-	qboolean active;
+	bool active;
 	vec3_t origin;	// predicted origin
 } predicted_players[MAX_CLIENTS];
 
@@ -246,13 +243,13 @@
 rest of the data stream.
 ==================
 */
-void CL_ParsePacketEntities (qboolean delta)
+void CL_ParsePacketEntities (bool delta)
 {
 	int			oldpacket, newpacket;
 	packet_entities_t	*oldp, *newp, dummy;
 	int			oldindex, newindex;
 	int			word, newnum, oldnum;
-	qboolean	full;
+	bool	full;
 	byte		from;
 
 	newpacket = cls.netchan.incoming_sequence&UPDATE_MASK;
@@ -922,7 +919,7 @@
 This sets up the first phase.
 ===
 */
-void CL_SetUpPlayerPrediction(qboolean dopred)
+void CL_SetUpPlayerPrediction(bool dopred)
 {
 	int				j;
 	player_state_t	*state;
--- a/qw/cl_input.c
+++ b/qw/cl_input.c
@@ -1,8 +1,5 @@
 // cl.input.c  -- builds an intended movement command to send to the server
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 cvar_t	cl_nodelta = {"cl_nodelta","0"};
@@ -154,7 +151,7 @@
 float CL_KeyState (kbutton_t *key)
 {
 	float		val;
-	qboolean	impulsedown, impulseup, down;
+	bool	impulsedown, impulseup, down;
 	
 	impulsedown = key->state & 2;
 	impulseup = key->state & 4;
--- a/qw/cl_main.c
+++ b/qw/cl_main.c
@@ -1,9 +1,5 @@
 // cl_main.c  -- client main loop
 
-#include <u.h>
-#include <libc.h>
-#include <ctype.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 enum{
@@ -13,7 +9,7 @@
 // we need to declare some mouse variables here, because the menu system
 // references them even when on a unix system.
 
-qboolean	noclip_anglehack;		// remnant from old quake
+bool	noclip_anglehack;		// remnant from old quake
 
 
 cvar_t	rcon_password = {"rcon_password", "", false};
@@ -44,7 +40,7 @@
 
 cvar_t  localid = {"localid", ""};
 
-static qboolean allowremotecmd = true;
+static bool allowremotecmd = true;
 
 //
 // info mirrors
@@ -83,8 +79,8 @@
 
 quakeparms_t host_parms;
 
-qboolean	host_initialized;		// true if into command execution
-qboolean	nomaster;
+bool	host_initialized;		// true if into command execution
+bool	nomaster;
 
 double		host_frametime;
 double		realtime;				// without any filtering or bounding
@@ -1137,7 +1133,7 @@
 {
 	va_list		argptr;
 	char		string[1024];
-	static	qboolean inerror = false;
+	static	bool inerror = false;
 	
 	if (inerror)
 		Sys_Error ("Host_Error: recursively entered");
@@ -1391,7 +1387,7 @@
 */
 void Host_Shutdown(void)
 {
-	static qboolean isdown = false;
+	static bool isdown = false;
 	
 	if (isdown)
 	{
--- a/qw/cl_parse.c
+++ b/qw/cl_parse.c
@@ -1,8 +1,5 @@
 // cl_parse.c  -- parse a message received from the server
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 char *svc_strings[] =
@@ -136,7 +133,7 @@
 to start a download from the server.
 ===============
 */
-qboolean	CL_CheckOrDownloadFile (char *filename)
+bool	CL_CheckOrDownloadFile (char *filename)
 {
 	FILE	*f;
 
@@ -490,7 +487,7 @@
 	CL_NextUpload();
 } 
 
-qboolean CL_IsUploading(void)
+bool CL_IsUploading(void)
 {
 	if (upload_data)
 		return true;
@@ -522,7 +519,7 @@
 	char	*str;
 	FILE	*f;
 	char	fn[MAX_OSPATH];
-	qboolean	cflag = false;
+	bool	cflag = false;
 	extern	char	gamedirfile[MAX_OSPATH];
 	int protover;
 	
--- a/qw/cl_pred.c
+++ b/qw/cl_pred.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 cvar_t	cl_nopred = {"cl_nopred","0"};
@@ -44,7 +41,7 @@
 CL_PredictUsercmd
 ==============
 */
-void CL_PredictUsercmd (player_state_t *from, player_state_t *to, usercmd_t *u, qboolean spectator)
+void CL_PredictUsercmd (player_state_t *from, player_state_t *to, usercmd_t *u, bool spectator)
 {
 	// split up very long moves
 	if (u->msec > 50)
--- a/qw/cl_tent.c
+++ b/qw/cl_tent.c
@@ -1,8 +1,5 @@
 // cl_tent.c -- client side temporary entities
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 
--- a/qw/client.h
+++ b/qw/client.h
@@ -1,7 +1,7 @@
 typedef struct
 {
 	char		name[16];
-	qboolean	failedload;		// the name isn't a valid skin
+	bool	failedload;		// the name isn't a valid skin
 	cache_user_t	cache;
 } skin_t;
 
@@ -71,7 +71,7 @@
 	player_state_t	playerstate[MAX_CLIENTS];	// message received that reflects performing
 							// the usercmd
 	packet_entities_t	packet_entities;
-	qboolean	invalid;		// true if the packet_entities delta was invalid
+	bool	invalid;		// true if the packet_entities delta was invalid
 } frame_t;
 
 
@@ -165,9 +165,9 @@
 
 // demo recording info must be here, because record is started before
 // entering a map (and clearing client_state_t)
-	qboolean	demorecording;
-	qboolean	demoplayback;
-	qboolean	timedemo;
+	bool	demorecording;
+	bool	demoplayback;
+	bool	timedemo;
 	FILE		*demofile;
 	float		td_lastframe;		// to meter out one message a frame
 	int			td_startframe;		// host_framecount at start
@@ -229,7 +229,7 @@
 
 // pitch drifting vars
 	float		pitchvel;
-	qboolean	nodrift;
+	bool	nodrift;
 	float		driftmove;
 	double		laststop;
 
@@ -236,7 +236,7 @@
 
 	float		crouch;			// local amount for smoothing stepups
 
-	qboolean	paused;			// send over by server
+	bool	paused;			// send over by server
 
 	float		punchangle;		// temporar yview kick from weapon firing
 	
@@ -315,7 +315,7 @@
 extern	lightstyle_t	cl_lightstyle[MAX_LIGHTSTYLES];
 extern	dlight_t		cl_dlights[MAX_DLIGHTS];
 
-extern	qboolean	nomaster;
+extern	bool	nomaster;
 extern float	server_version;	// version of server we connected to
 
 //=============================================================================
@@ -335,7 +335,7 @@
 void CL_Disconnect (void);
 void CL_Disconnect_f (void);
 void CL_NextDemo (void);
-qboolean CL_DemoBehind(void);
+bool CL_DemoBehind(void);
 
 void CL_BeginServerConnect(void);
 
@@ -382,7 +382,7 @@
 // cl_demo.c
 //
 void CL_StopPlayback (void);
-qboolean CL_GetMessage (void);
+bool CL_GetMessage (void);
 void CL_WriteDemoCmd (usercmd_t *pcmd);
 
 void CL_Stop_f (void);
@@ -400,8 +400,8 @@
 int CL_CalcNet (void);
 void CL_ParseServerMessage (void);
 void CL_NewTranslation (int slot);
-qboolean	CL_CheckOrDownloadFile (char *filename);
-qboolean CL_IsUploading(void);
+bool	CL_CheckOrDownloadFile (char *filename);
+bool CL_IsUploading(void);
 void CL_NextUpload(void);
 void CL_StartUpload (byte *data, int size);
 void CL_StopUpload(void);
@@ -430,11 +430,11 @@
 // cl_ents.c
 //
 void CL_SetSolidPlayers (int playernum);
-void CL_SetUpPlayerPrediction(qboolean dopred);
+void CL_SetUpPlayerPrediction(bool dopred);
 void CL_EmitEntities (void);
 void CL_ClearProjectiles (void);
 void CL_ParseProjectiles (void);
-void CL_ParsePacketEntities (qboolean delta);
+void CL_ParsePacketEntities (bool delta);
 void CL_SetSolidEntities (void);
 void CL_ParsePlayerinfo (void);
 
@@ -443,7 +443,7 @@
 //
 void CL_InitPrediction (void);
 void CL_PredictMove (void);
-void CL_PredictUsercmd (player_state_t *from, player_state_t *to, usercmd_t *u, qboolean spectator);
+void CL_PredictUsercmd (player_state_t *from, player_state_t *to, usercmd_t *u, bool spectator);
 
 //
 // cl_cam.c
@@ -454,8 +454,8 @@
 extern	int		autocam;
 extern int spec_track; // player# of who we are tracking
 
-qboolean Cam_DrawViewModel(void);
-qboolean Cam_DrawPlayer(int playernum);
+bool Cam_DrawViewModel(void);
+bool Cam_DrawPlayer(int playernum);
 void Cam_Track(usercmd_t *cmd);
 void Cam_FinishMove(usercmd_t *cmd);
 void Cam_Reset(void);
--- a/qw/cmd.c
+++ b/qw/cmd.c
@@ -1,8 +1,5 @@
 // cmd.c -- Quake script command processing module
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 void Cmd_ForwardToServer (void);
@@ -18,7 +15,7 @@
 
 cmdalias_t	*cmd_alias;
 
-qboolean	cmd_wait;
+bool	cmd_wait;
 
 cvar_t cl_warncmd = {"cl_warncmd", "0"};
 
@@ -526,7 +523,7 @@
 Cmd_Exists
 ============
 */
-qboolean	Cmd_Exists (char *cmd_name)
+bool	Cmd_Exists (char *cmd_name)
 {
 	cmd_function_t	*cmd;
 
--- a/qw/cmd.h
+++ b/qw/cmd.h
@@ -53,7 +53,7 @@
 // if function is NULL, the command will be forwarded to the server
 // as a clc_stringcmd instead of executed locally
 
-qboolean Cmd_Exists (char *cmd_name);
+bool Cmd_Exists (char *cmd_name);
 // used by the cvar code to check for cvar / command name overlap
 
 char 	*Cmd_CompleteCommand (char *partial);
--- a/qw/common.c
+++ b/qw/common.c
@@ -1,8 +1,5 @@
 // common.c -- misc functions used in client and server
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 cvar_t sv_highchars = {"sv_highchars", "1"};
@@ -19,11 +16,11 @@
 
 cvar_t	registered = {"registered","0"};
 
-qboolean	com_modified;	// set true if using non-id files
+bool	com_modified;	// set true if using non-id files
 
 int		static_registered = 1;	// only for startup check, then set
 
-qboolean		msg_suppress_1 = 0;
+bool		msg_suppress_1 = 0;
 
 void COM_InitFilesystem (void);
 void COM_Path_f (void);
@@ -33,7 +30,7 @@
 #define	PAK0_COUNT		339
 #define	PAK0_CRC		52883
 
-qboolean		standard_quake = true, rogue, hipnotic;
+bool		standard_quake = true, rogue, hipnotic;
 
 char	gamedirfile[MAX_OSPATH];
 
@@ -252,7 +249,7 @@
 ============================================================================
 */
 
-qboolean	bigendien;
+bool	bigendien;
 
 short	(*BigShort) (short l);
 short	(*LittleShort) (short l);
@@ -470,7 +467,7 @@
 // reading functions
 //
 int			msg_readcount;
-qboolean	msg_badread;
+bool	msg_badread;
 
 void MSG_BeginReading (void)
 {
@@ -968,7 +965,7 @@
 */
 void COM_InitArgv (int argc, char **argv)
 {
-	qboolean	safe;
+	bool	safe;
 	int			i;
 
 	safe = false;
--- a/qw/common.h
+++ b/qw/common.h
@@ -3,8 +3,6 @@
 typedef unsigned char 		byte;
 #define _DEF_BYTE_
 
-typedef enum {false, true}	qboolean;
-
 #define	MAX_INFO_STRING	196
 #define	MAX_SERVERINFO_STRING	512
 #define	MAX_LOCALINFO_STRING	32768
@@ -13,8 +11,8 @@
 
 typedef struct sizebuf_s
 {
-	qboolean	allowoverflow;	// if false, do a Sys_Error
-	qboolean	overflowed;		// set to true if the buffer size failed
+	bool	allowoverflow;	// if false, do a Sys_Error
+	bool	overflowed;		// set to true if the buffer size failed
 	byte	*data;
 	int		maxsize;
 	int		cursize;
@@ -63,7 +61,7 @@
 
 //============================================================================
 
-extern	qboolean		bigendien;
+extern	bool		bigendien;
 
 extern	short	(*BigShort) (short l);
 extern	short	(*LittleShort) (short l);
@@ -90,7 +88,7 @@
 void MSG_WriteDeltaUsercmd (sizebuf_t *sb, struct usercmd_s *from, struct usercmd_s *cmd);
 
 extern	int			msg_readcount;
-extern	qboolean	msg_badread;		// set if a read goes beyond end of message
+extern	bool	msg_badread;		// set if a read goes beyond end of message
 
 void MSG_BeginReading (void);
 int MSG_GetReadCount(void);
@@ -115,7 +113,7 @@
 //============================================================================
 
 extern	char		com_token[1024];
-extern	qboolean	com_eof;
+extern	bool	com_eof;
 
 char *COM_Parse (char *data);
 
@@ -157,7 +155,7 @@
 void COM_Gamedir (char *dir);
 
 extern	struct cvar_s	registered;
-extern qboolean		standard_quake, rogue, hipnotic;
+extern bool		standard_quake, rogue, hipnotic;
 
 char *Info_ValueForKey (char *s, char *key);
 void Info_RemoveKey (char *s, char *key);
--- a/qw/console.c
+++ b/qw/console.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 int			con_ormask;
@@ -29,7 +26,7 @@
 extern	int		key_linepos;
 		
 
-qboolean	con_initialized;
+bool	con_initialized;
 
 
 void Key_ClearTyping (void)
@@ -336,7 +333,7 @@
 {
 	va_list		argptr;
 	char		msg[MAXPRINTMSG];
-	static qboolean	inupdate;
+	static bool	inupdate;
 	
 	va_start (argptr,fmt);
 	vsprintf (msg,fmt,argptr);
--- a/qw/console.h
+++ b/qw/console.h
@@ -14,7 +14,7 @@
 extern	int			con_ormask;
 
 extern int con_totallines;
-extern qboolean con_initialized;
+extern bool con_initialized;
 extern byte *con_chars;
 extern	int	con_notifylines;		// scan lines to clear for notify lines
 
--- a/qw/crc.c
+++ b/qw/crc.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 // this is a 16 bit, non-reflected CRC using the polynomial 0x1021
--- a/qw/cvar.c
+++ b/qw/cvar.c
@@ -1,8 +1,5 @@
 // cvar.c -- dynamic variable tracking
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 cvar_t	*cvar_vars;
@@ -180,7 +177,7 @@
 Handles variable inspection and changing from the console
 ============
 */
-qboolean	Cvar_Command (void)
+bool	Cvar_Command (void)
 {
 	cvar_t			*v;
 
--- a/qw/cvar.h
+++ b/qw/cvar.h
@@ -36,8 +36,8 @@
 {
 	char	*name;
 	char	*string;
-	qboolean archive;		// set to true to cause it to be saved to vars.rc
-	qboolean info;			// added to serverinfo or userinfo when changed
+	bool archive;		// set to true to cause it to be saved to vars.rc
+	bool info;			// added to serverinfo or userinfo when changed
 	float	value;
 	struct cvar_s *next;
 } cvar_t;
@@ -62,7 +62,7 @@
 // attempts to match a partial variable name for command line completion
 // returns NULL if nothing fits
 
-qboolean Cvar_Command (void);
+bool Cvar_Command (void);
 // called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
 // command.  Returns true if the command was a variable reference that
 // was handled. (print or change)
--- a/qw/d_edge.c
+++ b/qw/d_edge.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 static int	miplevel;
--- a/qw/d_fill.c
+++ b/qw/d_fill.c
@@ -1,8 +1,5 @@
 // d_clear: clears a specified rectangle to the specified color
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 /*
--- a/qw/d_iface.h
+++ b/qw/d_iface.h
@@ -91,14 +91,14 @@
 extern int		d_spanpixcount;
 extern int		r_framecount;		// sequence # of current frame since Quake
 									//  started
-extern qboolean	r_drawpolys;		// 1 if driver wants clipped polygons
+extern bool	r_drawpolys;		// 1 if driver wants clipped polygons
 									//  rather than a span list
-extern qboolean	r_drawculledpolys;	// 1 if driver wants clipped polygons that
+extern bool	r_drawculledpolys;	// 1 if driver wants clipped polygons that
 									//  have been culled by the edge list
-extern qboolean	r_worldpolysbacktofront;	// 1 if driver wants polygons
+extern bool	r_worldpolysbacktofront;	// 1 if driver wants polygons
 											//  delivered back to front rather
 											//  than front to back
-extern qboolean	r_recursiveaffinetriangles;	// true if a driver wants to use
+extern bool	r_recursiveaffinetriangles;	// true if a driver wants to use
 											//  recursive triangular subdivison
 											//  and vertex drawing via
 											//  D_PolysetDrawFinalVerts() past
@@ -108,7 +108,7 @@
 extern float	r_aliasuvscale;		// scale-up factor for screen u and v
 									//  on Alias vertices passed to driver
 extern int		r_pixbytes;
-extern qboolean	r_dowarp;
+extern bool	r_dowarp;
 
 extern affinetridesc_t	r_affinetridesc;
 extern spritedesc_t		r_spritedesc;
--- a/qw/d_init.c
+++ b/qw/d_init.c
@@ -1,8 +1,5 @@
 // d_init.c: rasterization driver initialization
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define NUM_MIPS	4
@@ -11,7 +8,7 @@
 cvar_t	d_mipscale = {"d_mipscale", "1"};
 
 surfcache_t		*d_initial_rover;
-qboolean		d_roverwrapped;
+bool		d_roverwrapped;
 int				d_minmip;
 float			d_scalemip[NUM_MIPS-1];
 
--- a/qw/d_local.h
+++ b/qw/d_local.h
@@ -37,7 +37,7 @@
 
 extern float	scale_for_mip;
 
-extern qboolean		d_roverwrapped;
+extern bool		d_roverwrapped;
 extern surfcache_t	*sc_rover;
 extern surfcache_t	*d_initial_rover;
 
--- a/qw/d_modech.c
+++ b/qw/d_modech.c
@@ -1,8 +1,5 @@
 // d_modech.c: called when mode has just changed
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 int	d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
--- a/qw/d_part.c
+++ b/qw/d_part.c
@@ -1,8 +1,5 @@
 // d_part.c: software driver module for drawing particles
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 
--- a/qw/d_polyse.c
+++ b/qw/d_polyse.c
@@ -1,9 +1,6 @@
 // d_polyset.c: routines for drawing sets of polygons sharing the same
 // texture (used for Alias models)
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 // TODO: put in span spilling to shrink list size
@@ -81,7 +78,7 @@
 } adivtab_t;
 
 static adivtab_t	adivtab[32*32] = {
-#include "../adivtab.h"
+#include "/adivtab.h"
 };
 
 byte	*skintable[MAX_LBM_HEIGHT];
--- a/qw/d_scan.c
+++ b/qw/d_scan.c
@@ -1,8 +1,5 @@
 // Portable C scan-level rasterization code, all pixel depths.
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 unsigned char	*r_turb_pbase, *r_turb_pdest;
--- a/qw/d_sky.c
+++ b/qw/d_sky.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define SKY_SPAN_SHIFT	5
--- a/qw/d_sprite.c
+++ b/qw/d_sprite.c
@@ -1,8 +1,5 @@
 // d_sprite.c: software top-level rasterization driver module for drawing sprites
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 static int		sprite_height;
--- a/qw/d_surf.c
+++ b/qw/d_surf.c
@@ -1,12 +1,9 @@
 // d_surf.c: rasterization driver surface heap manager
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 float           surfscale;
-qboolean        r_cache_thrash;         // set if surface cache is thrashing
+bool        r_cache_thrash;         // set if surface cache is thrashing
 
 int                                     sc_size;
 surfcache_t                     *sc_rover, *sc_base;
@@ -111,7 +108,7 @@
 surfcache_t     *D_SCAlloc (int width, int size)
 {
 	surfcache_t             *new;
-	qboolean                wrapped_this_time;
+	bool                wrapped_this_time;
 
 	if ((width < 0) || (width > 256))
 		Sys_Error ("D_SCAlloc: bad cache width %d\n", width);
--- a/qw/d_vars.c
+++ b/qw/d_vars.c
@@ -1,8 +1,5 @@
 // r_vars.c: global refresh variables
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 // all global and static refresh variables are collected in a contiguous block
--- a/qw/d_zpoint.c
+++ b/qw/d_zpoint.c
@@ -1,8 +1,5 @@
 // d_zpoint.c: software driver module for drawing z-buffered points
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 
--- a/qw/draw.c
+++ b/qw/draw.c
@@ -1,8 +1,5 @@
 // draw.c -- this is the only file outside the refresh that touches the vid buffer
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 typedef struct {
@@ -624,9 +621,9 @@
 Fills a box of pixels with a single color
 =============
 */
-void Draw_Fill (int x, int y, int w, int h, int c)
+void Draw_Fill (int x, int y, int w, int h, pixel_t c)
 {
-	byte			*dest;
+	pixel_t			*dest;
 	int				u, v;
 
 	if (x < 0 || x + w > vid.width ||
@@ -635,9 +632,8 @@
 			x, y, w, h, c);
 		return;
 	}
-
-	dest = vid.buffer + y*vid.rowbytes + x;
-	for(v=0; v<h; v++, dest+=vid.rowbytes)
+	dest = vid.buffer + y*vid.width + x;
+	for(v=0; v<h; v++, dest+=vid.width)
 		for(u=0; u<w; u++)
 			dest[u] = c;
 }
--- a/qw/draw.h
+++ b/qw/draw.h
@@ -14,7 +14,7 @@
 void Draw_BeginDisc (void);
 void Draw_EndDisc (void);
 void Draw_TileClear (int x, int y, int w, int h);
-void Draw_Fill (int x, int y, int w, int h, int c);
+void Draw_Fill (int x, int y, int w, int h, pixel_t c);
 void Draw_FadeScreen (void);
 void Draw_String (int x, int y, char *str);
 void Draw_Alt_String (int x, int y, char *str);
--- a/qw/in.c
+++ b/qw/in.c
@@ -1,12 +1,9 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
+#include "quakedef.h"
 #include <bio.h>
 #include <draw.h>
 #include <thread.h>
 #include <mouse.h>
 #include <keyboard.h>
-#include "quakedef.h"
 
 /* vid.c */
 extern int resized;
--- a/qw/keys.c
+++ b/qw/keys.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 /* key up events are sent even if in console mode */
@@ -20,11 +17,11 @@
 int		key_count;			// incremented every key event
 
 char	*keybindings[256];
-qboolean	consolekeys[256];	// if true, can't be rebound while in console
-qboolean	menubound[256];	// if true, can't be rebound while in menu
+bool	consolekeys[256];	// if true, can't be rebound while in console
+bool	menubound[256];	// if true, can't be rebound while in menu
 int		keyshift[256];		// key to map to if shift held down in console
 int		key_repeats[256];	// if > 1, it is autorepeating
-qboolean	keydown[256];
+bool	keydown[256];
 
 typedef struct
 {
@@ -128,7 +125,7 @@
 ==============================================================================
 */
 
-qboolean CheckForCommand (void)
+bool CheckForCommand (void)
 {
 	char	command[128];
 	char	*cmd, *s;
@@ -296,7 +293,7 @@
 
 //============================================================================
 
-qboolean	chat_team;
+bool	chat_team;
 char		chat_buffer[MAXCMDLINE];
 int			chat_bufferlen = 0;
 
@@ -617,7 +614,7 @@
 Should NOT be called during an interrupt!
 ===================
 */
-void Key_Event (int key, qboolean down)
+void Key_Event (int key, bool down)
 {
 	char	*kb;
 	char	cmd[1024];
--- a/qw/keys.h
+++ b/qw/keys.h
@@ -107,9 +107,9 @@
 
 extern char chat_buffer[];
 extern	int chat_bufferlen;
-extern	qboolean	chat_team;
+extern	bool	chat_team;
 
-void Key_Event (int key, qboolean down);
+void Key_Event (int key, bool down);
 void Key_Init (void);
 void Key_WriteBindings (FILE *f);
 void Key_SetBinding (int keynum, char *binding);
--- a/qw/mathlib.c
+++ b/qw/mathlib.c
@@ -1,8 +1,5 @@
 // mathlib.c -- math primitives
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 void Sys_Error (char *error, ...);
--- a/qw/md4.c
+++ b/qw/md4.c
@@ -1,7 +1,5 @@
 /* GLOBAL.H - RSAREF types and constants */
-
-#include <u.h>
-#include <libc.h>
+#include "quakedef.h"
 
 /* POINTER defines a generic pointer type */
 typedef uchar *POINTER;
--- a/qw/menu.c
+++ b/qw/menu.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 void (*vid_menudrawfn)(void);
@@ -62,12 +59,12 @@
 void M_Search_Key (int key);
 void M_ServerList_Key (int key);
 
-qboolean	m_entersound;		// play after drawing a frame, so caching
+bool	m_entersound;		// play after drawing a frame, so caching
 								// won't disrupt the sound
-qboolean	m_recursiveDraw;
+bool	m_recursiveDraw;
 
 int			m_return_state;
-qboolean	m_return_onerror;
+bool	m_return_onerror;
 char		m_return_reason [32];
 
 #define StartingGame	(m_multiplayer_cursor == 1)
@@ -830,7 +827,7 @@
 
 int		msgNumber;
 int		m_quit_prevstate;
-qboolean	wasInMenus;
+bool	wasInMenus;
 
 char *quitMessage [] = 
 {
--- a/qw/mkfile
+++ b/qw/mkfile
@@ -5,6 +5,8 @@
 	qwcl\
 	qwsv\
 
+CFLAGS=$CFLAGS -D__plan9__ -D__${objtype}__ -I/sys/include -I../plan9 -I..
+
 CLOBJ=\
 	cd.$O\
 	cl_cam.$O\
@@ -35,6 +37,7 @@
 	draw.$O\
 	in.$O\
 	keys.$O\
+	../m_dotproduct`{test -f span_$objtype.s && echo -n _$objtype}.$O\
 	mathlib.$O\
 	md4.$O\
 	menu.$O\
@@ -75,6 +78,8 @@
 	common.$O\
 	crc.$O\
 	cvar.$O\
+	../isnanf.$O\
+	../m_dotproduct`{test -f span_$objtype.s && echo -n _$objtype}.$O\
 	mathlib.$O\
 	md4.$O\
 	nanosec.$O\
@@ -121,6 +126,7 @@
 	model.h\
 	modelgen.h\
 	net.h\
+	../plan9/platform.h\
 	pmove.h\
 	pr_comp.h\
 	progdefs.h\
@@ -143,6 +149,9 @@
 	zone.h\
 
 </sys/src/cmd/mkmany
+
+%.$O: %.c
+	$CC $CFLAGS -o $target $stem.c
 
 $O.qwcl: $CLOBJ
 	$LD -o $target $prereq
--- a/qw/model.c
+++ b/qw/model.c
@@ -3,9 +3,6 @@
 // models are the only shared resource between a client and server running
 // on the same machine.
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 model_t	*loadmodel;
@@ -14,7 +11,7 @@
 void Mod_LoadSpriteModel (model_t *mod, void *buffer);
 void Mod_LoadBrushModel (model_t *mod, void *buffer);
 void Mod_LoadAliasModel (model_t *mod, void *buffer);
-model_t *Mod_LoadModel (model_t *mod, qboolean crash);
+model_t *Mod_LoadModel (model_t *mod, bool crash);
 
 byte	mod_novis[MAX_MAP_LEAFS/8];
 
@@ -212,7 +209,7 @@
 Loads a model into the cache
 ==================
 */
-model_t *Mod_LoadModel (model_t *mod, qboolean crash)
+model_t *Mod_LoadModel (model_t *mod, bool crash)
 {
 	void	*d;
 	unsigned *buf;
@@ -288,7 +285,7 @@
 Loads in a model for the given name
 ==================
 */
-model_t *Mod_ForName (char *name, qboolean crash)
+model_t *Mod_ForName (char *name, bool crash)
 {
 	model_t	*mod;
 	
--- a/qw/model.h
+++ b/qw/model.h
@@ -283,7 +283,7 @@
 typedef struct model_s
 {
 	char		name[MAX_QPATH];
-	qboolean	needload;		// bmodels and sprites don't cache normally
+	bool	needload;		// bmodels and sprites don't cache normally
 
 	modtype_t	type;
 	int			numframes;
@@ -300,7 +300,7 @@
 //
 // solid volume for clipping (sent from server)
 //
-	qboolean	clipbox;
+	bool	clipbox;
 	vec3_t		clipmins, clipmaxs;
 
 //
@@ -364,7 +364,7 @@
 
 void	Mod_Init (void);
 void	Mod_ClearAll (void);
-model_t *Mod_ForName (char *name, qboolean crash);
+model_t *Mod_ForName (char *name, bool crash);
 void	*Mod_Extradata (model_t *mod);	// handles caching
 void	Mod_TouchModel (char *name);
 
--- a/qw/nanosec.c
+++ b/qw/nanosec.c
@@ -1,5 +1,4 @@
-#include <u.h>
-#include <libc.h>
+#include "quakedef.h"
 #include <tos.h>
 
 /*
--- a/qw/net.h
+++ b/qw/net.h
@@ -19,13 +19,13 @@
 
 void		NET_Init (int port);
 void		NET_Shutdown (void);
-qboolean	NET_GetPacket (void);
+bool	NET_GetPacket (void);
 void		NET_SendPacket (int length, void *data, netadr_t *to);
 void	NET_Close(netadr_t*);
 
-qboolean	NET_CompareAdr (netadr_t *a, netadr_t *b);
-qboolean	NET_CompareBaseAdr (netadr_t *a, netadr_t *b);
-qboolean	NET_StringToAdr(char*, netadr_t*, char*);
+bool	NET_CompareAdr (netadr_t *a, netadr_t *b);
+bool	NET_CompareBaseAdr (netadr_t *a, netadr_t *b);
+bool	NET_StringToAdr(char*, netadr_t*, char*);
 
 //============================================================================
 
@@ -35,7 +35,7 @@
 
 typedef struct
 {
-	qboolean	fatal_error;
+	bool	fatal_error;
 
 	float		last_received;		// for timeouts
 
@@ -83,9 +83,9 @@
 void Netchan_Transmit (netchan_t *chan, int length, byte *data);
 void Netchan_OutOfBand (netadr_t *adr, int length, byte *data);
 void Netchan_OutOfBandPrint (netadr_t *adr, char *format, ...);
-qboolean Netchan_Process (netchan_t *chan);
+bool Netchan_Process (netchan_t *chan);
 void Netchan_Setup (netchan_t *chan, netadr_t *adr, int qport);
 
-qboolean Netchan_CanPacket (netchan_t *chan);
-qboolean Netchan_CanReliable (netchan_t *chan);
+bool Netchan_CanPacket (netchan_t *chan);
+bool Netchan_CanReliable (netchan_t *chan);
 
--- a/qw/net_chan.c
+++ b/qw/net_chan.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define	PACKET_HEADER	8
@@ -158,7 +155,7 @@
 ================
 */
 #define	MAX_BACKUP	200
-qboolean Netchan_CanPacket (netchan_t *chan)
+bool Netchan_CanPacket (netchan_t *chan)
 {
 	if (chan->cleartime < realtime + MAX_BACKUP*chan->rate)
 		return true;
@@ -173,7 +170,7 @@
 Returns true if the bandwidth choke isn't 
 ================
 */
-qboolean Netchan_CanReliable (netchan_t *chan)
+bool Netchan_CanReliable (netchan_t *chan)
 {
 	if (chan->reliable_length)
 		return false;			// waiting for ack
@@ -194,7 +191,7 @@
 {
 	sizebuf_t	send;
 	byte		send_buf[MAX_MSGLEN + PACKET_HEADER];
-	qboolean	send_reliable;
+	bool	send_reliable;
 	unsigned	w1, w2;
 	int			i;
 
@@ -286,7 +283,7 @@
 modifies net_message so that it points to the packet payload
 =================
 */
-qboolean Netchan_Process (netchan_t *chan)
+bool Netchan_Process (netchan_t *chan)
 {
 	unsigned		sequence, sequence_ack;
 	unsigned		reliable_ack, reliable_message;
--- a/qw/net_udp.c
+++ b/qw/net_udp.c
@@ -1,9 +1,6 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
+#include "quakedef.h"
 #include <thread.h>
 #include <ip.h>
-#include "quakedef.h"
 
 Channel *echan, *lchan;
 char *netmtpt = "/net";
@@ -13,19 +10,19 @@
 static uchar netbuf[8192];
 static int afd = -1, lpid;
 
-qboolean
+bool
 NET_CompareBaseAdr(netadr_t *a, netadr_t *b)
 {
 	return strcmp(a->addr, b->addr) == 0;
 }
 
-qboolean
+bool
 NET_CompareAdr(netadr_t *a, netadr_t *b)
 {
 	return strcmp(a->sys, b->sys) == 0;
 }
 
-qboolean
+bool
 NET_StringToAdr(char *s, netadr_t *a, char *port)
 {
 	int fd, n;
@@ -78,7 +75,7 @@
 	free(nc);
 }
 
-qboolean
+bool
 NET_GetPacket(void)
 {
 	int n, fd;
--- a/qw/nonintel.c
+++ b/qw/nonintel.c
@@ -2,9 +2,6 @@
 // nonintel.c: code for non-Intel processors only
 //
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 /*
--- a/qw/pmove.c
+++ b/qw/pmove.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 movevars_t		movevars;
--- a/qw/pmove.h
+++ b/qw/pmove.h
@@ -6,9 +6,9 @@
 
 typedef struct
 {
-	qboolean	allsolid;	// if true, plane is not valid
-	qboolean	startsolid;	// if true, the initial point was in a solid area
-	qboolean	inopen, inwater;
+	bool	allsolid;	// if true, plane is not valid
+	bool	startsolid;	// if true, the initial point was in a solid area
+	bool	inopen, inwater;
 	float		fraction;		// time completed, 1.0 = didn't hit anything
 	vec3_t		endpos;			// final position
 	pmplane_t		plane;			// surface normal at impact
@@ -36,7 +36,7 @@
 	vec3_t	velocity;
 	int		oldbuttons;
 	float		waterjumptime;
-	qboolean	dead;
+	bool	dead;
 	int		spectator;
 
 	// world state
@@ -77,5 +77,5 @@
 int PM_HullPointContents (hull_t *hull, int num, vec3_t p);
 
 int PM_PointContents (vec3_t point);
-qboolean PM_TestPlayerPosition (vec3_t point);
+bool PM_TestPlayerPosition (vec3_t point);
 pmtrace_t PM_PlayerMove (vec3_t start, vec3_t stop);
--- a/qw/pmovetst.c
+++ b/qw/pmovetst.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 static	hull_t		box_hull;
@@ -157,7 +154,7 @@
 
 ==================
 */
-qboolean PM_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, pmtrace_t *trace)
+bool PM_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, pmtrace_t *trace)
 {
 	dclipnode_t	*node;
 	mplane_t	*plane;
@@ -295,7 +292,7 @@
 Returns false if the given player position is not valid (in solid)
 ================
 */
-qboolean PM_TestPlayerPosition (vec3_t pos)
+bool PM_TestPlayerPosition (vec3_t pos)
 {
 	int			i;
 	physent_t	*pe;
--- a/qw/pr_cmds.c
+++ b/qw/pr_cmds.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define	RETURN_EDICT(e) (((int *)pr_globals)[OFS_RETURN] = EDICT_TO_PROG(e))
--- a/qw/pr_edict.c
+++ b/qw/pr_edict.c
@@ -1,8 +1,5 @@
 // sv_edict.c -- entity dictionary
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 dprograms_t		*progs;
@@ -18,7 +15,7 @@
 int		type_size[8] = {1,sizeof(void *)/4,1,3,1,1,sizeof(void *)/4,sizeof(void *)/4};
 
 ddef_t *ED_FieldAtOfs (int ofs);
-qboolean	ED_ParseEpair (void *base, ddef_t *key, char *s);
+bool	ED_ParseEpair (void *base, ddef_t *key, char *s);
 
 #define	MAX_FIELD_LEN	64
 #define GEFV_CACHESIZE	2
@@ -701,7 +698,7 @@
 returns false if error
 =============
 */
-qboolean	ED_ParseEpair (void *base, ddef_t *key, char *s)
+bool	ED_ParseEpair (void *base, ddef_t *key, char *s)
 {
 	int		i;
 	char	string[128];
@@ -778,8 +775,8 @@
 char *ED_ParseEdict (char *data, edict_t *ent)
 {
 	ddef_t		*key;
-	qboolean	anglehack;
-	qboolean	init;
+	bool	anglehack;
+	bool	init;
 	char		keyname[256];
 
 	init = false;
--- a/qw/pr_exec.c
+++ b/qw/pr_exec.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 typedef struct
@@ -18,7 +15,7 @@
 int			localstack_used;
 
 
-qboolean	pr_trace;
+bool	pr_trace;
 dfunction_t	*pr_xfunction;
 int			pr_xstatement;
 
--- a/qw/progs.h
+++ b/qw/progs.h
@@ -11,7 +11,7 @@
 #define	MAX_ENT_LEAFS	16
 typedef struct edict_s
 {
-	qboolean	free;
+	bool	free;
 	link_t		area;				// linked to a division node or leaf
 	
 	int			num_leafs;
@@ -96,7 +96,7 @@
 
 extern int		pr_argc;
 
-extern	qboolean	pr_trace;
+extern	bool	pr_trace;
 extern	dfunction_t	*pr_xfunction;
 extern	int			pr_xstatement;
 
--- a/qw/quakedef.h
+++ b/qw/quakedef.h
@@ -1,5 +1,9 @@
 // quakedef.h -- primary header for client
 
+#pragma once
+
+#include "platform.h"
+
 #define	QUAKE_GAME			// as opposed to utilities
 //#define PARANOID			// speed sapping error checking
 
@@ -134,7 +138,7 @@
 #include "vid.h"
 #include "sys.h"
 #include "zone.h"
-#include "../mathlib.h"
+#include "mathlib.h"
 #include "wad.h"
 #include "draw.h"
 #include "cvar.h"
@@ -172,7 +176,7 @@
 #define MAX_NUM_ARGVS	50
 
 
-extern qboolean noclip_anglehack;
+extern bool noclip_anglehack;
 
 
 //
@@ -186,7 +190,7 @@
 
 extern	cvar_t	password;
 
-extern	qboolean	host_initialized;		// true if into command execution
+extern	bool	host_initialized;		// true if into command execution
 extern	double		host_frametime;
 extern	byte		*host_basepal;
 extern	byte		*host_colormap;
@@ -200,13 +204,13 @@
 void Host_Shutdown(void);
 void Host_Error (char *error, ...);
 void Host_EndGame (char *message, ...);
-qboolean Host_SimulationTime(float time);
+bool Host_SimulationTime(float time);
 void Host_Frame (float time);
 void Host_Quit_f (void);
 void Host_ClientCommands (char *fmt, ...);
-void Host_ShutdownServer (qboolean crash);
+void Host_ShutdownServer (bool crash);
 
-extern qboolean		msg_suppress_1;		// suppresses resolution and cache size console output
+extern bool		msg_suppress_1;		// suppresses resolution and cache size console output
 										//  an fullscreen DIB focus gain/loss
 
 void SV_Error (char *error, ...);
--- a/qw/qwcl.c
+++ b/qw/qwcl.c
@@ -1,14 +1,11 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
-#include <thread.h>
 #include "quakedef.h"
+#include <thread.h>
 
 mainstacksize = 512*1024;
 
 /* FIXME: stupid-ass linking kludges */
 server_static_t	svs;
-qboolean ServerPaused(void)
+bool ServerPaused(void)
 {
 	return 0;
 }
--- a/qw/qwsv.c
+++ b/qw/qwsv.c
@@ -1,9 +1,6 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
+#include "quakedef.h"
 #include <thread.h>
 #include <bio.h>
-#include "quakedef.h"
 
 mainstacksize = 256*1024;
 
--- a/qw/r_aclip.c
+++ b/qw/r_aclip.c
@@ -1,8 +1,5 @@
 // r_aclip.c: clip routines for drawing Alias models directly to the screen
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 static finalvert_t		fv[2][8];
--- a/qw/r_alias.c
+++ b/qw/r_alias.c
@@ -1,8 +1,5 @@
 // r_alias.c: routines for setting up to draw alias models
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define LIGHT_MIN	5		// lowest light value we'll allow, to avoid the
@@ -50,7 +47,7 @@
 #define NUMVERTEXNORMALS	162
 
 float	r_avertexnormals[NUMVERTEXNORMALS][3] = {
-#include "../anorms.h"
+#include "/anorms.h"
 };
 
 void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv,
@@ -67,7 +64,7 @@
 R_AliasCheckBBox
 ================
 */
-qboolean R_AliasCheckBBox (void)
+bool R_AliasCheckBBox (void)
 {
 	int					i, flags, frame, numv;
 	aliashdr_t			*pahdr;
@@ -75,7 +72,7 @@
 	finalvert_t			*pv0, *pv1, viewpts[16];
 	auxvert_t			*pa0, *pa1, viewaux[16];
 	maliasframedesc_t	*pframedesc;
-	qboolean			zclipped, zfullyclipped;
+	bool			zclipped, zfullyclipped;
 	unsigned			anyclip, allclip;
 	int					minz;
 	
@@ -399,11 +396,11 @@
 	int		temp;
 	float	lightcos, *plightnormal;
 
-	av->fv[0] = DotProduct(pverts->v, aliastransform[0]) +
+	av->fv[0] = DotProduct_(pverts->v, aliastransform[0]) +
 			aliastransform[0][3];
-	av->fv[1] = DotProduct(pverts->v, aliastransform[1]) +
+	av->fv[1] = DotProduct_(pverts->v, aliastransform[1]) +
 			aliastransform[1][3];
-	av->fv[2] = DotProduct(pverts->v, aliastransform[2]) +
+	av->fv[2] = DotProduct_(pverts->v, aliastransform[2]) +
 			aliastransform[2][3];
 
 	fv->v[2] = pstverts->s;
@@ -446,7 +443,7 @@
 	for (i=0 ; i<r_anumverts ; i++, fv++, pverts++, pstverts++)
 	{
 	// transform and project
-		zi = 1.0 / (DotProduct(pverts->v, aliastransform[2]) +
+		zi = 1.0 / (DotProduct_(pverts->v, aliastransform[2]) +
 				aliastransform[2][3]);
 
 	// x, y, and z are scaled down by 1/2**31 in the transform, so 1/z is
@@ -454,9 +451,9 @@
 	// projection
 		fv->v[5] = zi;
 
-		fv->v[0] = ((DotProduct(pverts->v, aliastransform[0]) +
+		fv->v[0] = ((DotProduct_(pverts->v, aliastransform[0]) +
 				aliastransform[0][3]) * zi) + aliasxcenter;
-		fv->v[1] = ((DotProduct(pverts->v, aliastransform[1]) +
+		fv->v[1] = ((DotProduct_(pverts->v, aliastransform[1]) +
 				aliastransform[1][3]) * zi) + aliasycenter;
 
 		fv->v[2] = pstverts->s;
--- a/qw/r_bsp.c
+++ b/qw/r_bsp.c
@@ -1,12 +1,9 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 //
 // current entity info
 //
-qboolean		insubmodel;
+bool		insubmodel;
 entity_t		*currententity;
 vec3_t			modelorg, base_modelorg;
 								// modelorg is the viewpoint reletive to
@@ -31,7 +28,7 @@
 
 static mvertex_t	*pfrontenter, *pfrontexit;
 
-static qboolean		makeclippededge;
+static bool		makeclippededge;
 
 
 //===========================================================================
--- a/qw/r_draw.c
+++ b/qw/r_draw.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define MAXLEFTCLIPEDGES		100
@@ -25,9 +22,9 @@
 
 medge_t			*r_pedge;
 
-qboolean		r_leftclipped, r_rightclipped;
-static qboolean	makeleftedge, makerightedge;
-qboolean		r_nearzionly;
+bool		r_leftclipped, r_rightclipped;
+static bool	makeleftedge, makerightedge;
+bool		r_nearzionly;
 
 int		sintable[MAXWIDTH+CYCLE];
 int		intsintable[nelem(sintable)];
@@ -46,7 +43,7 @@
 float			r_u1, r_v1, r_lzi1;
 int				r_ceilv1;
 
-qboolean	r_lastvertvalid;
+bool	r_lastvertvalid;
 
 
 /*
@@ -683,7 +680,7 @@
 	mvertex_t	verts[2][100];	//FIXME: do real number
 	polyvert_t	pverts[100];	//FIXME: do real number, safely
 	int			vertpage, newverts, newpage, lastvert;
-	qboolean	visible;
+	bool	visible;
 
 // FIXME: clean this up and make it faster
 // FIXME: guard against running out of vertices
--- a/qw/r_edge.c
+++ b/qw/r_edge.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 /* FIXME
--- a/qw/r_efrag.c
+++ b/qw/r_efrag.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 mnode_t	*r_pefragtopnode;
--- a/qw/r_light.c
+++ b/qw/r_light.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 int	r_dlightframecount;
--- a/qw/r_local.h
+++ b/qw/r_local.h
@@ -103,7 +103,7 @@
 //
 // current entity info
 //
-extern	qboolean		insubmodel;
+extern	bool		insubmodel;
 extern	vec3_t			r_worldmodelorg;
 
 
@@ -204,7 +204,7 @@
 extern finalvert_t		*pfinalverts;
 extern auxvert_t		*pauxverts;
 
-qboolean R_AliasCheckBBox (void);
+bool R_AliasCheckBBox (void);
 
 //=========================================================
 // turbulence stuff
@@ -255,9 +255,9 @@
 extern float	se_time1, se_time2, de_time1, de_time2, dv_time1, dv_time2;
 extern int		r_frustum_indexes[4*6];
 extern int		r_maxsurfsseen, r_maxedgesseen, r_cnumsurfs;
-extern qboolean	r_surfsonstack;
+extern bool	r_surfsonstack;
 extern cshift_t	cshift_water;
-extern qboolean	r_dowarpold, r_viewchanged;
+extern bool	r_dowarpold, r_viewchanged;
 
 extern mleaf_t	*r_viewleaf, *r_oldviewleaf;
 
--- a/qw/r_main.c
+++ b/qw/r_main.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 //define	PASSAGES
@@ -10,16 +7,16 @@
 alight_t	r_viewlighting = {128, 192, viewlightvec};
 float		r_time1;
 int			r_numallocatededges;
-qboolean	r_drawpolys;
-qboolean	r_drawculledpolys;
-qboolean	r_worldpolysbacktofront;
-qboolean	r_recursiveaffinetriangles = true;
+bool	r_drawpolys;
+bool	r_drawculledpolys;
+bool	r_worldpolysbacktofront;
+bool	r_recursiveaffinetriangles = true;
 int			r_pixbytes = 1;
 float		r_aliasuvscale = 1.0;
 int			r_outofsurfaces;
 int			r_outofedges;
 
-qboolean	r_dowarp, r_dowarpold, r_viewchanged;
+bool	r_dowarp, r_dowarpold, r_viewchanged;
 
 int			numbtofpolys;
 btofpoly_t	*pbtofpolys;
@@ -27,7 +24,7 @@
 
 int			c_surf;
 int			r_maxsurfsseen, r_maxedgesseen, r_cnumsurfs;
-qboolean	r_surfsonstack;
+bool	r_surfsonstack;
 int			r_clipflags;
 
 byte		*r_warpbuffer;
@@ -289,7 +286,7 @@
 {
 	int		h;
 	float	size;
-	qboolean full = false;
+	bool full = false;
 
 	if (scr_viewsize.value >= 100.0) {
 		size = 100.0;
--- a/qw/r_misc.c
+++ b/qw/r_misc.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 
--- a/qw/r_part.c
+++ b/qw/r_part.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define MAX_PARTICLES			2048	// default max # of particles at one
--- a/qw/r_shared.h
+++ b/qw/r_shared.h
@@ -65,7 +65,7 @@
 	void		*data;				// associated data like msurface_t
 	entity_t	*entity;
 	float		nearzi;				// nearest 1/z on surface, for mipmapping
-	qboolean	insubmodel;
+	bool	insubmodel;
 	float		d_ziorigin, d_zistepu, d_zistepv;
 
 	int			pad[2];				// to 64 bytes
--- a/qw/r_sky.c
+++ b/qw/r_sky.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 int		iskyspeed = 8;
--- a/qw/r_sprite.c
+++ b/qw/r_sprite.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 static int				clip_current;
--- a/qw/r_surf.c
+++ b/qw/r_surf.c
@@ -1,8 +1,5 @@
 // r_surf.c: surface-related refresh code
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 drawsurf_t	r_drawsurf;
--- a/qw/r_vars.c
+++ b/qw/r_vars.c
@@ -1,8 +1,5 @@
 // r_vars.c: global refresh variables
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 // all global and static refresh variables are collected in a contiguous block
--- a/qw/render.h
+++ b/qw/render.h
@@ -123,7 +123,7 @@
 // surface cache related
 //
 extern	int		reinit_surfcache;	// if 1, surface cache is currently empty and
-extern qboolean	r_cache_thrash;	// set if thrashing the surface cache
+extern bool	r_cache_thrash;	// set if thrashing the surface cache
 
 int	D_SurfaceCacheForRes (int width, int height);
 void D_FlushCaches (void);
--- a/qw/sbar.c
+++ b/qw/sbar.c
@@ -1,8 +1,5 @@
 // sbar.c -- status bar code
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 int			sb_updates;		// if >= vid.numpages, no update needed
@@ -27,8 +24,8 @@
 qpic_t	*sb_face_invuln;
 qpic_t	*sb_face_invis_invuln;
 
-qboolean	sb_showscores;
-qboolean	sb_showteamscores;
+bool	sb_showscores;
+bool	sb_showteamscores;
 
 int			sb_lines;			// scan lines to draw
 
@@ -36,7 +33,7 @@
 void Sbar_TeamOverlay (void);
 void Sbar_MiniDeathmatchOverlay (void);
 
-static qboolean largegame = false;
+static bool largegame = false;
 
 /*
 ===============
@@ -350,7 +347,7 @@
 Sbar_SortFrags
 ===============
 */
-void Sbar_SortFrags (qboolean includespec)
+void Sbar_SortFrags (bool includespec)
 {
 	int		i, j, k;
 		
@@ -486,8 +483,8 @@
 	char	num[6];
 	float	time;
 	int		flashon;
-	qboolean	headsup;
-	qboolean    hudswap;
+	bool	headsup;
+	bool    hudswap;
 
 	headsup = !(cl_sbar.value || scr_viewsize.value<100);
 	hudswap = cl_hudswap.value; // Get that nasty float out :)
@@ -750,7 +747,7 @@
 */
 void Sbar_Draw (void)
 {
-	qboolean headsup;
+	bool headsup;
 	char st[512];
 
 	headsup = !(cl_sbar.value || scr_viewsize.value<100);
--- a/qw/screen.c
+++ b/qw/screen.c
@@ -1,8 +1,5 @@
 // screen.c -- master for refresh, status bar, console, chat, notify, etc
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 /*
@@ -72,7 +69,7 @@
 cvar_t		scr_printspeed = {"scr_printspeed","8"};
 cvar_t		scr_allowsnap = {"scr_allowsnap", "1"};
 
-qboolean	scr_initialized;		// ready to draw
+bool	scr_initialized;		// ready to draw
 
 qpic_t		*scr_ram;
 qpic_t		*scr_net;
@@ -90,11 +87,11 @@
 vrect_t		*pconupdate;
 vrect_t		scr_vrect;
 
-qboolean	scr_disabled_for_loading;
+bool	scr_disabled_for_loading;
 
-qboolean	scr_skipupdate;
+bool	scr_skipupdate;
 
-qboolean	block_drawing;
+bool	block_drawing;
 
 void SCR_ScreenShot_f (void);
 void SCR_RSShot_f (void);
@@ -569,7 +566,7 @@
 ============== 
 */ 
 void WritePCXfile (char *filename, byte *data, int width, int height,
-	int rowbytes, byte *palette, qboolean upload) 
+	int rowbytes, byte *palette, bool upload) 
 {
 	int		i, j, length;
 	pcx_t	*pcx;
@@ -816,7 +813,7 @@
 //=============================================================================
 
 char	*scr_notifystring;
-qboolean	scr_drawdialog;
+bool	scr_drawdialog;
 
 void SCR_DrawNotifyString (void)
 {
--- a/qw/screen.h
+++ b/qw/screen.h
@@ -17,7 +17,7 @@
 extern	int			sb_lines;
 
 extern	int			clearnotify;	// set to 0 whenever notify text is drawn
-extern	qboolean	scr_disabled_for_loading;
+extern	bool	scr_disabled_for_loading;
 
 extern	cvar_t		scr_viewsize;
 
@@ -27,6 +27,6 @@
 extern	int			scr_copytop;
 extern	int			scr_copyeverything;
 
-qboolean	scr_skipupdate;
+bool	scr_skipupdate;
 
-qboolean	block_drawing;
+bool	block_drawing;
--- a/qw/server.h
+++ b/qw/server.h
@@ -14,7 +14,7 @@
 
 typedef struct
 {
-	qboolean	active;				// false when server is going down
+	bool	active;				// false when server is going down
 	server_state_t	state;			// precache commands are only valid during load
 
 	double		time;
@@ -22,7 +22,7 @@
 	int			lastcheck;			// used by PF_checkclient
 	double		lastchecktime;		// for monster ai 
 
-	qboolean	paused;				// are we paused?
+	bool	paused;				// are we paused?
 
 	//check player/eyes models for hacks
 	unsigned	model_player_checksum;
@@ -98,12 +98,12 @@
 
 	int				spectator;			// non-interactive
 
-	qboolean		sendinfo;			// at end of frame, send info to all
+	bool		sendinfo;			// at end of frame, send info to all
 										// this prevents malicious multiple broadcasts
 	float			lastnametime;		// time of last name change
 	int				lastnamecount;		// time of last name change
 	unsigned		checksum;			// checksum for calcs
-	qboolean		drop;				// lose this guy next opportunity
+	bool		drop;				// lose this guy next opportunity
 	int				lossage;			// loss percentage
 
 	int				userid;							// identifying number
@@ -133,7 +133,7 @@
 	byte		backbuf_data[MAX_BACK_BUFFERS][MAX_MSGLEN];
 
 	double			connection_started;	// or time of disconnect for zombies
-	qboolean		send_message;		// set on frames a datagram arived on
+	bool		send_message;		// set on frames a datagram arived on
 
 // spawn parms are carried from level to level
 	float			spawn_parms[NUM_SPAWN_PARMS];
@@ -156,12 +156,12 @@
  	int			whensaidhead;       // Head value for floodprots
  	double			lockedtill;
 
-	qboolean		upgradewarn;		// did we warn him?
+	bool		upgradewarn;		// did we warn him?
 
 	FILE			*upload;
 	char			uploadfn[MAX_QPATH];
 	netadr_t		snap_from;
-	qboolean		remote_snap;
+	bool		remote_snap;
  
 //===== NETWORK ============
 	int				chokecount;
@@ -329,8 +329,8 @@
 
 int SV_ModelIndex (char *name);
 
-qboolean SV_CheckBottom (edict_t *ent);
-qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink);
+bool SV_CheckBottom (edict_t *ent);
+bool SV_movestep (edict_t *ent, vec3_t move, bool relink);
 
 void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg);
 
@@ -363,7 +363,7 @@
 void SV_Physics (void);
 void SV_CheckVelocity (edict_t *ent);
 void SV_AddGravity (edict_t *ent, float scale);
-qboolean SV_RunThink (edict_t *ent);
+bool SV_RunThink (edict_t *ent);
 void SV_Physics_Toss (edict_t *ent);
 void SV_RunNewmis (void);
 void SV_Impact (edict_t *e1, edict_t *e2);
@@ -426,5 +426,5 @@
 void ClientReliableWrite_String(client_t *cl, char *s);
 void ClientReliableWrite_SZ(client_t *cl, void *data, int len);
 
-qboolean	ServerPaused(void);
+bool	ServerPaused(void);
 void	SV_SendServerInfoChange(char *key, char *value);
--- a/qw/skin.c
+++ b/qw/skin.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 cvar_t		baseskin = {"baseskin", "base"};
--- a/qw/snd.c
+++ b/qw/snd.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 cvar_t volume = {"volume", "0.7", 1};
--- a/qw/sound.h
+++ b/qw/sound.h
@@ -26,9 +26,9 @@
 
 typedef struct
 {
-	qboolean		gamealive;
-	qboolean		soundalive;
-	qboolean		splitbuffer;
+	bool		gamealive;
+	bool		soundalive;
+	bool		splitbuffer;
 	int				channels;
 	int				samples;				// mono samples in buffer
 	int				submission_chunk;		// don't mix less than this #
@@ -88,7 +88,7 @@
 void SND_Spatialize(channel_t *ch);
 
 // initializes cycling through a DMA buffer and returns information on it
-qboolean SNDDMA_Init(void);
+bool SNDDMA_Init(void);
 
 // gets the current DMA position
 int SNDDMA_GetDMAPos(void);
@@ -117,7 +117,7 @@
 // number of times stepsnd() is called per second.
 //
 
-extern qboolean 		fakedma;
+extern bool 		fakedma;
 extern int 			fakedma_updates;
 extern int		paintedtime;
 extern volatile dma_t *shm;
@@ -127,7 +127,7 @@
 extern	cvar_t bgmvolume;
 extern	cvar_t volume;
 
-extern qboolean	snd_initialized;
+extern bool	snd_initialized;
 
 extern int		snd_blocked;
 
--- a/qw/sv_ccmds.c
+++ b/qw/sv_ccmds.c
@@ -1,9 +1,6 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
-qboolean	sv_allow_cheats;
+bool	sv_allow_cheats;
 
 int fp_messages=4, fp_persecond=4, fp_secondsdead=10;
 char fp_msg[255];
@@ -142,7 +139,7 @@
 Sets host_client and sv_player to the player with idnum Cmd_Argv(1)
 ==================
 */
-qboolean SV_SetPlayer (void)
+bool SV_SetPlayer (void)
 {
 	client_t	*cl;
 	int			i;
--- a/qw/sv_ents.c
+++ b/qw/sv_ents.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 /*
@@ -78,7 +75,7 @@
 
 extern	int	sv_nailmodel, sv_supernailmodel, sv_playermodel;
 
-qboolean SV_AddNailUpdate (edict_t *ent)
+bool SV_AddNailUpdate (edict_t *ent)
 {
 	if (ent->v.modelindex != sv_nailmodel
 		&& ent->v.modelindex != sv_supernailmodel)
@@ -135,7 +132,7 @@
 Can delta from either a baseline or a previous packet_entity
 ==================
 */
-void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force)
+void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, bool force)
 {
 	int		bits;
 	int		i;
--- a/qw/sv_init.c
+++ b/qw/sv_init.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 server_static_t	svs;				// persistant server info
--- a/qw/sv_main.c
+++ b/qw/sv_main.c
@@ -1,11 +1,8 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 quakeparms_t host_parms;
 
-qboolean	host_initialized;		// true if into command execution (compatability)
+bool	host_initialized;		// true if into command execution (compatability)
 
 double		host_frametime;
 double		realtime;				// without any filtering or bounding
@@ -63,7 +60,7 @@
 
 //============================================================================
 
-qboolean ServerPaused(void)
+bool ServerPaused(void)
 {
 	return sv.paused;
 }
@@ -103,7 +100,7 @@
 {
 	va_list		argptr;
 	static	char		string[1024];
-	static	qboolean inerror = false;
+	static	bool inerror = false;
 
 	if (inerror)
 		Sys_Error ("SV_Error: recursively entered (%s)", string);
@@ -492,7 +489,7 @@
 	int			edictnum;
 	char		*s;
 	int			clients, spectators;
-	qboolean	spectator;
+	bool	spectator;
 	int			qport;
 	int			version;
 	int			challenge;
@@ -951,7 +948,7 @@
 SV_FilterPacket
 =================
 */
-qboolean SV_FilterPacket (void)
+bool SV_FilterPacket (void)
 {
 	int		i;
 
--- a/qw/sv_move.c
+++ b/qw/sv_move.c
@@ -1,8 +1,5 @@
 // sv_move.c -- monster movement
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define	STEPSIZE	18
@@ -18,7 +15,7 @@
 */
 int c_yes, c_no;
 
-qboolean SV_CheckBottom (edict_t *ent)
+bool SV_CheckBottom (edict_t *ent)
 {
 	vec3_t	mins, maxs, start, stop;
 	trace_t	trace;
@@ -91,7 +88,7 @@
 pr_global_struct->trace_normal is set to the normal of the blocking wall
 =============
 */
-qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
+bool SV_movestep (edict_t *ent, vec3_t move, bool relink)
 {
 	float		dz;
 	vec3_t		oldorg, neworg, end;
@@ -214,7 +211,7 @@
 ======================
 */
 void PF_changeyaw (void);
-qboolean SV_StepDirection (edict_t *ent, float yaw, float dist)
+bool SV_StepDirection (edict_t *ent, float yaw, float dist)
 {
 	vec3_t		move, oldorigin;
 	float		delta;
@@ -354,7 +351,7 @@
 
 ======================
 */
-qboolean SV_CloseEnough (edict_t *ent, edict_t *goal, float dist)
+bool SV_CloseEnough (edict_t *ent, edict_t *goal, float dist)
 {
 	int		i;
 	
--- a/qw/sv_nchan.c
+++ b/qw/sv_nchan.c
@@ -1,8 +1,5 @@
 // sv_nchan.c, user reliable data stream writes
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 // check to see if client block will fit, if not, rotate buffers
--- a/qw/sv_phys.c
+++ b/qw/sv_phys.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 /*
@@ -75,12 +72,12 @@
 //
 	for (i=0 ; i<3 ; i++)
 	{
-		if (IS_NAN(ent->v.velocity[i]))
+		if (isnanf(ent->v.velocity[i]))
 		{
 			Con_Printf ("Got a NaN velocity on %s\n", PR_GetString(ent->v.classname));
 			ent->v.velocity[i] = 0;
 		}
-		if (IS_NAN(ent->v.origin[i]))
+		if (isnanf(ent->v.origin[i]))
 		{
 			Con_Printf ("Got a NaN origin on %s\n", PR_GetString(ent->v.classname));
 			ent->v.origin[i] = 0;
@@ -102,7 +99,7 @@
 Returns false if the entity removed itself.
 =============
 */
-qboolean SV_RunThink (edict_t *ent)
+bool SV_RunThink (edict_t *ent)
 {
 	float	thinktime;
 
@@ -402,7 +399,7 @@
 
 ============
 */
-qboolean SV_Push (edict_t *pusher, vec3_t move)
+bool SV_Push (edict_t *pusher, vec3_t move)
 {
 	int			i, e;
 	edict_t		*check, *block;
@@ -766,7 +763,7 @@
 */
 void SV_Physics_Step (edict_t *ent)
 {
-	qboolean	hitsound;
+	bool	hitsound;
 
 // frefall if not onground
 	if ( ! ((int)ent->v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM) ) )
--- a/qw/sv_send.c
+++ b/qw/sv_send.c
@@ -1,8 +1,5 @@
 // sv_main.c -- server main program
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define CHAN_AUTO   0
@@ -243,7 +240,7 @@
 	mleaf_t		*leaf;
 	int			leafnum;
 	int			j;
-	qboolean	reliable;
+	bool	reliable;
 
 	leaf = Mod_PointInLeaf (origin, sv.worldmodel);
 	if (!leaf)
@@ -337,8 +334,8 @@
     int			i;
 	int			ent;
 	vec3_t		origin;
-	qboolean	use_phs;
-	qboolean	reliable = false;
+	bool	use_phs;
+	bool	reliable = false;
 
 	if (volume < 0 || volume > 255)
 		SV_Error ("SV_StartSound: volume = %d", volume);
@@ -548,7 +545,7 @@
 SV_SendClientDatagram
 =======================
 */
-qboolean SV_SendClientDatagram (client_t *client)
+bool SV_SendClientDatagram (client_t *client)
 {
 	byte		buf[MAX_DATAGRAM];
 	sizebuf_t	msg;
--- a/qw/sv_user.c
+++ b/qw/sv_user.c
@@ -1,8 +1,5 @@
 // sv_user.c -- server code for moving users
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 edict_t	*sv_player;
@@ -701,7 +698,7 @@
 SV_Say
 ==================
 */
-void SV_Say (qboolean team)
+void SV_Say (bool team)
 {
 	client_t *client;
 	int		j, tmp;
@@ -1514,7 +1511,7 @@
 	usercmd_t	oldest, oldcmd, newcmd;
 	client_frame_t	*frame;
 	vec3_t o;
-	qboolean	move_issued = false; //only allow one move command
+	bool	move_issued = false; //only allow one move command
 	int		checksumIndex;
 	byte	checksum, calculatedChecksum;
 	int		seq_hash;
--- a/qw/svmodel.c
+++ b/qw/svmodel.c
@@ -3,9 +3,6 @@
 // models are the only shared resource between a client and server running
 // on the same machine.
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 model_t	*loadmodel;
@@ -14,7 +11,7 @@
 void Mod_LoadSpriteModel (model_t *mod, void *buffer);
 void Mod_LoadBrushModel (model_t *mod, void *buffer);
 void Mod_LoadAliasModel (model_t *mod, void *buffer);
-model_t *Mod_LoadModel (model_t *mod, qboolean crash);
+model_t *Mod_LoadModel (model_t *mod, bool crash);
 
 byte	mod_novis[MAX_MAP_LEAFS/8];
 
@@ -177,7 +174,7 @@
 Loads a model into the cache
 ==================
 */
-model_t *Mod_LoadModel (model_t *mod, qboolean crash)
+model_t *Mod_LoadModel (model_t *mod, bool crash)
 {
 	void	*d;
 	unsigned *buf;
@@ -232,7 +229,7 @@
 Loads in a model for the given name
 ==================
 */
-model_t *Mod_ForName (char *name, qboolean crash)
+model_t *Mod_ForName (char *name, bool crash)
 {
 	model_t	*mod;
 	
--- a/qw/sys.c
+++ b/qw/sys.c
@@ -1,8 +1,5 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
-#include <thread.h>
 #include "quakedef.h"
+#include <thread.h>
 
 int svonly, debug;
 
--- a/qw/vid.c
+++ b/qw/vid.c
@@ -1,8 +1,5 @@
-#include <u.h>
-#include <libc.h>
-#include <draw.h>
-#include <stdio.h>
 #include "quakedef.h"
+#include <draw.h>
 
 viddef_t vid;		/* global video state */
 int resized;
--- a/qw/vid.h
+++ b/qw/vid.h
@@ -58,7 +58,7 @@
 // sets the mode; only used by the Quake engine for resetting to mode 0 (the
 // base mode) on memory allocation failures
 
-void VID_HandlePause (qboolean pause);
+void VID_HandlePause (bool pause);
 // called only on Win32, when pause happens, so the mouse can be released
 
 void VID_LockBuffer (void);
--- a/qw/view.c
+++ b/qw/view.c
@@ -1,8 +1,5 @@
 // view.c -- player eye positioning
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 /*
@@ -267,7 +264,7 @@
 V_CheckGamma
 =================
 */
-qboolean V_CheckGamma (void)
+bool V_CheckGamma (void)
 {
 	static float oldgammavalue;
 	
@@ -459,11 +456,11 @@
 void V_UpdatePalette (void)
 {
 	int		i, j;
-	qboolean	new;
+	bool	new;
 	byte	*basepal, *newpal;
 	byte	pal[768];
 	int		r,g,b;
-	qboolean force;
+	bool force;
 
 	V_CalcPowerupCshift ();
 	
--- a/qw/wad.c
+++ b/qw/wad.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 int			wad_numlumps;
--- a/qw/world.c
+++ b/qw/world.c
@@ -1,8 +1,5 @@
 // world.c -- world query functions
 
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 /*
@@ -341,7 +338,7 @@
 
 ===============
 */
-void SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
+void SV_LinkEdict (edict_t *ent, bool touch_triggers)
 {
 	areanode_t	*node;
 	
@@ -507,7 +504,7 @@
 
 ==================
 */
-qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace)
+bool SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace)
 {
 	dclipnode_t	*node;
 	mplane_t	*plane;
--- a/qw/world.h
+++ b/qw/world.h
@@ -6,9 +6,9 @@
 
 typedef struct
 {
-	qboolean	allsolid;	// if true, plane is not valid
-	qboolean	startsolid;	// if true, the initial point was in a solid area
-	qboolean	inopen, inwater;
+	bool	allsolid;	// if true, plane is not valid
+	bool	startsolid;	// if true, the initial point was in a solid area
+	bool	inopen, inwater;
 	float	fraction;		// time completed, 1.0 = didn't hit anything
 	vec3_t	endpos;			// final position
 	plane_t	plane;			// surface normal at impact
@@ -43,7 +43,7 @@
 // so it doesn't clip against itself
 // flags ent->v.modified
 
-void SV_LinkEdict (edict_t *ent, qboolean touch_triggers);
+void SV_LinkEdict (edict_t *ent, bool touch_triggers);
 // Needs to be called any time an entity changes origin, mins, maxs, or solid
 // flags ent->v.modified
 // sets ent->v.absmin and ent->v.absmax
--- a/qw/zone.c
+++ b/qw/zone.c
@@ -1,6 +1,3 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
 #include "quakedef.h"
 
 #define	DYNAMIC_SIZE	0x20000
@@ -254,7 +251,7 @@
 int		hunk_low_used;
 int		hunk_high_used;
 
-qboolean	hunk_tempactive;
+bool	hunk_tempactive;
 int		hunk_tempmark;
 
 void R_FreeTextures (void);
@@ -288,7 +285,7 @@
 Otherwise, allocations with the same name will be totaled up before printing.
 ==============
 */
-void Hunk_Print (qboolean all)
+void Hunk_Print (bool all)
 {
 	hunk_t	*h, *next, *endlow, *starthigh, *endhigh;
 	int		count, sum;
@@ -539,7 +536,7 @@
 	struct cache_system_s	*lru_prev, *lru_next;	// for LRU flushing	
 } cache_system_t;
 
-cache_system_t *Cache_TryAlloc (int size, qboolean nobottom);
+cache_system_t *Cache_TryAlloc (int size, bool nobottom);
 
 cache_system_t	cache_head;
 
@@ -653,7 +650,7 @@
 Size should already include the header and padding
 ============
 */
-cache_system_t *Cache_TryAlloc (int size, qboolean nobottom)
+cache_system_t *Cache_TryAlloc (int size, bool nobottom)
 {
 	cache_system_t	*cs, *new;