- Fixed: After respawning in a singleplayer demo, demo playback went out

of sync becase the RNG seed was being altered during recording but not
  during playback. This was caused by an inappropriate fix for a similar
  problem: -record calls G_InitNew() before it actually starts recording
  the demo, but -playdemo calls G_InitNew() after it starts playback. So
  the rngseed stored in the demo was already altered. The correct thing
  to do is not to prevent the rngseed from changing during playback but
  to move the call to G_InitNew() after the call to G_BeginRecording().
- Fixed: After respawning in a demo, demo playback was prematurely
  terminated.


SVN r50 (trunk)
This commit is contained in:
Randy Heit 2006-04-16 19:09:36 +00:00
parent da51ac7446
commit fa7987005e
7 changed files with 41 additions and 22 deletions

View file

@ -1,3 +1,15 @@
April 16, 2006
- Fixed: After respawning in a singleplayer demo, demo playback went out
of sync becase the RNG seed was being altered during recording but not
during playback. This was caused by an inappropriate fix for a similar
problem: -record calls G_InitNew() before it actually starts recording
the demo, but -playdemo calls G_InitNew() after it starts playback. So
the rngseed stored in the demo was already altered. The correct thing
to do is not to prevent the rngseed from changing during playback but
to move the call to G_InitNew() after the call to G_BeginRecording().
- Fixed: After respawning in a demo, demo playback was prematurely
terminated.
April 16, 2006 (Changes by Graf Zahl)
- Increased the limit for the sound DoorCloseLight in Hexen to 4 because
it got cut off in the polyobject crusher in MAP01.

View file

@ -147,7 +147,7 @@ extern BOOL netdemo;
extern int NewWidth, NewHeight, NewBits, DisplayBits;
EXTERN_CVAR (Bool, st_scale)
extern BOOL gameisdead;
extern BOOL demorecording;
extern bool demorecording;
extern bool M_DemoNoPlay; // [RH] if true, then skip any demos in the loop
extern cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles;
@ -2282,12 +2282,15 @@ void D_DoomMain (void)
G_LoadGame (file);
}
if (gameaction != ga_loadgame)
{
BorderNeedRefresh = screen->GetPageCount ();
if (autostart || netgame)
{
CheckWarpTransMap (startmap, true);
if (demorecording)
G_BeginRecording (startmap);
G_InitNew (startmap, false);
}
else
@ -2295,9 +2298,10 @@ void D_DoomMain (void)
D_StartTitle (); // start up intro loop
}
}
if (demorecording)
G_BeginRecording ();
else if (demorecording)
{
G_BeginRecording (NULL);
}
atterm (D_QuitNetGame); // killough

View file

@ -161,8 +161,8 @@ extern level_locals_t level;
// Disable save/end game?
extern bool usergame;
extern BOOL demoplayback;
extern BOOL demorecording;
extern bool demoplayback;
extern bool demorecording;
extern int demover;
// Quit after playing a demo from cmdline.

View file

@ -130,10 +130,10 @@ int gametic;
CVAR(Bool, demo_compress, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
char demoname[256];
BOOL demorecording;
BOOL demoplayback;
BOOL netdemo;
BOOL demonew; // [RH] Only used around G_InitNew for demos
bool demorecording;
bool demoplayback;
bool netdemo;
bool demonew; // [RH] Only used around G_InitNew for demos
int demover;
byte* demobuffer;
byte* demo_p;
@ -1345,8 +1345,10 @@ void G_DoReborn (int playernum, bool freshbot)
}
else
{ // Reload the level from scratch
bool indemo = demoplayback;
BackupSaveName = "";
G_InitNew (level.mapname, false);
demoplayback = indemo;
// gameaction = ga_loadlevel;
}
}
@ -2161,10 +2163,14 @@ void G_RecordDemo (char* name)
// for earlier ZDEMs since I didn't want to bother supporting
// something that probably wasn't used much (if at all).
void G_BeginRecording (void)
void G_BeginRecording (const char *startmap)
{
int i;
if (startmap == NULL)
{
startmap = level.mapname;
}
demo_p = demobuffer;
WriteLong (FORM_ID, &demo_p); // Write FORM ID
@ -2178,7 +2184,7 @@ void G_BeginRecording (void)
*demo_p++ = 3; // (Useful?)
for (i = 0; i < 8; i++) // Write name of map demo was recorded on.
{
*demo_p++ = level.mapname[i];
*demo_p++ = startmap[i];
}
WriteLong (rngseed, &demo_p); // Write RNG seed
*demo_p++ = consoleplayer;

View file

@ -47,7 +47,7 @@ void G_SaveGame (const char *filename, const char *description);
// Only called by startup code.
void G_RecordDemo (char* name);
void G_BeginRecording (void);
void G_BeginRecording (const char *startmap);
void G_PlayDemo (char* name);
void G_TimeDemo (char* name);

View file

@ -114,7 +114,7 @@ TAutoGrowArray<SDWORD> ACS_WorldArrays[NUM_WORLDVARS];
SDWORD ACS_GlobalVars[NUM_GLOBALVARS];
TAutoGrowArray<SDWORD> ACS_GlobalArrays[NUM_GLOBALVARS];
extern BOOL netdemo;
extern bool netdemo;
extern string BackupSaveName;
BOOL savegamerestore;
@ -1331,14 +1331,11 @@ void G_InitNew (char *mapname, bool bTitleLevel)
if (!savegamerestore)
{
if (!demoplayback)
{
if (!netgame)
{ // [RH] Change the random seed for each new single player game
rngseed = rngseed*3/2;
}
FRandom::StaticClearRandom ();
if (!netgame)
{ // [RH] Change the random seed for each new single player game
rngseed = rngseed*3/2;
}
FRandom::StaticClearRandom ();
memset (ACS_WorldVars, 0, sizeof(ACS_WorldVars));
memset (ACS_GlobalVars, 0, sizeof(ACS_GlobalVars));
for (i = 0; i < NUM_WORLDVARS; ++i)

View file

@ -3277,7 +3277,7 @@ void AActor::AdjustFloorClip ()
// Most of the player structure stays unchanged between levels.
//
EXTERN_CVAR (Bool, chasedemo)
extern BOOL demonew;
extern bool demonew;
void P_SpawnPlayer (mapthing2_t *mthing)
{