IOQ3 commit 2076

This commit is contained in:
Richard Allen 2011-07-18 16:27:47 +00:00
parent 6a2edcb095
commit 8b7d9f9021
4 changed files with 96 additions and 74 deletions

View file

@ -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;
demoname = s_demos.names;
i = 0;
if(protocolLegacy > 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 );

View file

@ -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);
}
}
}
/*

View file

@ -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

View file

@ -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)