From 6f6f6e30d303d9e36b2d1a7c6d547ec61523c909 Mon Sep 17 00:00:00 2001 From: JadingTsunami Date: Thu, 5 Oct 2023 21:33:28 -0700 Subject: [PATCH] COMPLVL lump support for supported complevels. --- README.md | 2 ++ prboom2/src/c_cmd.c | 6 ++++++ prboom2/src/d_main.c | 8 +++++--- prboom2/src/g_game.c | 39 +++++++++++++++++++++++++++++++++++++-- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3356d2f30..fd7f336a7 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Install [PrBoom-Plus](https://github.com/coelckers/prboom-plus) and place the bi * Option to skip QuickSave/QuickLoad confirmation prompt * Option to fix the Blockmap bug (uses blockmap bug fix from Terry Hearst, adapted from similar PR for Woof) * Option to change player automap arrow to a chevron shape (easier to see direction at a distance) +* [COMPLVL](https://doomwiki.org/wiki/COMPLVL) lump support for supported compatibility levels * Note-taking console command * Jot down quick notes while playtesting. Notes go into a dated text file in the current working directory. * Each note lists the time, all loaded WAD files, player position, and an optional user-supplied message on the console. @@ -81,6 +82,7 @@ Install [PrBoom-Plus](https://github.com/coelckers/prboom-plus) and place the bi - `bind [key] [command]` - `unbind [key]` - `[config file setting]` (read config file settings from the console) +- `complevel` (show current compatibility level) # Bindable Special Key Names diff --git a/prboom2/src/c_cmd.c b/prboom2/src/c_cmd.c index aef03941b..f8d67b4ec 100644 --- a/prboom2/src/c_cmd.c +++ b/prboom2/src/c_cmd.c @@ -514,6 +514,11 @@ static void C_mapfollow(char* cmd) } } +static void C_complevel(char* cmd) +{ + doom_printf("Compatibility level: %d (%s)", compatibility_level, comp_lev_str[compatibility_level]); +} + command command_list[] = { {"noclip", C_noclip}, {"noclip2", C_noclip2}, @@ -537,6 +542,7 @@ command command_list[] = { {"bind", C_bind}, {"unbind", C_unbind}, {"mapfollow", C_mapfollow}, + {"complevel", C_complevel}, /* aliases */ {"snd", C_sndvol}, diff --git a/prboom2/src/d_main.c b/prboom2/src/d_main.c index c71a03ba4..266f7874d 100644 --- a/prboom2/src/d_main.c +++ b/prboom2/src/d_main.c @@ -1942,9 +1942,6 @@ static void D_DoomMainSetup(void) // init subsystems - G_ReloadDefaults(); // killough 3/4/98: set defaults just loaded. - // jff 3/24/98 this sets startskill if it was -1 - #ifdef GL_DOOM // proff 04/05/2000: for GL-specific switches gld_InitCommandLine(); @@ -2122,6 +2119,11 @@ static void D_DoomMainSetup(void) lprintf(LO_INFO,"\n"); // killough 3/6/98: add a newline, by popular demand :) + // Moved after WAD initialization for COMPLVL lump support + G_ReloadDefaults(); // killough 3/4/98: set defaults just loaded. + // jff 3/24/98 this sets startskill if it was -1 + + // e6y // option to disable automatic loading of dehacked-in-wad lump if (!M_CheckParm ("-nodeh")) diff --git a/prboom2/src/g_game.c b/prboom2/src/g_game.c index fd444540c..03b7ae13f 100644 --- a/prboom2/src/g_game.c +++ b/prboom2/src/g_game.c @@ -378,6 +378,8 @@ static void G_TimeWarpLoadAnchorPoint(int position); static void G_TimeWarpReset(); static void G_TimeWarpTicker(); +static int G_GetWADCompatibilityLevel(); + static void G_DoSaveGame (dboolean menu); //e6y: save/restore all data which could be changed by G_ReadDemoHeader @@ -2577,7 +2579,7 @@ static void G_DoSaveGame (dboolean menu) D_AdjustSaveLocation(); } else { FILE *f; - char* saveinfo = "saveinfo.txt"; + const char* saveinfo = "saveinfo.txt"; int filenamelen = strlen(basesavegame) + strlen(saveinfo) + 2; char* filename = malloc(sizeof(char)*(filenamelen)); snprintf(filename, filenamelen, "%s/%s", basesavegame, saveinfo); @@ -2841,7 +2843,11 @@ void G_ReloadDefaults(void) consoleplayer = 0; - compatibility_level = default_compatibility_level; + compatibility_level = G_GetWADCompatibilityLevel(); + + if (compatibility_level == -1) + compatibility_level = default_compatibility_level; + { int i = M_CheckParm("-complevel"); if (i && (1+i) < myargc) { @@ -4552,6 +4558,35 @@ void G_CheckDemoContinue(void) } } +//jds +// COMPLVL Lump support +static int G_GetWADCompatibilityLevel() +{ + int resolved_complevel = -1; + int lumpnum = W_CheckNumForName("COMPLVL"); + + if (lumpnum != -1) { + int size = W_LumpLength(lumpnum); + const char *p = W_CacheLumpNum(lumpnum); + + if (size == 7 && !strncasecmp(p, "vanilla", 7)) { + if (gamemode == retail || gamemission == chex) + resolved_complevel = 3; + else if (gamemode == commercial && (gamemission == pack_plut || gamemission == pack_tnt)) + resolved_complevel = 4; + else + resolved_complevel = 2; + } else if (size == 4 && !strncasecmp(p, "boom", 4)) { + resolved_complevel = 9; + } else if (size == 3 && !strncasecmp(p, "mbf", 3)) { + resolved_complevel = 11; + } + W_UnlockLumpNum(lumpnum); + } + + return resolved_complevel; +} + //jds // time warp feature