[Quake2world-dev] r214 - quake2world/trunk/src

jdolan at jdolan.dyndns.org jdolan at jdolan.dyndns.org
Tue Feb 24 01:21:44 UTC 2009


Author: jdolan
Date: 2009-02-24 01:21:43 +0000 (Tue, 24 Feb 2009)
New Revision: 214

Modified:
   quake2world/trunk/src/cl_console.c
   quake2world/trunk/src/cl_emit.c
   quake2world/trunk/src/cl_http.c
   quake2world/trunk/src/cl_main.c
   quake2world/trunk/src/cl_parse.c
   quake2world/trunk/src/client.h
   quake2world/trunk/src/r_main.c
Log:
Fix several potential crashes during full r_restart.  Clean up cls.download.disk nonsense.

Modified: quake2world/trunk/src/cl_console.c
===================================================================
--- quake2world/trunk/src/cl_console.c	2009-02-23 04:44:06 UTC (rev 213)
+++ quake2world/trunk/src/cl_console.c	2009-02-24 01:21:43 UTC (rev 214)
@@ -201,7 +201,8 @@
 	int y;
 	char dl[MAX_STRING_CHARS];
 
-	height = (r_state.height * frac);
+	height = (int)((float)r_state.height * frac);
+
 	if(height <= 0)  // nothing to do
 		return;
 
@@ -216,26 +217,30 @@
 	// draw the text
 	lines = cl_con.height;
 	y = 0;
