shithub: qk1

Download patch

ref: aa377eccbe2f49395b65cb83fe68e857e08c144f
parent: 65327985abf5b3619428eb0fc489d875fcb9555b
author: Konstantinn Bonnet <qu7uux@gmail.com>
date: Mon Mar 9 18:59:53 EDT 2015

include headers with global definitions everywhere

this resolves generating type incompatibilities when using -T CFLAG.
it's ugly.

--- a/README
+++ b/README
@@ -60,7 +60,6 @@
 	- manpages
 	- ungrab mouse when entering console or menus a la games/doom (IN_Grabm())
 	- cleanse *_9.c from linux legacy
-	- linking errors with -T cflag
 	- fix potential fp exceptions in code rather than ignoring them?
 	- g '/\* FIXME'
 	- port quakeworld and utilities +/- merge common code and mkmany
--- a/crc.c
+++ b/crc.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "crc.h"
 
 // this is a 16 bit, non-reflected CRC using the polynomial 0x1021
 // and the initial and final xor values shown below...  in other words, the
--- a/d_edge.c
+++ b/d_edge.c
@@ -2,8 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 static int	miplevel;
 
--- a/d_fill.c
+++ b/d_fill.c
@@ -5,7 +5,6 @@
 #include <stdio.h>
 #include "quakedef.h"
 
