[quake3-commits] r2076 - in trunk/code: q3_ui ui

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Jul 13 04:40:31 EDT 2011


Author: thilo
Date: 2011-07-13 04:40:30 -0400 (Wed, 13 Jul 2011)
New Revision: 2076

Modified:
   trunk/code/q3_ui/ui_demo2.c
   trunk/code/ui/ui_atoms.c
   trunk/code/ui/ui_local.h
   trunk/code/ui/ui_main.c
Log:
- Add dual protocol support to team arena demo selector
- Fix demo selection in team arena menu on case sensitive file systems
- Some changes in the way how vanilla q3 demo file lists are compiled in the menu


Modified: trunk/code/q3_ui/ui_demo2.c
===================================================================
--- trunk/code/q3_ui/ui_demo2.c	2011-07-12 11:59:48 UTC (rev 2075)
+++ trunk/code/q3_ui/ui_demo2.c	2011-07-13 08:40:30 UTC (rev 2076)
@@ -72,8 +72,6 @@
 
 	int				numDemos;
 	char			names[NAMEBUFSIZE];
-	int				numLegacyDemos;
-	char			namesLegacy[NAMEBUFSIZE];
 	
 	char			*demolist[MAX_DEMOS];
 } demos_t;
@@ -133,7 +131,7 @@
 ===============
 */
 static void Demos_MenuInit( void ) {
-	int		i;
+	int		i, j;
 	int		len;
 	char	*demoname, extension[32];
 	int	protocol, protocolLegacy;
@@ -239,50 +237,47 @@
 		protocolLegacy = 0;
 
 	Com_sprintf(extension, sizeof(extension), ".%s%d", DEMOEXT, protocol);
-	s_demos.numDemos = trap_FS_GetFileList("demos", extension, s_demos.names, NAMEBUFSIZE);
+	s_demos.numDemos = trap_FS_GetFileList("demos", extension, s_demos.names, ARRAY_LEN(s_demos.names));
 
-	if(s_demos.numDemos > MAX_DEMOS)
-		s_demos.numDemos = MAX_DEMOS;
-	
-	if(protocolLegacy > 0)
+	demoname = s_demos.names;
+	i = 0;
+
+	for(j = 0; j < 2; j++)
 	{
-		Com_sprintf(extension, sizeof(extension), ".%s%d", DEMOEXT, protocolLegacy);
-		s_demos.numLegacyDemos = trap_FS_GetFileList("demos", extension, s_demos.namesLegacy, NAMEBUFSIZE);
-	}
-	else
-		s_demos.numLegacyDemos = 0;
+		if(s_demos.numDemos > MAX_DEMOS)
+			s_demos.numDemos = MAX_DEMOS;
 
-	s_demos.list.numitems = s_demos.numDemos + s_demos.numLegacyDemos;
+		for(; i < s_demos.numDemos; i++)
+		{
+			s_demos.list.itemnames[i] = demoname;
+		
+			len = strlen(demoname);
 
+			demoname += len + 1;
+		}
 
-	if (!s_demos.list.numitems) {
-		strcpy( s_demos.names, "No Demos Found." );
-		s_demos.list.numitems = 1;
-
-		//degenerate case, not selectable
-		s_demos.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
+		if(!j)
+		{
+			if(protocolLegacy > 0 && s_demos.numDemos < MAX_DEMOS)
+			{
+				Com_sprintf(extension, sizeof(extension), ".%s%d", DEMOEXT, protocolLegacy);
+				s_demos.numDemos += trap_FS_GetFileList("demos", extension, demoname,
+									ARRAY_LEN(s_demos.names) - (demoname - s_demos.names));
+			}
+			else
+				break;
+		}
 	}
-	else if (s_demos.list.numitems > MAX_DEMOS)
-		s_demos.list.numitems = MAX_DEMOS;
 
-	demoname = s_demos.names;
-	for(i = 0; i < s_demos.numDemos; i++)
-	{
-		s_demos.list.itemnames[i] = demoname;
-		
-		len = strlen(demoname);
+	s_demos.list.numitems = s_demos.numDemos;
 
-		demoname += len + 1;
-	}
-
-	demoname = s_demos.namesLegacy;
-	for(; i < s_demos.list.numitems; i++)
+	if(!s_demos.numDemos)
 	{
-		s_demos.list.itemnames[i] = demoname;
-		
-		len = strlen(demoname);
+		s_demos.list.itemnames[0] = "No Demos Found.";
+		s_demos.list.numitems = 1;
 
-		demoname += len + 1;
+		//degenerate case, not selectable
+		s_demos.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
 	}
 
 	Menu_AddItem( &s_demos.menu, &s_demos.banner );

Modified: trunk/code/ui/ui_atoms.c
===================================================================
--- trunk/code/ui/ui_atoms.c	2011-07-12 11:59:48 UTC (rev 2075)
+++ trunk/code/ui/ui_atoms.c	2011-07-13 08:40:30 UTC (rev 2076)
@@ -146,10 +146,13 @@
 	}
 }
 
