diff options
author | Simon Howard | 2014-03-30 00:24:49 -0400 |
---|---|---|
committer | Simon Howard | 2014-03-30 00:24:49 -0400 |
commit | fb00bf8354efee1847cbec3370f7a34eef745d3a (patch) | |
tree | b2ea3af9d5f714baf141dd8fdb0a65973cc0f31c /src/hexen | |
parent | 59a80b5a902d51d03fb079b0ec5560d450f92731 (diff) | |
download | chocolate-doom-fb00bf8354efee1847cbec3370f7a34eef745d3a.tar.gz chocolate-doom-fb00bf8354efee1847cbec3370f7a34eef745d3a.tar.bz2 chocolate-doom-fb00bf8354efee1847cbec3370f7a34eef745d3a.zip |
hexen: Make -playdemo cope with paths.
Vanilla Hexen makes you specify the demo name to play by giving
the plain lump name, eg. heretic -playdemo mydemo to load mydemo.lmp.
It doesn't work if you specify the extension or the full file path.
As a convenience and to match the behavior of Chocolate Doom, allow
paths and extensions.
Also rework the code for other games so that they're slightly more
consistent. This fixes #301.
Diffstat (limited to 'src/hexen')
-rw-r--r-- | src/hexen/h2_main.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c index 845496b4..f6351fae 100644 --- a/src/hexen/h2_main.c +++ b/src/hexen/h2_main.c @@ -102,6 +102,7 @@ extern boolean askforquit; GameMode_t gamemode; char *iwadfile; +static char demolumpname[9]; // Demo lump to start playing. boolean nomonsters; // checkparm of -nomonsters boolean respawnparm; // checkparm of -respawn boolean randomclass; // checkparm of -randclass @@ -382,14 +383,14 @@ void D_DoomMain(void) if (p) { singledemo = true; // Quit after one demo - G_DeferedPlayDemo(myargv[p + 1]); + G_DeferedPlayDemo(demolumpname); H2_GameLoop(); // Never returns } p = M_CheckParmWithArgs("-timedemo", 1); if (p) { - G_TimeDemo(myargv[p + 1]); + G_TimeDemo(demolumpname); H2_GameLoop(); // Never returns } @@ -553,13 +554,26 @@ static void HandleArgs(void) M_StringCopy(file, myargv[p+1], sizeof(file)); - if (!M_StringEndsWith(file, ".lmp")) + // With Vanilla Hexen you have to specify the file without + // extension, but make that optional. + if (!M_StringEndsWith(myargv[p+1], ".lmp")) { M_StringConcat(file, ".lmp", sizeof(file)); } - W_AddFile(file); - ST_Message("Playing demo %s.\n", file); + if (W_AddFile(file) != NULL) + { + M_StringCopy(demolumpname, lumpinfo[numlumps - 1].name, + sizeof(demolumpname)); + } + else + { + // The file failed to load, but copy the original arg as a + // demo name to make tricks like -playdemo demo1 possible. + M_StringCopy(demolumpname, myargv[p+1], sizeof(demolumpname)); + } + + ST_Message("Playing demo %s.\n", myargv[p+1]); } if (M_ParmExists("-testcontrols")) |