From 3377f9981a5c9a245422d6a1531f66fceb333f77 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 12 Apr 2018 00:38:25 -0500 Subject: [PATCH] Fix map list in Team Arena start server menu after entering SP menu In September 2017 I moved loading arenas.txt/*.arena files from entering start server menu to at startup to fix running out of memory in Team Arena UI after opening the start server menu several times. However, Team Arena completely replaces the uiInfo.mapList array when switching between single player and start server menus. So after my change, entering single player and then entering start server would only display single player maps. It caused SP endofgame menu to use MP map list for replay/next map since arenas were loaded after gameinfo.txt. Continue loading arena info at start up to avoid reallocating arena info but move setting up uiInfo.mapList to when entering the start server menu. --- code/ui/ui_gameinfo.c | 16 +++++++++++++--- code/ui/ui_local.h | 1 + code/ui/ui_main.c | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/code/ui/ui_gameinfo.c b/code/ui/ui_gameinfo.c index 557dee23..0721f8b2 100644 --- a/code/ui/ui_gameinfo.c +++ b/code/ui/ui_gameinfo.c @@ -138,12 +138,10 @@ void UI_LoadArenas( void ) { char filename[128]; char dirlist[1024]; char* dirptr; - int i, n; + int i; int dirlen; - char *type; ui_numArenas = 0; - uiInfo.mapCount = 0; trap_Cvar_Register( &arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM ); if( *arenasFile.string ) { @@ -166,6 +164,18 @@ void UI_LoadArenas( void ) { if (UI_OutOfMemory()) { trap_Print(S_COLOR_YELLOW"WARNING: not enough memory in pool to load all arenas\n"); } +} + +/* +=============== +UI_LoadArenasIntoMapList +=============== +*/ +void UI_LoadArenasIntoMapList( void ) { + int n; + char *type; + + uiInfo.mapCount = 0; for( n = 0; n < ui_numArenas; n++ ) { // determine type diff --git a/code/ui/ui_local.h b/code/ui/ui_local.h index 9129aee9..ae181823 100644 --- a/code/ui/ui_local.h +++ b/code/ui/ui_local.h @@ -359,6 +359,7 @@ int UI_AdjustTimeByGame(int time); void UI_ShowPostGame(qboolean newHigh); void UI_ClearScores( void ); void UI_LoadArenas(void); +void UI_LoadArenasIntoMapList(void); // // ui_menu.c diff --git a/code/ui/ui_main.c b/code/ui/ui_main.c index 66e897c3..f83de0be 100644 --- a/code/ui/ui_main.c +++ b/code/ui/ui_main.c @@ -3268,6 +3268,7 @@ static void UI_RunMenuScript(char **args) { trap_Cvar_Set("ui_cdkeyvalid", "CD Key does not appear to be valid."); } } else if (Q_stricmp(name, "loadArenas") == 0) { + UI_LoadArenasIntoMapList(); UI_MapCountByGameType(qfalse); Menu_SetFeederSelection(NULL, FEEDER_ALLMAPS, 0, "createserver"); } else if (Q_stricmp(name, "saveControls") == 0) {