shithub: qk1

Download patch

ref: 1b89f96bdfe8147e0ed8e0c35dc5cfdd2a48062c
parent: a63d5778cb72c91bf1b14aaa4453a0239cc4a823
author: Konstantinn Bonnet <[email protected]>
date: Mon Mar 2 09:06:28 EST 2015

assume truecolor; some cleanup and quench compiler warnings

for some reason, they (he?) kind of assume 24bit color space in quake 2, and
when they copied over the linux code from 1, they kept the 16bit shit by error,
and with the old input issues (same code), linux/x11 code is completely fucked.
or so it seems anyway. carmack is probably right about giving x11 the finger.

--- a/cd_9.c
+++ b/cd_9.c
@@ -36,7 +36,7 @@
 	*/
 }
 
-void CDAudio_Play (byte track, qboolean looping)
+void CDAudio_Play (byte track, qboolean /*looping*/)
 {
 	if(cdfd == -1 || !enabled)
 		return;
@@ -46,9 +46,6 @@
 			return;
 	}
 
-	Con_DPrintf("CDAudio_Play: PORTME\n");
-	return;
-
 	track = remap[track];
 	if(track < 1 || track > maxTrack){
 		Con_DPrintf("CDAudio: Bad track number %ud.\n", track);
@@ -55,6 +52,9 @@
 		return;
 	}
 
+	Con_DPrintf("CDAudio_Play: PORTME\n");
+	return;
+
 	/*
 	struct cdrom_tocentry entry;
 	struct cdrom_ti ti;
@@ -87,7 +87,6 @@
 	}
 	if(ioctl(cdfd, CDROMRESUME) == -1) 
 		Con_DPrintf("ioctl cdromresume failed\n");
-	*/
 
 	playLooping = looping;
 	playTrack = track;
@@ -95,6 +94,7 @@
 
 	if(cdvolume == 0.0)
 		CDAudio_Pause();
+	*/
 }
 
 void CDAudio_Stop (void)
--- a/cmd.c
+++ b/cmd.c
@@ -479,11 +479,8 @@
 			text++;
 		}
 		
-		if (*text == '\n')
-		{	// a newline seperates commands in the buffer
-			text++;
-			break;
-		}
+		if (*text == '\n')	// a newline seperates commands in the buffer	
+			return;
 
 		if (!*text)
 			return;
@@ -502,7 +499,6 @@
 			cmd_argc++;
 		}
 	}
-	
 }
 
 
--- a/d_polyse.c
+++ b/d_polyse.c
@@ -820,8 +820,6 @@
 		// FIXME: need to clamp l, s, t, at both ends?
 			d_pedgespanpackage->light = d_light;
 			d_pedgespanpackage->zi = d_zi;