-
 /*
 ================
 D_FillRect
--- a/d_init.c
+++ b/d_init.c
@@ -4,8 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 #define NUM_MIPS	4
 
--- a/d_modech.c
+++ b/d_modech.c
@@ -4,8 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 int	d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
 
--- a/d_part.c
+++ b/d_part.c
@@ -4,9 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
-
 
 /*
 ==============
--- a/d_polyse.c
+++ b/d_polyse.c
@@ -5,8 +5,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 // TODO: put in span spilling to shrink list size
 // !!! if this is changed, it must be changed in d_polysa.s too !!!
--- a/d_scan.c
+++ b/d_scan.c
@@ -6,8 +6,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 unsigned char	*r_turb_pbase, *r_turb_pdest;
 fixed16_t		r_turb_s, r_turb_t, r_turb_sstep, r_turb_tstep;
--- a/d_sky.c
+++ b/d_sky.c
@@ -2,8 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 #define SKY_SPAN_SHIFT	5
 #define SKY_SPAN_MAX	(1 << SKY_SPAN_SHIFT)
--- a/d_sprite.c
+++ b/d_sprite.c
@@ -5,8 +5,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 static int		sprite_height;
 static int		minindex, maxindex;
--- a/d_surf.c
+++ b/d_surf.c
@@ -4,8 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 float           surfscale;
 qboolean        r_cache_thrash;         // set if surface cache is thrashing
--- a/d_zpoint.c
+++ b/d_zpoint.c
@@ -4,9 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
-
 
 /*
 =====================
--- a/host.c
+++ b/host.c
@@ -4,7 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 /*
 
--- a/mkfile
+++ b/mkfile
@@ -97,11 +97,7 @@
 	menu.h\
 	modelgen.h\
 	model.h\
-	net_dgrm.h\
 	net.h\
-	net_loop.h\
-	net_udp.h\
-	net_vcr.h\
 	pr_comp.h\
 	progdefs.h\
 	progs.h\
@@ -123,6 +119,3 @@
 	zone.h\
 
 </sys/src/cmd/mkone
-
-# FIXME
-CFLAGS=-FVw
--- a/model.c
+++ b/model.c
@@ -7,7 +7,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 model_t	*loadmodel;
 char	loadname[32];	// for hunk tags
--- a/net.h
+++ b/net.h
@@ -314,3 +314,69 @@
 extern	qboolean	slistLocal;
 
 void NET_Slist_f (void);
+
+/* dgrm */
+int			Datagram_Init (void);
+void		Datagram_Listen (qboolean state);
+void		Datagram_SearchForHosts (qboolean xmit);
+qsocket_t	*Datagram_Connect (char *host);
+qsocket_t 	*Datagram_CheckNewConnections (void);
+int			Datagram_GetMessage (qsocket_t *sock);
+int			Datagram_SendMessage (qsocket_t *sock, sizebuf_t *data);
+int			Datagram_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data);
+qboolean	Datagram_CanSendMessage (qsocket_t *sock);
+qboolean	Datagram_CanSendUnreliableMessage (qsocket_t *sock);
+void		Datagram_Close (qsocket_t *sock);
+void		Datagram_Shutdown (void);
+
+/* loop */
+int			Loop_Init (void);
+void		Loop_Listen (qboolean state);
+void		Loop_SearchForHosts (qboolean xmit);
+qsocket_t 	*Loop_Connect (char *host);
+qsocket_t 	*Loop_CheckNewConnections (void);
+int			Loop_GetMessage (qsocket_t *sock);
+int			Loop_SendMessage (qsocket_t *sock, sizebuf_t *data);
+int			Loop_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data);
+qboolean	Loop_CanSendMessage (qsocket_t *sock);
+qboolean	Loop_CanSendUnreliableMessage (qsocket_t *sock);
+void		Loop_Close (qsocket_t *sock);
+void		Loop_Shutdown (void);
+
+/* vcr */
+#define VCR_OP_CONNECT		1
+#define VCR_OP_GETMESSAGE	2
+#define VCR_OP_SENDMESSAGE	3
+#define VCR_OP_CANSENDMESSAGE	4
+#define VCR_MAX_MESSAGE		4
+
+int			VCR_Init (void);
+void		VCR_Listen (qboolean state);
+void		VCR_SearchForHosts (qboolean xmit);
+qsocket_t 	*VCR_Connect (char *host);
+qsocket_t 	*VCR_CheckNewConnections (void);
+int			VCR_GetMessage (qsocket_t *sock);
+int			VCR_SendMessage (qsocket_t *sock, sizebuf_t *data);
+qboolean	VCR_CanSendMessage (qsocket_t *sock);
+void		VCR_Close (qsocket_t *sock);
+void		VCR_Shutdown (void);
+
+/* udp */
+int  UDP_Init (void);
+void UDP_Shutdown (void);
+void UDP_Listen (qboolean state);
+int  UDP_OpenSocket (int port);
+int  UDP_CloseSocket (int socket);
+int  UDP_Connect (int socket, struct qsockaddr *addr);
+int  UDP_CheckNewConnections (void);
+int  UDP_Read (int socket, byte *buf, int len, struct qsockaddr *addr);
+int  UDP_Write (int socket, byte *buf, int len, struct qsockaddr *addr);
+int  UDP_Broadcast (int socket, byte *buf, int len);
+char *UDP_AddrToString (struct qsockaddr *addr);
+int  UDP_StringToAddr (char *string, struct qsockaddr *addr);
+int  UDP_GetSocketAddr (int socket, struct qsockaddr *addr);
+int  UDP_GetNameFromAddr (struct qsockaddr *addr, char *name);
+int  UDP_GetAddrFromName (char *name, struct qsockaddr *addr);
+int  UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2);
+int  UDP_GetSocketPort (struct qsockaddr *addr);
+int  UDP_SetSocketPort (struct qsockaddr *addr, int port);
--- a/net_bsd.c
+++ b/net_bsd.c
@@ -2,8 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "net_loop.h"
-#include "net_dgrm.h"
 
 net_driver_t net_drivers[MAX_NET_DRIVERS] =
 {
@@ -43,8 +41,6 @@
 };
 
 int net_numdrivers = 2;
