ref: 59a80b5a902d51d03fb079b0ec5560d450f92731
parent: 79699357c1b4dfe8db47eb43f15b7d03c9bc820f
author: Simon Howard <[email protected]>
date: Sat Mar 29 19:56:44 EDT 2014
heretic: Make -playdemo cope with paths. Vanilla Heretic 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. This fixes half of #301.
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -812,6 +812,7 @@
GameMission_t gamemission;
int p;
char file[256];
+ char demolumpname[9];
I_PrintBanner(PACKAGE_STRING);
@@ -1005,9 +1006,26 @@
if (p)
{
- DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p + 1]);
- D_AddFile(file);
- DEH_printf("Playing demo %s.lmp.\n", myargv[p + 1]);
+ if (!M_StringEndsWith(myargv[p + 1], ".lmp"))
+ {
+ DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p + 1]);
+ }
+ else
+ {
+ M_StringCopy(file, myargv[p + 1], sizeof(file));
+ }
+
+ if (D_AddFile(file))
+ {
+ M_StringCopy(demolumpname, lumpinfo[numlumps - 1].name,
+ sizeof(demolumpname));
+
+ DEH_printf("Playing demo %s.\n", file);
+ }
+ else
+ {
+ M_StringCopy(demolumpname, myargv[p + 1], sizeof(demolumpname));
+ }
}
if (W_CheckNumForName(DEH_String("E2M1")) == -1)
@@ -1137,7 +1155,7 @@
if (p)
{
singledemo = true; // Quit after one demo
- G_DeferedPlayDemo(myargv[p + 1]);
+ G_DeferedPlayDemo(demolumpname);
D_DoomLoop(); // Never returns
}
@@ -1144,7 +1162,7 @@
p = M_CheckParmWithArgs("-timedemo", 1);
if (p)
{
- G_TimeDemo(myargv[p + 1]);
+ G_TimeDemo(demolumpname);
D_DoomLoop(); // Never returns
}