- 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
This commit is contained in:
Thilo Schulz 2011-07-13 08:40:30 +00:00
parent e06c117e9e
commit a844c94af1
4 changed files with 94 additions and 59 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));
demoname = s_demos.names;
i = 0;
for(j = 0; j < 2; j++)
{
if(s_demos.numDemos > MAX_DEMOS)
s_demos.numDemos = MAX_DEMOS;
if(protocolLegacy > 0)
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.numLegacyDemos = trap_FS_GetFileList("demos", extension, s_demos.namesLegacy, NAMEBUFSIZE);
s_demos.numDemos += trap_FS_GetFileList("demos", extension, demoname,
ARRAY_LEN(s_demos.names) - (demoname - s_demos.names));
}
else
s_demos.numLegacyDemos = 0;
break;
}
}
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

@ -146,10 +146,13 @@ void UI_SetBestScores(postGameInfo_t *newInfo, qboolean postGame) {
}
}
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,12 +165,31 @@ void UI_LoadBestScores(const char *map, int game) {
}
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);
}
}
}
/*

View File

@ -631,7 +631,7 @@ typedef struct {
#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

@ -2863,7 +2863,7 @@ static void UI_LoadMovies( void ) {
}
#define NAMEBUFSIZE (MAX_DEMOS * 32)
/*
===============
@ -2871,31 +2871,49 @@ UI_LoadDemos
===============
*/
static void UI_LoadDemos( void ) {
char demolist[4096];
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));
if (uiInfo.demoCount) {
if (uiInfo.demoCount > MAX_DEMOS) {
uiInfo.demoCount = MAX_DEMOS;
}
demoname = demolist;
for ( i = 0; i < uiInfo.demoCount; i++ ) {
i = 0;
for(j = 0; j < 2; j++)
{
if(uiInfo.demoCount > MAX_DEMOS)
uiInfo.demoCount = MAX_DEMOS;
for(; i < uiInfo.demoCount; i++)
{
len = strlen(demoname);
if (!Q_stricmp(demoname + len - strlen(demoExt), demoExt)) {
demoname[len-strlen(demoExt)] = '\0';
}
Q_strupr(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;
}
}
}