-
-#include "net_udp.h"
 
 net_landriver_t	net_landrivers[MAX_NET_DRIVERS] =
 {
--- a/net_dgrm.c
+++ b/net_dgrm.c
@@ -1,6 +1,7 @@
 #include <u.h>
 #include <libc.h>
 #include <stdio.h>
+#include "quakedef.h"
 
 // This is enables a simple IP banning mechanism
 //#define BAN_TEST	/* FIXME */
@@ -28,8 +29,6 @@
 u32int inet_addr(const char *cp);
 #endif	// BAN_TEST
 
-#include "quakedef.h"
-#include "net_dgrm.h"
 
 // these two macros are to make the code more readable
 #define sfunc	net_landrivers[sock->landriver]
--- a/net_dgrm.h
+++ /dev/null
@@ -1,12 +1,0 @@
-int			Datagram_Init (void);
-void		Datagram_Listen (qboolean state);
-void		Datagram_SearchForHosts (qboolean xmit);
-qsocket_t	*Datagram_Connect (char *host);
-qsocket_t 	*Datagram_CheckNewConnections (void);
-int			Datagram_GetMessage (qsocket_t *sock);
-int			Datagram_SendMessage (qsocket_t *sock, sizebuf_t *data);
-int			Datagram_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data);
-qboolean	Datagram_CanSendMessage (qsocket_t *sock);
-qboolean	Datagram_CanSendUnreliableMessage (qsocket_t *sock);
-void		Datagram_Close (qsocket_t *sock);
-void		Datagram_Shutdown (void);
--- a/net_loop.c
+++ b/net_loop.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "net_loop.h"
 
 qboolean	localconnectpending = false;
 qsocket_t	*loop_client = nil;
--- a/net_loop.h
+++ /dev/null
@@ -1,12 +1,0 @@
-int			Loop_Init (void);
-void		Loop_Listen (qboolean state);
-void		Loop_SearchForHosts (qboolean xmit);
-qsocket_t 	*Loop_Connect (char *host);
-qsocket_t 	*Loop_CheckNewConnections (void);
-int			Loop_GetMessage (qsocket_t *sock);
-int			Loop_SendMessage (qsocket_t *sock, sizebuf_t *data);
-int			Loop_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data);
-qboolean	Loop_CanSendMessage (qsocket_t *sock);
-qboolean	Loop_CanSendUnreliableMessage (qsocket_t *sock);
-void		Loop_Close (qsocket_t *sock);
-void		Loop_Shutdown (void);
--- a/net_main.c
+++ b/net_main.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "net_vcr.h"
 
 qsocket_t	*net_activeSockets = nil;
 qsocket_t	*net_freeSockets = nil;
--- a/net_udp.c
+++ b/net_udp.c
@@ -19,8 +19,6 @@
 static u32int myAddr;
 */
 
