ref: a94100706700ff6b29f6ff3d8a6be7daf46f4dfc
parent: 7c18ad6ccf1461696185013b333af3c056cc5630
author: Simon Howard <fraggle@gmail.com>
date: Mon May 22 14:51:21 EDT 2006
Allow specifying the full path and filename when playing back demos. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 510
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: d_main.c 484 2006-05-19 20:01:59Z fraggle $
+// $Id: d_main.c 510 2006-05-22 18:51:21Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -184,7 +184,7 @@
//-----------------------------------------------------------------------------
-static const char rcsid[] = "$Id: d_main.c 484 2006-05-19 20:01:59Z fraggle $";
+static const char rcsid[] = "$Id: d_main.c 510 2006-05-22 18:51:21Z fraggle $";
#define BGCOLOR 7
#define FGCOLOR 8
@@ -734,10 +734,10 @@
char title[128];
-static void D_AddFile(char *filename)
+static boolean D_AddFile(char *filename)
{
printf(" adding %s\n", filename);
- W_AddFile(filename);
+ return W_AddFile(filename);
}
@@ -1342,7 +1342,8 @@
void D_DoomMain (void)
{
int p;
- char file[256];
+ char file[256];
+ char demolumpname[9];
FindResponseFile ();
@@ -1542,9 +1543,32 @@
if (p && p < myargc-1)
{
- sprintf (file,"%s.lmp", myargv[p+1]);
- D_AddFile (file);
- printf(DEH_String("Playing demo %s.lmp.\n"),myargv[p+1]);
+ if (!strcasecmp(myargv[p+1] + strlen(myargv[p+1]) - 4, ".lmp"))
+ {
+ strcpy(file, myargv[p + 1]);
+ }
+ else
+ {
+ sprintf (file,"%s.lmp", myargv[p+1]);
+ }
+
+ if (D_AddFile (file))
+ {
+ strncpy(demolumpname, lumpinfo[numlumps - 1].name, 8);
+ demolumpname[8] = '\0';
+
+ printf("Playing demo %s.\n", file);
+ }
+ else
+ {
+ // If file failed to load, still continue trying to play
+ // the demo in the same way as Vanilla Doom. This makes
+ // tricks like "-playdemo demo1" possible.
+
+ strncpy(demolumpname, myargv[p + 1], 8);
+ demolumpname[8] = '\0';
+ }
+
}
// Generate the WAD hash table. Speed things up a bit.
@@ -1714,7 +1738,7 @@
if (p && p < myargc-1)
{
singledemo = true; // quit after one demo
- G_DeferedPlayDemo (myargv[p+1]);
+ G_DeferedPlayDemo (demolumpname);
D_DoomLoop (); // never returns
}
@@ -1721,7 +1745,7 @@
p = M_CheckParm ("-timedemo");
if (p && p < myargc-1)
{
- G_TimeDemo (myargv[p+1]);
+ G_TimeDemo (demolumpname);
D_DoomLoop (); // never returns
}
@@ -1738,7 +1762,6 @@
G_InitNew (startskill, startepisode, startmap);
else
D_StartTitle (); // start up intro loop
-
}
D_DoomLoop (); // never returns