-
-			d_pedgespanpackage++;
 		}
 		else
 		{
--- a/net_dgrm.c
+++ b/net_dgrm.c
@@ -505,7 +505,6 @@
 	int		colors;
 	int		frags;
 	int		connectTime;
-	byte	playerNumber;
 
 	net_landriverlevel = testDriver;
 
@@ -530,7 +529,7 @@
 		if (MSG_ReadByte() != CCREP_PLAYER_INFO)
 			Sys_Error("Unexpected repsonse to Player Info request\n");
 
-		playerNumber = MSG_ReadByte();
+		MSG_ReadByte();	/* playerNumber */
 		Q_strcpy(name, MSG_ReadString());
 		colors = MSG_ReadLong();
 		frags = MSG_ReadLong();
--- a/net_udp.c
+++ b/net_udp.c
@@ -23,14 +23,14 @@
 
 int UDP_Init (void)
 {
+	/*
 	struct hostent *local;
-	/*char	buff[MAXHOSTNAMELEN];*/
+	char	buff[MAXHOSTNAMELEN];
 	struct qsockaddr addr;
 	char *colon;
 	
 	if (COM_CheckParm ("-noudp"))
 		return -1;
-	/*
 	// determine my name & address
 	gethostname(buff, MAXHOSTNAMELEN);
 	local = gethostbyname(buff);
@@ -72,7 +72,7 @@
 	*/
 }
 
-void UDP_Listen (qboolean state)
+void UDP_Listen (qboolean /*state*/)
 {
 	/*
 	// enable listening
@@ -93,7 +93,7 @@
 	*/
 }
 
-int UDP_OpenSocket (int port)
+int UDP_OpenSocket (int /*port*/)
 {
 	/*
 	int newsocket;
@@ -121,7 +121,7 @@
 	return -1;
 }
 
-int UDP_CloseSocket (int socket)
+int UDP_CloseSocket (int /*socket*/)
 {
 	/*
 	if (socket == net_broadcastsocket)
@@ -139,7 +139,7 @@
 the local network components to fill in the rest
 ============
 */
-static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
+static int PartialIPAddress (char */*in*/, struct qsockaddr */*hostaddr*/)
 {
 	/*
 	char buff[256];
@@ -191,7 +191,7 @@
 	return -1;
 }
 
-int UDP_Connect (int socket, struct qsockaddr *addr)
+int UDP_Connect (int /*socket*/, struct qsockaddr */*addr*/)
 {
 	return 0;
 }
@@ -213,7 +213,7 @@
 	return -1;
 }
 
-int UDP_Read (int socket, byte *buf, int len, struct qsockaddr *addr)
+int UDP_Read (int /*socket*/, byte */*buf*/, int /*len*/, struct qsockaddr */*addr*/)
 {
 	/*
 	int addrlen = sizeof (struct qsockaddr);
@@ -227,7 +227,7 @@
 	return -1;
 }
 
-int UDP_MakeSocketBroadcastCapable (int socket)
+int UDP_MakeSocketBroadcastCapable (int /*socket*/)
 {
 	/*
 	int				i = 1;
@@ -242,7 +242,7 @@
 	return -1;
 }
 
-int UDP_Broadcast (int socket, byte *buf, int len)
+int UDP_Broadcast (int /*socket*/, byte */*buf*/, int /*len*/)
 {
 	/*
 	int ret;
@@ -264,7 +264,7 @@
 	return -1;
 }
 
-int UDP_Write (int socket, byte *buf, int len, struct qsockaddr *addr)
+int UDP_Write (int /*socket*/, byte */*buf*/, int /*len*/, struct qsockaddr */*addr*/)
 {
 	/*
 	int ret;
@@ -277,7 +277,7 @@
 	return -1;
 }
 
-char *UDP_AddrToString (struct qsockaddr *addr)
+char *UDP_AddrToString (struct qsockaddr */*addr*/)
 {
 	/*
 	static char buffer[22];
@@ -290,7 +290,7 @@
 	return nil;
 }
 
-int UDP_StringToAddr (char *string, struct qsockaddr *addr)
+int UDP_StringToAddr (char */*string*/, struct qsockaddr */*addr*/)
 {
 	/*
 	int ha1, ha2, ha3, ha4, hp;
@@ -307,7 +307,7 @@
 	return -1;
 }
 
-int UDP_GetSocketAddr (int socket, struct qsockaddr *addr)
+int UDP_GetSocketAddr (int /*socket*/, struct qsockaddr */*addr*/)
 {
 	/*
 	int addrlen = sizeof(struct qsockaddr);
@@ -324,7 +324,7 @@
 	return -1;
 }
 
-int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name)
+int UDP_GetNameFromAddr (struct qsockaddr */*addr*/, char */*name*/)
 {
 	/*
 	struct hostent *hostentry;
@@ -342,7 +342,7 @@
 	return -1;
 }
 
-int UDP_GetAddrFromName(char *name, struct qsockaddr *addr)
+int UDP_GetAddrFromName(char */*name*/, struct qsockaddr */*addr*/)
 {
 	/*
 	struct hostent *hostentry;
@@ -363,7 +363,7 @@
 	return -1;
 }
 
-int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
+int UDP_AddrCompare (struct qsockaddr */*addr1*/, struct qsockaddr */*addr2*/)
 {
 	/*
 	if (addr1->sa_family != addr2->sa_family)
@@ -380,13 +380,13 @@
 	return -1;
 }
 
-int UDP_GetSocketPort (struct qsockaddr *addr)
+int UDP_GetSocketPort (struct qsockaddr */*addr*/)
 {
 	//return ntohs(((struct sockaddr_in *)addr)->sin_port);
 	return -1;
 }
 
-int UDP_SetSocketPort (struct qsockaddr *addr, int port)
+int UDP_SetSocketPort (struct qsockaddr */*addr*/, int /*port*/)
 {
 	/*
 	((struct sockaddr_in *)addr)->sin_port = htons(port);
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -1232,10 +1232,8 @@
 	int		i, j;
 	trace_t	tr;
 	float	dist, bestdist;
-	float	speed;
 	
 	ent = G_EDICT(OFS_PARM0);
-	speed = G_FLOAT(OFS_PARM1);
 
 	VectorCopy (ent->v.origin, start);
 	start[2] += 20;
--- a/snd_9.c
+++ b/snd_9.c
@@ -65,7 +65,7 @@
 	shm->submission_chunk = 1;
 
 	if((shm->buffer = mallocz(shm->samplebits/8 * shm->samples, 1)) == nil)
-		Sys_Error("SNDDMA_Init:malloc: %r\n");
+		Sys_Error("SNDDMA_Init:mallocz: %r\n");
 	shm->samplepos = 0;
 	snd_inited = 1;
 	schan = chancreate(sizeof(int), Nbuf);
--- a/sys_9.c
+++ b/sys_9.c
@@ -84,7 +84,7 @@
 		print("%s\n", end2);
 	else
 		print("%s\n", end1);
-	exits(nil);
+	threadexitsall(nil);
 }
 
 void Sys_Error (char *error, ...)
@@ -95,9 +95,10 @@
 	va_start(arg, error);
 	out = vseprint(buf, buf+sizeof(buf), error, arg);
 	va_end(arg);
+	out = seprint(out, buf+sizeof(buf), "\n");
 	write(2, buf, out-buf);
 	Host_Shutdown();
-	sysfatal("ending");
+	sysfatal("ending.");
 } 
 
 int Sys_FileTime (char *path)
--- a/vid.h
+++ b/vid.h
@@ -40,13 +40,13 @@
 extern void (*vid_menudrawfn)(void);
 extern void (*vid_menukeyfn)(int key);
 
-void	VID_SetPalette (unsigned char *palette);
+void	VID_SetPalette (uchar *palette);
 // called at startup and after any gamma correction
 
-void	VID_ShiftPalette (unsigned char *palette);
+void	VID_ShiftPalette (uchar *palette);
 // called for bonus and pain flashes, and for underwater color changes
 
-void	VID_Init (unsigned char *palette);
+void	VID_Init (uchar *palette);
 // Called at startup to set up translation tables, takes 256 8 bit RGB values
 // the palette data will go away after the call, so it must be copied off if
 // the video driver will need it again
@@ -56,11 +56,3 @@
 
 void	VID_Update (vrect_t *rects);
 // flushes the given rectangles from the view buffer to the screen
-
-int VID_SetMode (int modenum, unsigned char *palette);
-// 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);
-// called only on Win32, when pause happens, so the mouse can be released
-
--- a/vid_9.c
+++ b/vid_9.c
@@ -10,7 +10,6 @@
 
 int config_notify;
 int ignorenext;
-int bits_per_pixel;
 viddef_t vid;	// global video state
 unsigned short d_8to16table[256];
 int d_con_indirect = 0;
@@ -21,15 +20,15 @@
 int X11_buffersize;
 int vid_surfcachesize;
 void *vid_surfcache;
-typedef u16int PIXEL16;
+Point center;		/* of window */
+Rectangle grabout;	/* center mouse outside of this if cvar set */
+
+
 typedef u32int PIXEL24;
-PIXEL16 st2d_8to16table[256];
 PIXEL24 st2d_8to24table[256];
 int shiftmask_fl = 0;
 int r_shift, g_shift, b_shift;
 uint r_mask, g_mask, b_mask;
-Point center;		/* of window */
-Rectangle grabout;	/* center mouse outside of this if cvar set */
 
 void (*vid_menudrawfn)(void);
 void (*vid_menukeyfn)(int key);
@@ -50,33 +49,6 @@
 	shiftmask_fl = 1;
 }
 
-PIXEL16 xlib_rgb16 (int r, int g, int b)
-{
-	PIXEL16 p = 0;
-
-	if(shiftmask_fl == 0)
-		shiftmask_init();
-	if(r_shift > 0){
-		p = r<<r_shift & r_mask;
-	}else if(r_shift < 0){
-		p = r>>-r_shift & r_mask;
-	}else
-		p |= r & r_mask;
-	if(g_shift > 0){
-		p |= g<<g_shift & g_mask;
-	}else if(g_shift < 0){
-		p |= g>>-g_shift & g_mask;
-	}else
-		p |= g & g_mask;
-	if(b_shift > 0){
-		p |= b<<b_shift & b_mask;
-	}else if(b_shift < 0){
-		p |= b>>-b_shift & b_mask;
-	}else
-		p |= b & b_mask;
-	return p;
-}
-
 PIXEL24 xlib_rgb24 (int r, int g, int b)
 {
 	PIXEL24 p = 0;
@@ -104,41 +76,6 @@
 	return p;
 }
 
-void st2_fixup (uchar *data, int x, int y, int width, int height)
-{
-	int yi;
-	uchar *src;
-	PIXEL16 *dest;
-	register int count, n;
-
-	if(x < 0 || y < 0)
-		return;
-
-	for(yi = y; yi < y+height; yi++){
-		src = &data[yi*vid.rowbytes];
-
-		// Duff's Device
-		count = width;
-		n = (count+7) / 8;
-		dest = ((PIXEL16 *)src) + x+width-1;
-		src += x+width-1;
-
-		switch(count % 8){
-		case 0:	do{	*dest-- = st2d_8to16table[*src--];
-		case 7:		*dest-- = st2d_8to16table[*src--];
-		case 6:		*dest-- = st2d_8to16table[*src--];
-		case 5:		*dest-- = st2d_8to16table[*src--];
-		case 4:		*dest-- = st2d_8to16table[*src--];
-		case 3:		*dest-- = st2d_8to16table[*src--];
-		case 2:		*dest-- = st2d_8to16table[*src--];
-		case 1:		*dest-- = st2d_8to16table[*src--];
-			}while(--n > 0);
-		}
-		//for(xi = x+width-1; xi >= x; xi--)
-		//	dest[xi] = st2d_8to16table[src[xi]];
-	}
-}
-
 void st3_fixup (uchar *data, int x, int y, int width, int height)
 {
 	int yi;
@@ -214,8 +151,7 @@
 // Called at startup to set up translation tables, takes 256 8 bit RGB values
 // the palette data will go away after the call, so it must be copied off if
 // the video driver will need it again
-
-void VID_Init (unsigned char *palette)
+void VID_Init (uchar */*palette*/)
 {
 	ignorenext = 0;
 	vid.maxwarpwidth = WARP_WIDTH;
@@ -232,41 +168,21 @@
 		Sys_Error("VID_Init:initdraw: %r\n");
 	vid.width = Dx(screen->r);
 	vid.height = Dy(screen->r);
-	if(screen->chan == CMAP8)
-		VID_SetPalette(palette);
 	ResetFrameBuffer();
 	vid.direct = 0;
 }
 
-void VID_ShiftPalette (unsigned char *p)
+void VID_ShiftPalette (uchar *p)
 {
 	VID_SetPalette(p);
 }
 
-void VID_SetPalette (unsigned char *palette)
+void VID_SetPalette (uchar *palette)
 {
 	int i;
 
-	for(i = 0; i < 256; i++){
-		st2d_8to16table[i] = xlib_rgb16(palette[i*3], palette[i*3+1], palette[i*3+2]);
+	for(i = 0; i < 256; i++)
 		st2d_8to24table[i] = xlib_rgb24(palette[i*3], palette[i*3+1], palette[i*3+2]);
-	}
-	if(screen->chan == 8){
-		if(palette != current_palette)
-			memcpy(current_palette, palette, 768);
-		/* FIXME
-		XColor colors[256];
-		for(i = 0 ; i < 256 ; i++){
-			colors[i].pixel = i;
-			colors[i].flags = DoRed|DoGreen|DoBlue;
-			colors[i].red = palette[i*3] * 257;
-			colors[i].green = palette[i*3+1] * 257;
-			colors[i].blue = palette[i*3+2] * 257;
-		}
-		XStoreColors(x_disp, x_cmap, colors, 256);
-		*/
-	}
-
 }
 
 void VID_Shutdown (void)
@@ -291,17 +207,10 @@
 		return;
 	}
 
-	if(screen->chan != CMAP8)	/* force full update if not 8bit */
-		scr_fullupdate = 0;
+	scr_fullupdate = 0;	/* force full update if not 8bit (cf. screen.h) */
 
 	while(rects){
-		if(screen->chan == RGB16)
-			st2_fixup(framebuf, rects->x, rects->y,
-				rects->width, rects->height);
-		/* FIXME: ??? just assume truecolor? (not RGB16 or CMAP8) */
-		else if(screen->chan == RGB24 || screen->chan == RGBA32 || screen->chan == XRGB32)
-			st3_fixup(framebuf, rects->x, rects->y,
-				rects->width, rects->height);
+		st3_fixup(framebuf, rects->x, rects->y, rects->width, rects->height);
 		rects = rects->pnext;
 	}
 	loadimage(fbim, fbim->r, framebuf, vid.height * vid.rowbytes);