Platform: add menu debug command 'listGameLibrary' to output all the currently indexed games/mods
This commit is contained in:
parent
29e7b84e4b
commit
07173b3c7b
4 changed files with 26 additions and 10 deletions
|
@ -125,6 +125,7 @@ m_init(void)
|
||||||
registercommand("map_background");
|
registercommand("map_background");
|
||||||
registercommand("menu_musicstart");
|
registercommand("menu_musicstart");
|
||||||
registercommand("richpresence_dump");
|
registercommand("richpresence_dump");
|
||||||
|
registercommand("listGameLibrary");
|
||||||
|
|
||||||
Font_Load("fonts/fontcon.font", font_console);
|
Font_Load("fonts/fontcon.font", font_console);
|
||||||
Font_Load("fonts/menu_label.font", font_label);
|
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",
|
localcmd(sprintf("maxplayers 2\nset coop 1\nset sv_background 1\nmap %s\n",
|
||||||
argv(1)));
|
argv(1)));
|
||||||
break;
|
break;
|
||||||
|
case "listGameLibrary":
|
||||||
|
GameLibrary_DebugList();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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. */
|
/** Retrieves fields for the currently running game. See gameInfo_t for a list of fields you can query. */
|
||||||
__variant GameLibrary_GetInfo(gameInfo_t);
|
__variant GameLibrary_GetInfo(gameInfo_t);
|
||||||
|
|
||||||
|
/** Prints debug info about the currently cached games to the console. */
|
||||||
|
void GameLibrary_DebugList(void);
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
GAMEINFO_NONE, /**< No gameinfo available. This is probably the engine making assumptions. */
|
GAMEINFO_NONE, /**< No gameinfo available. This is probably the engine making assumptions. */
|
||||||
|
@ -142,4 +145,5 @@ typedef struct
|
||||||
|
|
||||||
int gameinfo_count;
|
int gameinfo_count;
|
||||||
gameinfo_t *games;
|
gameinfo_t *games;
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -203,6 +203,7 @@ GameLibrary_LibListParse(int id, string strKey, string strValue)
|
||||||
case "startmap":
|
case "startmap":
|
||||||
games[id].startmap = strcat("map ", strValue, "\n");
|
games[id].startmap = strcat("map ", strValue, "\n");
|
||||||
break;
|
break;
|
||||||
|
case "trainmap":
|
||||||
case "trainingmap":
|
case "trainingmap":
|
||||||
games[id].trainingmap = strcat("map ", strValue, "\n");
|
games[id].trainingmap = strcat("map ", strValue, "\n");
|
||||||
break;
|
break;
|
||||||
|
@ -404,12 +405,9 @@ GameLibrary_SetDefaults(int id, string gamedirname)
|
||||||
games[id].readme = "readme.txt";
|
games[id].readme = "readme.txt";
|
||||||
games[id].pkgid = -1;
|
games[id].pkgid = -1;
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (games[id].gamedir == "valve") {
|
if (games[id].gamedir == "valve") {
|
||||||
games[id].pkgname = "valve_patch;addon_furtherdata;addon_holidaymodels";
|
games[id].chatroom = "halflife";
|
||||||
games[id].pkgfile = "maps/crossfire.bsp"; /* only found in patches */
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks if a given game directory was installed manually. */
|
/** Checks if a given game directory was installed manually. */
|
||||||
|
@ -434,10 +432,12 @@ GameLibrary_InitCustom(void)
|
||||||
int id;
|
int id;
|
||||||
int foundself = 0;
|
int foundself = 0;
|
||||||
string gamedirname = __NULL__;
|
string gamedirname = __NULL__;
|
||||||
gameinfo_count = 0;
|
int old_count = gameinfo_count;
|
||||||
int packageinfo_count = 0i;
|
int packageinfo_count = 0i;
|
||||||
int c = 0i;
|
int c = 0i;
|
||||||
|
|
||||||
|
gameinfo_count = 0i;
|
||||||
|
|
||||||
/* first count let's all manually installed mods */
|
/* first count let's all manually installed mods */
|
||||||
for (id = 0; (gamedirname = getgamedirinfo(id, 0)); id++) {
|
for (id = 0; (gamedirname = getgamedirinfo(id, 0)); id++) {
|
||||||
gameinfo_count++;
|
gameinfo_count++;
|
||||||
|
@ -465,15 +465,14 @@ GameLibrary_InitCustom(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* re-allocate the game list */
|
/* re-allocate the game list */
|
||||||
memfree(games);
|
games = (gameinfo_t *)memrealloc(games, sizeof(gameinfo_t), old_count, (gameinfo_count + packageinfo_count));
|
||||||
games = memalloc(sizeof(gameinfo_t) * (gameinfo_count + packageinfo_count));
|
|
||||||
|
|
||||||
/* The things we do for frequent flyer mileage. */
|
/* The things we do for frequent flyer mileage. */
|
||||||
if (!games)
|
if (!games)
|
||||||
error(sprintf("Attempting to allocate mod data for %i entries failed\n", gameinfo_count));
|
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 */
|
/* 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);
|
gamedirname = getgamedirinfo(id, 0);
|
||||||
GameLibrary_SetDefaults(id, gamedirname);
|
GameLibrary_SetDefaults(id, gamedirname);
|
||||||
|
|
||||||
|
@ -829,3 +828,13 @@ GameLibrary_GetGameInfo(int gameID, gameInfo_t infoType)
|
||||||
return __NULL__;
|
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));
|
||||||
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
noref var string g_mapcycle_override = __NULL__;
|
noref var string g_mapcycle_override = __NULL__;
|
||||||
noref var string g_mapCycle = "mapcycle.txt";
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Mapcycle_Load(string filename)
|
Mapcycle_Load(string filename)
|
||||||
|
@ -64,7 +63,7 @@ Mapcycle_Load(string filename)
|
||||||
void
|
void
|
||||||
Mapcycle_Init(void)
|
Mapcycle_Init(void)
|
||||||
{
|
{
|
||||||
string cycleFile = cvar_string("g_mapCycle");
|
string cycleFile = autocvar(g_mapCycle, "mapcycle.txt");
|
||||||
|
|
||||||
/* by default, this will be multiplayer only */
|
/* by default, this will be multiplayer only */
|
||||||
if (g_grMode.IsMultiplayer() == false)
|
if (g_grMode.IsMultiplayer() == false)
|
||||||
|
|
Loading…
Reference in a new issue