From d114dffcb499a79755be5d4f5927cb2adfb3339d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 13 Aug 2024 17:21:40 +0300 Subject: [PATCH] filesystem: add new gameinfo.txt key: demomap --- Documentation/gameinfo.md | 1 + filesystem/filesystem.c | 15 +++++++++++++++ filesystem/filesystem.h | 1 + 3 files changed, 17 insertions(+) diff --git a/Documentation/gameinfo.md b/Documentation/gameinfo.md index af9109ec..868a10c9 100644 --- a/Documentation/gameinfo.md +++ b/Documentation/gameinfo.md @@ -78,6 +78,7 @@ These strings are specific to Xash3D FWGS. | `internal_vgui_support` | boolean | 0 | Only for programmers! Required to be set as 1 for PrimeXT!
When set to 1, the engine will not load vgui_support DLL, as VGUI support is done (or intentionally ignored) on the game side. | | `render_picbutton_text` | boolean | 0 | When set to 1, the UI will not use prerendered `btns_main.bmp` and dynamically render them instead | | `quicksave_aged_count` | integer | 2 | Quick saves limit used in saves rotation | +| `demomap` | string | Empty string | The name of the demo chapter map (Half-Life Uplink) | ## Note on GoldSrc liblist.gam support diff --git a/filesystem/filesystem.c b/filesystem/filesystem.c index 53bf6d20..60695f16 100644 --- a/filesystem/filesystem.c +++ b/filesystem/filesystem.c @@ -619,6 +619,9 @@ static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo ) FS_Printf( f, "internal_vgui_support\t\t%s\n", GameInfo->internal_vgui_support ? "1" : "0" ); FS_Printf( f, "render_picbutton_text\t\t%s\n", GameInfo->render_picbutton_text ? "1" : "0" ); + if( COM_CheckStringEmpty( GameInfo->demomap )) + FS_Printf( f, "demomap\t\t\"%s\"\n", GameInfo->demomap ); + FS_Close( f ); // all done } @@ -879,9 +882,21 @@ static void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, cons pfile = COM_ParseFile( pfile, token, sizeof( token )); GameInfo->autosave_aged_count = bound( 2, Q_atoi( token ), 99 ); } + else if( !Q_stricmp( token, "demomap" )) + { + pfile = COM_ParseFile( pfile, GameInfo->demomap, sizeof( GameInfo->demomap )); + } } } + // demomap only valid for gameinfo.txt but HL1 after 25th anniversary update + // comes with demo chapter. Set the demomap here. + if( !COM_CheckStringEmpty( GameInfo->demomap )) + { + if( !Q_stricmp( GameInfo->title, "Half-Life" )) // original check from GameUI + Q_strncpy( GameInfo->demomap, "hldemo1", sizeof( GameInfo->demomap )); + } + if( !found_linux || !found_osx ) { // just replace extension from dll to so/dylib diff --git a/filesystem/filesystem.h b/filesystem/filesystem.h index 0cb6b2aa..74bdda57 100644 --- a/filesystem/filesystem.h +++ b/filesystem/filesystem.h @@ -118,6 +118,7 @@ typedef struct gameinfo_s // HL25 compatibility keys qboolean hd_background; qboolean animated_title; + char demomap[MAX_QPATH]; } gameinfo_t; typedef enum