From 8b7d9f9021b15f4de018a31434b8096eff225837 Mon Sep 17 00:00:00 2001 From: Richard Allen Date: Mon, 18 Jul 2011 16:27:47 +0000 Subject: [PATCH] IOQ3 commit 2076 --- reaction/code/q3_ui/ui_demo2.c | 71 +++++++++++++++------------------ reaction/code/ui/ui_atoms.c | 24 ++++++++++- reaction/code/ui/ui_local.h | 2 +- reaction/code/ui/ui_main.c | 73 +++++++++++++++++++--------------- 4 files changed, 96 insertions(+), 74 deletions(-) diff --git a/reaction/code/q3_ui/ui_demo2.c b/reaction/code/q3_ui/ui_demo2.c index f63bcdf7..a16a762b 100644 --- a/reaction/code/q3_ui/ui_demo2.c +++ b/reaction/code/q3_ui/ui_demo2.c @@ -72,8 +72,6 @@ typedef struct { int numDemos; char names[NAMEBUFSIZE]; - int numLegacyDemos; - char namesLegacy[NAMEBUFSIZE]; char *demolist[MAX_DEMOS]; } demos_t; @@ -133,7 +131,7 @@ Demos_MenuInit =============== */ static void Demos_MenuInit( void ) { - int i; + int i, j; int len; char *demoname, extension[32]; int protocol, protocolLegacy; @@ -239,51 +237,48 @@ static void Demos_MenuInit( void ) { 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); + if(s_demos.numDemos > MAX_DEMOS) + s_demos.numDemos = MAX_DEMOS; + + for(; i < s_demos.numDemos; i++) + { + s_demos.list.itemnames[i] = demoname; + + len = strlen(demoname); + + demoname += len + 1; + } + + 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 - s_demos.numLegacyDemos = 0; - s_demos.list.numitems = s_demos.numDemos + s_demos.numLegacyDemos; + s_demos.list.numitems = s_demos.numDemos; - - if (!s_demos.list.numitems) { - strcpy( s_demos.names, "No Demos Found." ); + if(!s_demos.numDemos) + { + s_demos.list.itemnames[0] = "No Demos Found."; s_demos.list.numitems = 1; //degenerate case, not selectable s_demos.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN); } - 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); - - demoname += len + 1; - } - - demoname = s_demos.namesLegacy; - for(; i < s_demos.list.numitems; i++) - { - s_demos.list.itemnames[i] = demoname; - - len = strlen(demoname); - - demoname += len + 1; - } Menu_AddItem( &s_demos.menu, &s_demos.banner ); Menu_AddItem( &s_demos.menu, &s_demos.framel ); diff --git a/reaction/code/ui/ui_atoms.c b/reaction/code/ui/ui_atoms.c index c7ab0573..c049b1cc 100644 --- a/reaction/code/ui/ui_atoms.c +++ b/reaction/code/ui/ui_atoms.c @@ -213,6 +213,7 @@ 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); @@ -226,12 +227,31 @@ void UI_LoadBestScores(const char *map, int game) } UI_SetBestScores(&newInfo, qfalse); - Com_sprintf(fileName, MAX_QPATH, "demos/%s_%d.dm_%d", map, game, (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); + } + } } /* diff --git a/reaction/code/ui/ui_local.h b/reaction/code/ui/ui_local.h index 6f3eb6ad..a55099df 100644 --- a/reaction/code/ui/ui_local.h +++ b/reaction/code/ui/ui_local.h @@ -788,7 +788,7 @@ qboolean UI_RQ3_WeaponMenuAccess( void ); #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 diff --git a/reaction/code/ui/ui_main.c b/reaction/code/ui/ui_main.c index 48547096..afecbfcc 100644 --- a/reaction/code/ui/ui_main.c +++ b/reaction/code/ui/ui_main.c @@ -5384,6 +5384,8 @@ static void UI_LoadMovies( void ) } +#define NAMEBUFSIZE (MAX_DEMOS * 32) + /* =============== UI_LoadDemos @@ -5448,47 +5450,52 @@ void UI_SortDemoList(int start, int end, int column) } } -static void UI_LoadDemos( void ) -{ - char demolist[4096]; - char demoExt[32]; - char *demoname; - int i, j, len, protocol = (int) trap_Cvar_VariableValue("protocol"); +static void UI_LoadDemos( void ) { + char demolist[NAMEBUFSIZE]; + char demoExt[32]; + char *demoname; + int i, j, len; + int protocol, protocolLegacy; - uiInfo.demoCount = 0; - //Makro - old code was using just the "protocol" cvar; replaced with a for loop - for (j=66; j<=protocol; j++) + 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(demoExt, sizeof(demoExt), ".%s%d", DEMOEXT, protocol); + uiInfo.demoCount = trap_FS_GetFileList("demos", demoExt, demolist, ARRAY_LEN(demolist)); + + demoname = demolist; + i = 0; + + for(j = 0; j < 2; j++) { - int count; - //Com_sprintf(demoExt, sizeof(demoExt), "dm_%d", (int) trap_Cvar_VariableValue("protocol")); - Com_sprintf(demoExt, sizeof(demoExt), "dm_%d", j); + if(uiInfo.demoCount > MAX_DEMOS) + uiInfo.demoCount = MAX_DEMOS; - count = trap_FS_GetFileList("demos", demoExt, demolist, 4096); + for(; i < uiInfo.demoCount; i++) + { + len = strlen(demoname); + uiInfo.demoList[i] = String_Alloc(demoname); + demoname += len + 1; + } - //Com_sprintf(demoExt, sizeof(demoExt), ".dm_%d", (int) trap_Cvar_VariableValue("protocol")); - Com_sprintf(demoExt, sizeof(demoExt), ".dm_%d", j); - - if (count) { - //int start = uiInfo.demoCount+1; - //uiInfo.demoList[uiInfo.demoCount++] = String_Alloc(va("*** Recorded with Quake 3 %s ***", q3VersionFromProtocol(j))); - demoname = demolist; - for (i = 0; i < count && uiInfo.demoCount <= MAX_DEMOS; i++) + if(!j) + { + if(protocolLegacy > 0 && uiInfo.demoCount < MAX_DEMOS) { - len = strlen(demoname); - if (!Q_stricmp(demoname + len - strlen(demoExt), demoExt)) - { - demoname[len - strlen(demoExt)] = '\0'; - } - //Makro - bad for linux users - //Q_strupr(demoname); - uiInfo.demoType[uiInfo.demoCount] = j; - //uiInfo.demoList[uiInfo.demoCount++] = String_Alloc(va("%s (%s)", demoname, q3VersionFromProtocol(j))); - uiInfo.demoList[uiInfo.demoCount++] = String_Alloc(demoname); - demoname += len + 1; + Com_sprintf(demoExt, sizeof(demoExt), ".%s%d", DEMOEXT, protocolLegacy); + uiInfo.demoCount += trap_FS_GetFileList("demos", demoExt, demolist, ARRAY_LEN(demolist)); + demoname = demolist; } + else + break; } } - UI_SortDemoList(0, uiInfo.demoCount, 0); + } static qboolean UI_SetNextMap(int actual, int index)