summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/doom/d_main.c8
-rw-r--r--src/heretic/d_main.c14
-rw-r--r--src/hexen/h2_main.c24
-rw-r--r--src/strife/d_main.c9
4 files changed, 38 insertions, 17 deletions
diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index 17dbd170..6d37e455 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1359,21 +1359,21 @@ void D_DoomMain (void)
if (p)
{
+ // With Vanilla you have to specify the file without extension,
+ // but make that optional.
if (M_StringEndsWith(myargv[p + 1], ".lmp"))
{
M_StringCopy(file, myargv[p + 1], sizeof(file));
}
else
{
- snprintf(file, sizeof(file), "%s.lmp", myargv[p+1]);
+ DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p+1]);
}
if (D_AddFile(file))
{
M_StringCopy(demolumpname, lumpinfo[numlumps - 1].name,
sizeof(demolumpname));
-
- printf("Playing demo %s.\n", file);
}
else
{
@@ -1383,6 +1383,8 @@ void D_DoomMain (void)
M_StringCopy(demolumpname, myargv[p + 1], sizeof(demolumpname));
}
+
+ printf("Playing demo %s.\n", file);
}
I_AtExit((atexit_func_t) G_CheckDemoStatus, true);
diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c
index 316a30b8..d0fdc582 100644
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -1006,26 +1006,30 @@ void D_DoomMain(void)
if (p)
{
- if (!M_StringEndsWith(myargv[p + 1], ".lmp"))
+ // In Vanilla, the filename must be specified without .lmp,
+ // but make that optional.
+ if (M_StringEndsWith(myargv[p + 1], ".lmp"))
{
- DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p + 1]);
+ M_StringCopy(file, myargv[p + 1], sizeof(file));
}
else
{
- M_StringCopy(file, myargv[p + 1], sizeof(file));
+ DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p + 1]);
}
if (D_AddFile(file))
{
M_StringCopy(demolumpname, lumpinfo[numlumps - 1].name,
sizeof(demolumpname));
-
- DEH_printf("Playing demo %s.\n", file);
}
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));
}
+
+ printf("Playing demo %s.\n", file);
}
if (W_CheckNumForName(DEH_String("E2M1")) == -1)
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"))
diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index edd01f87..5d8399eb 100644
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -1606,21 +1606,21 @@ void D_DoomMain (void)
if (p)
{
- if (!strcasecmp(myargv[p+1] + strlen(myargv[p+1]) - 4, ".lmp"))
+ // With Vanilla you have to specify the file without extension,
+ // but make that optional.
+ if (M_StringEndsWith(myargv[p + 1], ".lmp"))
{
M_StringCopy(file, myargv[p + 1], sizeof(file));
}
else
{
- snprintf(file, sizeof(file), "%s.lmp", myargv[p+1]);
+ DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p+1]);
}
if (D_AddFile (file))
{
M_StringCopy(demolumpname, lumpinfo[numlumps - 1].name,
sizeof(demolumpname));
-
- printf("Playing demo %s.\n", file);
}
else
{
@@ -1631,6 +1631,7 @@ void D_DoomMain (void)
M_StringCopy(demolumpname, myargv[p + 1], sizeof(demolumpname));
}
+ printf("Playing demo %s.\n", file);
}
I_AtExit((atexit_func_t) G_CheckDemoStatus, true);