Platform: add menu debug command 'listGameLibrary' to output all the currently indexed games/mods

This commit is contained in:
Marco Cawthorne 2023-11-18 13:31:17 -08:00
parent 29e7b84e4b
commit 07173b3c7b
Signed by: eukara
GPG key ID: CE2032F0A2882A22
4 changed files with 26 additions and 10 deletions

View file

@ -125,6 +125,7 @@ m_init(void)
registercommand("map_background");
registercommand("menu_musicstart");
registercommand("richpresence_dump");
registercommand("listGameLibrary");
Font_Load("fonts/fontcon.font", font_console);
Font_Load("fonts/menu_label.font", font_label);
@ -441,6 +442,9 @@ m_consolecommand(string cmd)
localcmd(sprintf("maxplayers 2\nset coop 1\nset sv_background 1\nmap %s\n",
argv(1)));
break;
case "listGameLibrary":
GameLibrary_DebugList();
break;
default:
return (0);
}

View file

@ -99,6 +99,9 @@ __variant GameLibrary_GetGameInfo(int, gameInfo_t);
/** Retrieves fields for the currently running game. See gameInfo_t for a list of fields you can query. */
__variant GameLibrary_GetInfo(gameInfo_t);
/** Prints debug info about the currently cached games to the console. */
void GameLibrary_DebugList(void);
typedef enum
{
GAMEINFO_NONE, /**< No gameinfo available. This is probably the engine making assumptions. */
@ -142,4 +145,5 @@ typedef struct
int gameinfo_count;
gameinfo_t *games;
#endif

View file

@ -203,6 +203,7 @@ GameLibrary_LibListParse(int id, string strKey, string strValue)
case "startmap":
games[id].startmap = strcat("map ", strValue, "\n");
break;
case "trainmap":
case "trainingmap":
games[id].trainingmap = strcat("map ", strValue, "\n");
break;
@ -404,12 +405,9 @@ GameLibrary_SetDefaults(int id, string gamedirname)
games[id].readme = "readme.txt";
games[id].pkgid = -1;
#if 0
if (games[id].gamedir == "valve") {
games[id].pkgname = "valve_patch;addon_furtherdata;addon_holidaymodels";
games[id].pkgfile = "maps/crossfire.bsp"; /* only found in patches */
games[id].chatroom = "halflife";
}
#endif
}
/** Checks if a given game directory was installed manually. */
@ -434,10 +432,12 @@ GameLibrary_InitCustom(void)
int id;
int foundself = 0;
string gamedirname = __NULL__;
gameinfo_count = 0;
int old_count = gameinfo_count;
int packageinfo_count = 0i;
int c = 0i;
gameinfo_count = 0i;
/* first count let's all manually installed mods */
for (id = 0; (gamedirname = getgamedirinfo(id, 0)); id++) {
gameinfo_count++;
@ -465,15 +465,14 @@ GameLibrary_InitCustom(void)
}
/* re-allocate the game list */
memfree(games);
games = memalloc(sizeof(gameinfo_t) * (gameinfo_count + packageinfo_count));
games = (gameinfo_t *)memrealloc(games, sizeof(gameinfo_t), old_count, (gameinfo_count + packageinfo_count));
/* The things we do for frequent flyer mileage. */
if (!games)
error(sprintf("Attempting to allocate mod data for %i entries failed\n", gameinfo_count));
/* now loop through all the mods we found and load in the metadata */
for (id = 0; id < gameinfo_count; id++) {
for (id = 1; id < gameinfo_count; id++) {
gamedirname = getgamedirinfo(id, 0);
GameLibrary_SetDefaults(id, gamedirname);
@ -829,3 +828,13 @@ GameLibrary_GetGameInfo(int gameID, gameInfo_t infoType)
return __NULL__;
}
}
void
GameLibrary_DebugList(void)
{
for (int i = 0; i < gameinfo_count; i++) {
print(sprintf("%i %s (%s)\n", i, games[i].game, games[i].gamedir));
}
print(sprintf("\t%i game(s) loaded\n", gameinfo_count));
}

View file

@ -15,7 +15,6 @@
*/
noref var string g_mapcycle_override = __NULL__;
noref var string g_mapCycle = "mapcycle.txt";
void
Mapcycle_Load(string filename)
@ -64,7 +63,7 @@ Mapcycle_Load(string filename)
void
Mapcycle_Init(void)
{
string cycleFile = cvar_string("g_mapCycle");
string cycleFile = autocvar(g_mapCycle, "mapcycle.txt");
/* by default, this will be multiplayer only */
if (g_grMode.IsMultiplayer() == false)