-void UI_LoadBestScores(const char *map, int game) {
+void UI_LoadBestScores(const char *map, int game)
+{
 	char		fileName[MAX_QPATH];
 	fileHandle_t f;
 	postGameInfo_t newInfo;
+	int protocol, protocolLegacy;
+	
 	memset(&newInfo, 0, sizeof(postGameInfo_t));
 	Com_sprintf(fileName, MAX_QPATH, "games/%s_%i.game", map, game);
 	if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) {
@@ -162,11 +165,30 @@
 	}
 	UI_SetBestScores(&newInfo, qfalse);
 
-	Com_sprintf(fileName, MAX_QPATH, "demos/%s_%d.%s%d", map, game, DEMOEXT, (int)trap_Cvar_VariableValue("protocol"));
 	uiInfo.demoAvailable = qfalse;
-	if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) {
+
+	protocolLegacy = trap_Cvar_VariableValue("com_legacyprotocol");
+	protocol = trap_Cvar_VariableValue("com_protocol");
+
+	if(!protocol)
+		protocol = trap_Cvar_VariableValue("protocol");
+	if(protocolLegacy == protocol)
+		protocolLegacy = 0;
+
+	Com_sprintf(fileName, MAX_QPATH, "demos/%s_%d.%s%d", map, game, DEMOEXT, protocol);
+	if(trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0)
+	{
 		uiInfo.demoAvailable = qtrue;
 		trap_FS_FCloseFile(f);
+	}
+	else if(protocolLegacy > 0)
+	{
+		Com_sprintf(fileName, MAX_QPATH, "demos/%s_%d.%s%d", map, game, DEMOEXT, protocolLegacy);
+		if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0)
+		{
+			uiInfo.demoAvailable = qtrue;
+			trap_FS_FCloseFile(f);
+		}
 	} 
 }
 

Modified: trunk/code/ui/ui_local.h
===================================================================
--- trunk/code/ui/ui_local.h	2011-07-12 11:59:48 UTC (rev 2075)
+++ trunk/code/ui/ui_local.h	2011-07-13 08:40:30 UTC (rev 2076)
@@ -631,7 +631,7 @@
 #define MAPS_PER_TIER 3
 #define MAX_TIERS 16
 #define MAX_MODS 64
-#define MAX_DEMOS 256
+#define MAX_DEMOS 512
 #define MAX_MOVIES 256
 #define MAX_PLAYERMODELS 256
 

Modified: trunk/code/ui/ui_main.c
===================================================================
--- trunk/code/ui/ui_main.c	2011-07-12 11:59:48 UTC (rev 2075)
+++ trunk/code/ui/ui_main.c	2011-07-13 08:40:30 UTC (rev 2076)
@@ -2863,39 +2863,57 @@
 
 }
 
+#define NAMEBUFSIZE (MAX_DEMOS * 32)
 
-
 /*
 ===============
 UI_LoadDemos
 ===============
 */
 static void UI_LoadDemos( void ) {
-	char	demolist[4096];
-	char demoExt[32];
+	char	demolist[NAMEBUFSIZE];
+	char	demoExt[32];
 	char	*demoname;
-	int		i, len;
+	int	i, j, len;
+	int	protocol, protocolLegacy;
 
-	Com_sprintf(demoExt, sizeof(demoExt), "%s%d", DEMOEXT, (int)trap_Cvar_VariableValue("protocol"));
+	protocolLegacy = trap_Cvar_VariableValue("com_legacyprotocol");
+	protocol = trap_Cvar_VariableValue("com_protocol");
 
-	uiInfo.demoCount = trap_FS_GetFileList( "demos", demoExt, demolist, 4096 );
+	if(!protocol)
+		protocol = trap_Cvar_VariableValue("protocol");
+	if(protocolLegacy == protocol)
+		protocolLegacy = 0;
 
-	Com_sprintf(demoExt, sizeof(demoExt), ".%s%d", DEMOEXT, (int)trap_Cvar_VariableValue("protocol"));
+	Com_sprintf(demoExt, sizeof(demoExt), ".%s%d", DEMOEXT, protocol);
+	uiInfo.demoCount = trap_FS_GetFileList("demos", demoExt, demolist, ARRAY_LEN(demolist));
+	
+	demoname = demolist;
+	i = 0;
 
-	if (uiInfo.demoCount) {
-		if (uiInfo.demoCount > MAX_DEMOS) {
+	for(j = 0; j < 2; j++)
+	{
+		if(uiInfo.demoCount > MAX_DEMOS)
 			uiInfo.demoCount = MAX_DEMOS;
-		}
-		demoname = demolist;
-		for ( i = 0; i < uiInfo.demoCount; i++ ) {
-			len = strlen( demoname );
-			if (!Q_stricmp(demoname +  len - strlen(demoExt), demoExt)) {
-				demoname[len-strlen(demoExt)] = '\0';
-			}
-			Q_strupr(demoname);
+
+		for(; i < uiInfo.demoCount; i++)
+		{
+			len = strlen(demoname);
 			uiInfo.demoList[i] = String_Alloc(demoname);
 			demoname += len + 1;
 		}
+		
+		if(!j)
+		{
+		        if(protocolLegacy > 0 && uiInfo.demoCount < MAX_DEMOS)
+		        {
+                        	Com_sprintf(demoExt, sizeof(demoExt), ".%s%d", DEMOEXT, protocolLegacy);
+                        	uiInfo.demoCount += trap_FS_GetFileList("demos", demoExt, demolist, ARRAY_LEN(demolist));
+                        	demoname = demolist;
+                        }
+                        else
+                                break;
+		}
 	}
 
 }



More information about the quake3-commits mailing list