Skip to content

Commit

Permalink
COMPLVL lump support for supported complevels.
Browse files Browse the repository at this point in the history
  • Loading branch information
JadingTsunami committed Oct 6, 2023
1 parent 2c5a705 commit 6f6f6e3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions prboom2/src/c_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -537,6 +542,7 @@ command command_list[] = {
{"bind", C_bind},
{"unbind", C_unbind},
{"mapfollow", C_mapfollow},
{"complevel", C_complevel},

/* aliases */
{"snd", C_sndvol},
Expand Down
8 changes: 5 additions & 3 deletions prboom2/src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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"))
Expand Down
39 changes: 37 additions & 2 deletions prboom2/src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 6f6f6e3

Please sign in to comment.