-	for (line = cl_con.lastline - cl_con.scroll - lines; line < cl_con.lastline - cl_con.scroll; line++) {
-		if (line >= 0 && cl_con.linestart[line][0] != '\0') {
-			R_DrawBytes(0, y, cl_con.linestart[line], cl_con.linestart[line + 1] - cl_con.linestart[line], cl_con.linecolor[line]);
+	for(line = cl_con.lastline - cl_con.scroll - lines;
+			line < cl_con.lastline - cl_con.scroll; line++){
+
+		if(line >= 0 && cl_con.linestart[line][0] != '\0'){
+			R_DrawBytes(0, y, cl_con.linestart[line],
+					cl_con.linestart[line + 1] - cl_con.linestart[line], cl_con.linecolor[line]);
 		}
 		y += 32;
 	}
 
-	// draw loading progress
-	if(cls.download.disk){
-		snprintf(dl, sizeof(dl), "Loading... %2d%%", cls.download.percent);
+	if(cls.loading){  // draw loading progress
+		snprintf(dl, sizeof(dl), "Loading... %2d%%", cls.loading);
 		R_DrawString(0, cl_con.height << 5, dl, CON_COLOR_INFO);
-	} else
-	// draw download progress
-	if(cls.download.file && (kb = (int)ftell(cls.download.file) / 1024)){
+	}
+	else if(cls.download.file){  // draw download progress
 
+		kb = (int)ftell(cls.download.file) / 1024;
+
 		snprintf(dl, sizeof(dl), "%s [%s] %dKB ", cls.download.name,
 				(cls.download.http ? "HTTP" : "UDP"), kb);
 
 		R_DrawString(0, cl_con.height << 5, dl, CON_COLOR_INFO);
-	} else
-		// draw the input prompt, user text, and cursor if desired
+	}
+	else {  // draw the input prompt, user text, and cursor if desired
 		Con_DrawInput();
+	}
 }

Modified: quake2world/trunk/src/cl_emit.c
===================================================================
--- quake2world/trunk/src/cl_emit.c	2009-02-23 04:44:06 UTC (rev 213)
+++ quake2world/trunk/src/cl_emit.c	2009-02-24 01:21:43 UTC (rev 214)
@@ -310,14 +310,18 @@
 static void Cl_UpdateEmits(void){
 	int i;
 
-	if(r_view.update){  // reload models
+	if(r_view.update){  // resolve leafs, reload models
 
 		for(i = 0; i < num_emits; i++){
 
 			emit_t *e = &emits[i];
 
-			if(e->flags & EMIT_MODEL)
+			e->leaf = R_LeafForPoint(e->org, r_worldmodel);
+
+			if(e->flags & EMIT_MODEL){
 				e->mod = R_LoadModel(e->model);
+				e->lighting.dirty = true;
+			}
 		}
 	}
 

Modified: quake2world/trunk/src/cl_http.c
===================================================================
--- quake2world/trunk/src/cl_http.c	2009-02-23 04:44:06 UTC (rev 213)
+++ quake2world/trunk/src/cl_http.c	2009-02-24 01:21:43 UTC (rev 214)
@@ -191,7 +191,6 @@
 		unlink(file);  // delete partial or empty file
 	}
 
-	cls.download.percent = 0;
 	cls.download.http = false;
 
 	status = length = 0;

Modified: quake2world/trunk/src/cl_main.c
===================================================================
--- quake2world/trunk/src/cl_main.c	2009-02-23 04:44:06 UTC (rev 213)
+++ quake2world/trunk/src/cl_main.c	2009-02-24 01:21:43 UTC (rev 214)
@@ -370,8 +370,9 @@
  * Called after an ERR_DROP or ERR_NONE was thrown
  */
 void Cl_Drop(void){
-	cls.download.disk = false;
 
+	cls.loading = 0;
+
 	if(cls.state == ca_uninitialized)
 		return;
 
@@ -791,7 +792,7 @@
  */
 void Cl_LoadProgress(int percent){
 
-	cls.download.percent = percent;
+	cls.loading = percent;
 
 	Cl_UpdateScreen();
 }
@@ -802,8 +803,7 @@
  */
 static void Cl_LoadMedia(void){
 
-	cls.download.percent = 0;
-	cls.download.disk = true;
+	cls.loading = 1;
 
 	R_LoadMedia();
 
@@ -813,7 +813,7 @@
 
 	Cl_LoadLocations();
 
-	cls.download.disk = false;
+	cls.loading = 0;
 }
 
 
@@ -872,28 +872,30 @@
 	Cl_RequestNextDownload();
 }
 
+
 /*
  * Cl_GetUserName
  */
 static const char *Cl_GetUserName(void){
+	const char *username = Sys_GetCurrentUser();
 
-	const char *username = Sys_GetCurrentUser();
-	if (username[0] == '\0')
+	if(username[0] == '\0')
 		username = "newbie";
 
-	Com_Printf("Username: %s\n", username);
 	return username;
 }
 
+
 /*
  * Cl_InitLocal
  */
 static void Cl_InitLocal(void){
 	int bits;
 
+	memset(&cls, 0, sizeof(cls));
+
 	cls.state = ca_disconnected;
 	cls.realtime = curtime;
-	cls.download.disk = false;
 
 	Cl_ClearState();
 

Modified: quake2world/trunk/src/cl_parse.c
===================================================================
--- quake2world/trunk/src/cl_parse.c	2009-02-23 04:44:06 UTC (rev 213)
+++ quake2world/trunk/src/cl_parse.c	2009-02-24 01:21:43 UTC (rev 214)
@@ -188,9 +188,6 @@
 	net_message.readcount += size;
 
 	if(percent != 100){
-
-		cls.download.percent = percent;
-
 		Msg_WriteByte(&cls.netchan.message, clc_stringcmd);
 		Sb_Print(&cls.netchan.message, "nextdl");
 	} else {
@@ -207,7 +204,6 @@
 			Com_Warn("Failed to rename %s to %s.\n", oldn, newn);
 
 		cls.download.file = NULL;
-		cls.download.percent = 0;
 
 		if(strstr(newn, ".pak"))  // append paks to searchpaths
 			Fs_AddPakfile(newn);

Modified: quake2world/trunk/src/client.h
===================================================================
--- quake2world/trunk/src/client.h	2009-02-23 04:44:06 UTC (rev 213)
+++ quake2world/trunk/src/client.h	2009-02-24 01:21:43 UTC (rev 214)
@@ -149,12 +149,10 @@
 } keydest_t;
 
 typedef struct {
-	qboolean disk;
 	qboolean http;
 	FILE *file;
 	char tempname[MAX_OSPATH];
 	char name[MAX_OSPATH];
-	int percent;
 } download_t;
 
 typedef enum {
@@ -192,6 +190,8 @@
 
 	int challenge;  // from the server to use for connecting
 
+	int loading;  // loading percentage indicator
+
 	char downloadurl[MAX_OSPATH];  // for http downloads
 	download_t download;  // current download (udp or http)
 

Modified: quake2world/trunk/src/r_main.c
===================================================================
--- quake2world/trunk/src/r_main.c	2009-02-23 04:44:06 UTC (rev 213)
+++ quake2world/trunk/src/r_main.c	2009-02-24 01:21:43 UTC (rev 214)
@@ -489,11 +489,20 @@
 
 	Cl_LoadClientinfo(&cl.baseclientinfo, "newbie\\ichabod/ichabod");
 
-	// clients
+	j = 0;
+
+	// client models and skins
 	for(i = 0; i < MAX_CLIENTS; i++){
+
 		if(!cl.configstrings[CS_PLAYERSKINS + i][0])
 			continue;
+
 		Cl_ParseClientinfo(i);
+
+		if(++j == 10)
+			j = 10;
+
+		Cl_LoadProgress(75 + j);
 	}
 	Cl_LoadProgress(85);
 
@@ -529,8 +538,7 @@
 
 	r_view.ready = false;
 
-	cls.download.percent = 0;
-	cls.download.disk = true;
+	cls.loading = 1;
 
 	R_DrawFill(0, 0, r_view.width, r_view.height, 0);
 
@@ -544,7 +552,7 @@
 
 	Cvar_ClearVars(CVAR_R_IMAGES);
 
-	cls.download.disk = false;
+	cls.loading = 0;
 }
 
 



More information about the Quake2World-dev mailing list