From 54cd8b9ca98447491ed42ad886b19606d32abace Mon Sep 17 00:00:00 2001 From: Roman Fomin Date: Mon, 18 Jul 2022 22:23:43 +0700 Subject: [PATCH] implement G_GetCurrentComplevelName function (#668) * implement G_GetCurrentComplevelName function * move gameversions to doomstat.h * include GNUInstallDirs * fix cmake doc dir --- man/CMakeLists.txt | 3 ++- src/d_main.c | 18 ------------------ src/doomstat.c | 8 ++++++++ src/doomstat.h | 9 +++++++++ src/g_game.c | 27 +++++++++++++++++++-------- src/g_game.h | 2 ++ src/p_setup.c | 5 +++-- 7 files changed, 43 insertions(+), 29 deletions(-) diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt index a869d184..df72f5d4 100644 --- a/man/CMakeLists.txt +++ b/man/CMakeLists.txt @@ -1,3 +1,4 @@ +include(GNUInstallDirs) if(Python3_EXECUTABLE) add_custom_target(paramsgen @@ -13,7 +14,7 @@ install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/WoofInstall.cmake") if(WIN32) install(FILES CMDLINE.txt DESTINATION .) elseif(UNIX AND NOT APPLE) - install(FILES CMDLINE.txt DESTINATION "share/doc/${PROJECT_SHORTNAME}") + install(FILES CMDLINE.txt DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_SHORTNAME}") install(FILES "${PROJECT_SHORTNAME}.6" DESTINATION ${CMAKE_INSTALL_MANDIR}/man6) install(FILES "${PROJECT_SHORTNAME}-setup.6" DESTINATION ${CMAKE_INSTALL_MANDIR}/man6) install(FILES "bash-completion/${PROJECT_SHORTNAME}" diff --git a/src/d_main.c b/src/d_main.c index cf442b98..e1350f55 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1069,19 +1069,6 @@ void IdentifyVersion (void) // [FG] emulate a specific version of Doom -static struct -{ - const char *description; - const char *cmdline; - GameVersion_t version; -} gameversions[] = { - {"Doom 1.9", "1.9", exe_doom_1_9}, - {"Ultimate Doom", "ultimate", exe_ultimate}, - {"Final Doom", "final", exe_final}, - {"Chex Quest", "chex", exe_chex}, - { NULL, NULL, 0}, -}; - static void InitGameVersion(void) { int i, p; @@ -1154,11 +1141,6 @@ static void InitGameVersion(void) } } -const char* GetGameVersionCmdline(void) -{ - return gameversions[gameversion].cmdline; -} - // killough 5/3/98: old code removed // diff --git a/src/doomstat.c b/src/doomstat.c index 54b85c5e..11dd33d1 100644 --- a/src/doomstat.c +++ b/src/doomstat.c @@ -34,6 +34,14 @@ GameMission_t gamemission = doom; // [FG] emulate a specific version of Doom GameVersion_t gameversion = exe_doom_1_9; +GameVersions_t gameversions[] = { + {"Doom 1.9", "1.9", exe_doom_1_9}, + {"Ultimate Doom", "ultimate", exe_ultimate}, + {"Final Doom", "final", exe_final}, + {"Chex Quest", "chex", exe_chex}, + { NULL, NULL, 0}, +}; + // Language. Language_t language = english; diff --git a/src/doomstat.h b/src/doomstat.h index 0b3f1490..cb78ac59 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -66,6 +66,15 @@ extern GameMission_t gamemission; // [FG] emulate a specific version of Doom extern GameVersion_t gameversion; +typedef struct +{ + const char *description; + const char *cmdline; + GameVersion_t version; +} GameVersions_t; + +extern GameVersions_t gameversions[]; + extern char *MAPNAME(int e, int m); // Set if homebrew PWAD stuff has been added. diff --git a/src/g_game.c b/src/g_game.c index 943b66df..ba7c14ad 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1576,12 +1576,7 @@ static void G_DoPlayDemo(void) // [FG] report compatibility mode fprintf(stderr, "G_DoPlayDemo: Playing demo with %s (%d) compatibility.\n", - mbf21 ? "MBF21" : - demover >= 203 ? "MBF" : - demover >= 200 ? (compatibility ? "Boom compatibility" : "Boom") : - gameversion == exe_final ? "Final Doom" : - gameversion == exe_ultimate ? "Ultimate Doom" : - "Doom 1.9", demover); + G_GetCurrentComplevelName(), demover); } #define VERSIONSIZE 16 @@ -2616,6 +2611,23 @@ static int G_GetDefaultComplevel() } } +const char *G_GetCurrentComplevelName(void) +{ + switch (demo_version) + { + case 109: + return gameversions[gameversion].description; + case 202: + return "Boom"; + case 203: + return "MBF"; + case 221: + return "MBF21"; + default: + return "Unknown"; + } +} + static int G_GetWadComplevel(void) { int lumpnum; @@ -3523,7 +3535,6 @@ void G_DeferedPlayDemo(char* name) } #define DEMO_FOOTER_SEPARATOR "\n" -extern const char* GetGameVersionCmdline(void); extern char **dehfiles; static void G_AddDemoFooter(void) @@ -3564,7 +3575,7 @@ static void G_AddDemoFooter(void) if (demo_compatibility) { mem_fputs(" -complevel vanilla", stream); - tmp = M_StringJoin(" -gameversion ", GetGameVersionCmdline(), NULL); + tmp = M_StringJoin(" -gameversion ", gameversions[gameversion].cmdline, NULL); mem_fputs(tmp, stream); free(tmp); } diff --git a/src/g_game.h b/src/g_game.h index 1c7f2bdc..c7a70a04 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -72,6 +72,8 @@ int G_ValidateMapName(const char *mapname, int *pEpi, int *pMap); void G_EnableWarp(boolean warp); +const char *G_GetCurrentComplevelName(void); + extern int default_complevel; // killough 5/2/98: moved from m_misc.c: diff --git a/src/p_setup.c b/src/p_setup.c index 27cf7934..2e02e6eb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1635,14 +1635,15 @@ void P_SetupLevel(int episode, int map, int playermask, skill_t skill) // [FG] log level setup { - fprintf(stderr, "P_SetupLevel: %.8s (%s), %s%s%s\n", + fprintf(stderr, "P_SetupLevel: %.8s (%s), %s%s%s, %s compatibility\n", lumpname, W_WadNameForLump(lumpnum), mapformat == MFMT_ZDBSPX ? "ZDBSP nodes" : mapformat == MFMT_ZDBSPZ ? "compressed ZDBSP nodes" : mapformat == MFMT_DEEPBSP ? "DeepBSP nodes" : "Doom nodes", gen_blockmap ? " + generated Blockmap" : "", - pad_reject ? " + padded Reject table" : ""); + pad_reject ? " + padded Reject table" : "", + G_GetCurrentComplevelName()); } }