shithub: qk1

Download patch

ref: 65327985abf5b3619428eb0fc489d875fcb9555b
parent: 1b89f96bdfe8147e0ed8e0c35dc5cfdd2a48062c
author: Konstantinn Bonnet <qu7uux@gmail.com>
date: Mon Mar 9 18:28:18 EDT 2015

appropriate stack size for kproc, mproc, sproc; clean up mouseactive bool

mouseactive and mouse_avail were sort of redundant.
also some silly style changes.
also also free framebuf in VID_Shutdown().

--- a/README
+++ b/README
@@ -47,12 +47,12 @@
 
 todo/issues
 -----------
-	- compile with PARANOID -> MSG_WriteByte complains about range error and
-	  exits. no idea why.
+	- compiling with PARANOID reveals several points of failure that are otherwise
+          ignored, resulting in abnormal exit (also on linux)
 	- leave running for a couple of hours -> sound dies and eventually, invalid
 	  write/reads -> crash
-	- compile with BAN_TEST -> net_dgrm build fails
-	- sprites/particles not scaled correctly on high resolutions
+	- compile with BAN_TEST -> net_dgrm build fails (struct sockaddr_in)
+	- sprites/particles not scaled correctly on high resolutions (also in quake2)
 	- m_windowed 1: can still look around in frozen world when paused
 	- m_windowed 1: mouse can still escape, causing glitchy mouse look
 	- net_9p.c
--- a/in_9.c
+++ b/in_9.c
@@ -19,11 +19,10 @@
 cvar_t m_windowed = {"m_windowed","0", true};
 cvar_t m_filter = {"m_filter","0", true};
 float oldm_windowed;
-qboolean mouse_avail;
 int mouse_buttons = 3;
 int mouse_buttonstate, mouse_oldbuttonstate;
 float mouse_x, mouse_y, old_mouse_x, old_mouse_y;
-int mouseactive;
+int mouseon;
 int ktid = -1, mtid = -1;
 Channel *kchan;
 
@@ -57,7 +56,7 @@
 {
 	int i;
 
-	if(!mouse_avail)
+	if(!mouseon)
 		return;
 
 	/* FIXMEGASHIT */
@@ -72,7 +71,7 @@
 
 void IN_Move (usercmd_t *cmd)
 {
-	if(!mouse_avail)
+	if(!mouseon)
 		return;
    
 	if(m_filter.value){
@@ -222,7 +221,7 @@
 			config_notify = 1;
 			/* fall through */
 		case 'm':
-			if(!mouseactive)
+			if(!mouseon)
 				break;
 
 			x = atoi(buf+1+0*12) - center.x;
@@ -243,12 +242,12 @@
 
 void IN_Grabm (int on)
 {
-	static char nocurs[2*4+2*2*16] = {0};
+	static char nocurs[2*4+2*2*16];
 	static int fd = -1;
 
-	if(mouseactive == on)
+	if(mouseon == on)
 		return;
-	if(mouseactive = on){
+	if(mouseon = on){
 		if((fd = open("/dev/cursor", ORDWR|OCEXEC)) < 0){
 			Con_Printf("IN_Grabm:open: %r\n");
 			return;
@@ -273,10 +272,10 @@
 	}
 	chanclose(kchan);
 	chanfree(kchan);
-	mouse_avail = 0;
+	mouseon = 0;
 }
 
-void sucks(void *, char *note)
+void sucks (void *, char *note)
 {
 	if(!strncmp(note, "sys:", 4))
 		IN_Shutdown();
@@ -289,16 +288,13 @@
 	Cvar_RegisterVariable(&m_filter);
 	notify(sucks);
 	kchan = chancreate(sizeof(Kev), Nbuf);
-	if((ktid = proccreate(kproc, nil, mainstacksize)) < 0)
+	if((ktid = proccreate(kproc, nil, 8192)) < 0)
 		sysfatal("proccreate kproc: %r");
 	if(COM_CheckParm("-nomouse"))
 		return;
 	if(m_windowed.value)
 		IN_Grabm(1);
-	if((mtid = proccreate(mproc, nil, mainstacksize)) < 0)
+	if((mtid = proccreate(mproc, nil, 8192)) < 0)
 		sysfatal("proccreate mproc: %r");
 	mouse_x = mouse_y = 0.0;
-	/* FIXME: both kind of do the same thing */
-	//mouse_avail = mouseactive = 1;
-	mouse_avail = 1;
 }
--- a/snd_9.c
+++ b/snd_9.c
@@ -69,7 +69,7 @@
 	shm->samplepos = 0;
 	snd_inited = 1;
 	schan = chancreate(sizeof(int), Nbuf);
-	if((stid = proccreate(sproc, nil, mainstacksize)) < 0){
+	if((stid = proccreate(sproc, nil, 8192)) < 0){
 		stid = -1;
 		SNDDMA_Shutdown();
 		Sys_Error("SNDDMA_Init:proccreate: %r\n");
--- a/vid_9.c
+++ b/vid_9.c
@@ -49,29 +49,29 @@
 	shiftmask_fl = 1;
 }
 
-PIXEL24 xlib_rgb24 (int r, int g, int b)
+PIXEL24 rgb24 (int r, int g, int b)
 {
 	PIXEL24 p = 0;
 
 	if(shiftmask_fl == 0)
 		shiftmask_init();
-	if(r_shift > 0){
+	if(r_shift > 0)
 		p = r<<r_shift & r_mask;
-	}else if(r_shift < 0){
+	else if(r_shift < 0)
 		p = r>>-r_shift & r_mask;
-	}else
+	else
 		p |= r & r_mask;
-	if(g_shift > 0){
+	if(g_shift > 0)
 		p |= g<<g_shift & g_mask;
-	}else if(g_shift < 0){
+	else if(g_shift < 0)
 		p |= g>>-g_shift & g_mask;
-	}else
+	else
 		p |= g & g_mask;
-	if(b_shift > 0){
+	if(b_shift > 0)
 		p |= b<<b_shift & b_mask;
-	}else if(b_shift < 0){
+	else if(b_shift < 0)
 		p |= b>>-b_shift & b_mask;
-	}else
+	else
 		p |= b & b_mask;
 	return p;
 }
@@ -182,12 +182,13 @@
 	int i;
 
 	for(i = 0; i < 256; i++)
-		st2d_8to24table[i] = xlib_rgb24(palette[i*3], palette[i*3+1], palette[i*3+2]);
+		st2d_8to24table[i] = rgb24(palette[i*3], palette[i*3+1], palette[i*3+2]);
 }
 
 void VID_Shutdown (void)
 {
 	Con_Printf("VID_Shutdown\n");
+	free(framebuf);
 	freeimage(fbim);
 }