diff --git a/docs/rh-log.txt b/docs/rh-log.txt index b7d269fba..951c7566e 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -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. diff --git a/src/d_main.cpp b/src/d_main.cpp index f9cda830c..37d1aae28 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -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 diff --git a/src/doomstat.h b/src/doomstat.h index a9ad40fbb..e043544b1 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -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. diff --git a/src/g_game.cpp b/src/g_game.cpp index 1cd5e8cc5..04452a9ee 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -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; diff --git a/src/g_game.h b/src/g_game.h index ba734f282..939969108 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -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); diff --git a/src/g_level.cpp b/src/g_level.cpp index 3b4f0a7f4..34295692e 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -114,7 +114,7 @@ TAutoGrowArray ACS_WorldArrays[NUM_WORLDVARS]; SDWORD ACS_GlobalVars[NUM_GLOBALVARS]; TAutoGrowArray 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) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index f0614cc69..3e9cc1449 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -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) {