ref: 4f5b2b8a2f45229114e66e546d0795e6373afd88
parent: 1ae0fe698400cda907a1a9b55b50827b9931bd0a
author: Simon Howard <[email protected]>
date: Thu Nov 24 15:20:28 EST 2016
hexen: Forbid demo extensions in WAD files. Save and restore of these extension bits is a convenience for demo playback purposes and not intended as an editing feature. If a demo with such bits set is found inside a WAD file, we ignore them as Vanilla Hexen would do. Part of #817.
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -2046,23 +2046,50 @@
gameaction = ga_playdemo;
}
+// Returns true if the given lump number corresponds to data from a .lmp
+// file, as opposed to a WAD.
+static boolean IsDemoFile(int lumpnum)
+{
+ char *lower;
+ boolean result;
+
+ lower = M_StringDuplicate(lumpinfo[lumpnum]->wad_file->path);
+ M_ForceLowercase(lower);
+ result = M_StringEndsWith(lower, ".lmp");
+ free(lower);
+
+ return result;
+}
+
void G_DoPlayDemo(void)
{
skill_t skill;
- int i, episode, map;
+ int i, lumpnum, episode, map;
gameaction = ga_nothing;
- demobuffer = demo_p = W_CacheLumpName(defdemoname, PU_STATIC);
+ lumpnum = W_GetNumForName(defdemoname);
+ demobuffer = W_CacheLumpNum(lumpnum, PU_STATIC);
+ demo_p = demobuffer;
skill = *demo_p++;
episode = *demo_p++;
map = *demo_p++;
- // Read special parameter bits: see G_RecordDemo() for details.
- longtics = (*demo_p & DEMOHEADER_LONGTICS) != 0;
+ // When recording we store some extra options inside the upper bits
+ // of the player 1 present byte; this is equivalent to what vvHeretic
+ // does. However, only recognize these bits if they are in a demo file
+ // being played manually by the user; we ignore them (as is Vanilla
+ // behavior) if they are inside a WAD file.
+ // These extra bits are a convenience feature for demo playback, not
+ // an editing extension for WAD authors.
+ if (IsDemoFile(lumpnum))
+ {
+ // Read special parameter bits: see G_RecordDemo() for details.
+ longtics = (*demo_p & DEMOHEADER_LONGTICS) != 0;
- // don't overwrite arguments from the command line
- respawnparm |= (*demo_p & DEMOHEADER_RESPAWN) != 0;
- nomonsters |= (*demo_p & DEMOHEADER_NOMONSTERS) != 0;
+ // don't overwrite arguments from the command line
+ respawnparm |= (*demo_p & DEMOHEADER_RESPAWN) != 0;
+ nomonsters |= (*demo_p & DEMOHEADER_NOMONSTERS) != 0;
+ }
for (i = 0; i < maxplayers; i++)
{