-#include "net_udp.h"
-
 int UDP_Init (void)
 {
 	/*
--- a/net_udp.h
+++ /dev/null
@@ -1,18 +1,0 @@
-int  UDP_Init (void);
-void UDP_Shutdown (void);
-void UDP_Listen (qboolean state);
-int  UDP_OpenSocket (int port);
-int  UDP_CloseSocket (int socket);
-int  UDP_Connect (int socket, struct qsockaddr *addr);
-int  UDP_CheckNewConnections (void);
-int  UDP_Read (int socket, byte *buf, int len, struct qsockaddr *addr);
-int  UDP_Write (int socket, byte *buf, int len, struct qsockaddr *addr);
-int  UDP_Broadcast (int socket, byte *buf, int len);
-char *UDP_AddrToString (struct qsockaddr *addr);
-int  UDP_StringToAddr (char *string, struct qsockaddr *addr);
-int  UDP_GetSocketAddr (int socket, struct qsockaddr *addr);
-int  UDP_GetNameFromAddr (struct qsockaddr *addr, char *name);
-int  UDP_GetAddrFromName (char *name, struct qsockaddr *addr);
-int  UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2);
-int  UDP_GetSocketPort (struct qsockaddr *addr);
-int  UDP_SetSocketPort (struct qsockaddr *addr, int port);
--- a/net_vcr.c
+++ b/net_vcr.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "net_vcr.h"
 
 extern int vcrFile;
 
--- a/net_vcr.h
+++ /dev/null
@@ -1,16 +1,0 @@
-#define VCR_OP_CONNECT					1
-#define VCR_OP_GETMESSAGE				2
-#define VCR_OP_SENDMESSAGE				3
-#define VCR_OP_CANSENDMESSAGE			4
-#define VCR_MAX_MESSAGE					4
-
-int			VCR_Init (void);
-void		VCR_Listen (qboolean state);
-void		VCR_SearchForHosts (qboolean xmit);
-qsocket_t 	*VCR_Connect (char *host);
-qsocket_t 	*VCR_CheckNewConnections (void);
-int			VCR_GetMessage (qsocket_t *sock);
-int			VCR_SendMessage (qsocket_t *sock, sizebuf_t *data);
-qboolean	VCR_CanSendMessage (qsocket_t *sock);
-void		VCR_Close (qsocket_t *sock);
-void		VCR_Shutdown (void);
--- a/nonintel.c
+++ b/nonintel.c
@@ -6,8 +6,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 /*
 ================
--- a/quakedef.h
+++ b/quakedef.h
@@ -193,6 +193,10 @@
 #include "crc.h"
 #include "cdaudio.h"
 
+/* included here to avoid type incompatibilities errors from 2c(1),2l(1) */
+#include "r_local.h"
+#include "d_local.h"
+
 //=============================================================================
 
 // the host system specifies the base of the directory tree, the
--- a/r_aclip.c
+++ b/r_aclip.c
@@ -4,8 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 static finalvert_t		fv[2][8];
 static auxvert_t		av[8];
--- a/r_alias.c
+++ b/r_alias.c
@@ -4,9 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"	// FIXME: shouldn't be needed (is needed for patch
-						// right now, but that should move)
 
 #define LIGHT_MIN	5		// lowest light value we'll allow, to avoid the
 							//  need for inner-loop light clamping
--- a/r_bsp.c
+++ b/r_bsp.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 //
 // current entity info
--- a/r_draw.c
+++ b/r_draw.c
@@ -2,8 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"	// FIXME: shouldn't need to include this
 
 #define MAXLEFTCLIPEDGES		100
 
--- a/r_edge.c
+++ b/r_edge.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 /* FIXME
 the complex cases add new polys on most lines, so dont optimize for keeping them the same
--- a/r_efrag.c
+++ b/r_efrag.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 mnode_t	*r_pefragtopnode;
 
--- a/r_light.c
+++ b/r_light.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 int	r_dlightframecount;
 
--- a/r_main.c
+++ b/r_main.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 //define	PASSAGES
 
--- a/r_misc.c
+++ b/r_misc.c
@@ -2,8 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-
 
 /*
 ===============
--- a/r_part.c
+++ b/r_part.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 #define MAX_PARTICLES			2048	// default max # of particles at one
 										//  time
--- a/r_sky.c
+++ b/r_sky.c
@@ -2,8 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
 
 
 int		iskyspeed = 8;
--- a/r_sprite.c
+++ b/r_sprite.c
@@ -2,7 +2,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 static int				clip_current;
 static vec5_t			clip_verts[2][MAXWORKINGVERTS];
--- a/r_surf.c
+++ b/r_surf.c
@@ -4,7 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 drawsurf_t	r_drawsurf;
 
--- a/screen.c
+++ b/screen.c
@@ -4,7 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 // only the refresh window will be updated unless these variables are flagged 
 int			scr_copytop;
--- a/vid_9.c
+++ b/vid_9.c
@@ -3,9 +3,6 @@
 #include <draw.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
-#include "d_local.h"
-
 extern int scr_fullupdate;
 
 int config_notify;
--- a/view.c
+++ b/view.c
@@ -4,7 +4,6 @@
 #include <libc.h>
 #include <stdio.h>
 #include "quakedef.h"
-#include "r_local.h"
 
 /*