diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 63b83d4db..6453c1999 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5335,8 +5335,9 @@ void TryRunTics(tic_t realtics) } // record the actual local controls - boolean canSimulate = (gamestate == GS_LEVEL) && leveltime >= 10 && gametic >= BACKUPTICS && (cv_simulate.value && !server); - boolean recordingStates = (gamestate == GS_LEVEL) && leveltime >= 10 && gametic >= BACKUPTICS; + static boolean didSimulate = false; + boolean canSimulate = (gamestate == GS_LEVEL) && leveltime >= BACKUPTICS && gametic >= BACKUPTICS && (cv_simulate.value && !server); + boolean recordingStates = (gamestate == GS_LEVEL) && leveltime >= BACKUPTICS && gametic >= BACKUPTICS; boolean preserveSoundDisabled = sound_disabled; int numNewTics = neededtic - gametic; @@ -5344,6 +5345,24 @@ void TryRunTics(tic_t realtics) angle_t preservedAngle = localangle[0]; INT32 preservedAiming = localaiming[0]; + if (didSimulate && !canSimulate) + { + // we've stopped simulating for a while, so restore the original state before continuing + if (gameStateBufferIsValid[gametic % BACKUPTICS]) { + sound_disabled = true; + + save_p = gameStateBuffer[gametic % BACKUPTICS]; + P_LoadNetGame(true); + + sound_disabled = preserveSoundDisabled; + } + + // clear previous states + for (int i = 0; i < BACKUPTICS; i++) { + gameStateBufferIsValid[i] = false; + } + } + if (recordingStates) { PerformDebugRewinds(); @@ -5500,6 +5519,8 @@ void TryRunTics(tic_t realtics) smoothedTic = gametic; } + didSimulate = simTic != gametic || smoothedTic != gametic; + // we're gonna need more debugs... MakeNetDebugString(); } @@ -5561,6 +5582,13 @@ static void PerformDebugRewinds() { /* sector_t initial = *((elevator_t*)thlist[1].next)->sector; mobj_t initialPlayer = *players[consoleplayer].mo;*/ + int xyz = 0; + mapthing_t spawnpoint; + if (redflag) { + xyz = redflag->spawnpoint->x + redflag->spawnpoint->y + redflag->spawnpoint->z; + spawnpoint = *(redflag->spawnpoint); + } + for (int i = 0; i < cv_debugsimulaterewind.value; i++) { G_Ticker(true); } @@ -5568,6 +5596,13 @@ static void PerformDebugRewinds() { save_p = gameStateBuffer[gametic % BACKUPTICS]; P_LoadNetGame(true); + if (redflag) { + if (redflag->spawnpoint->x + redflag->spawnpoint->y + redflag->spawnpoint->z != xyz && xyz != 0) + { + CONS_Printf("Flag consistency error!\n"); + } + } + /*sector_t current = *((elevator_t*)thlist[1].next)->sector; mobj_t currentPlayer = *players[consoleplayer].mo;*/ diff --git a/src/p_inter.c b/src/p_inter.c index 404b4b38f..9f08f9560 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -924,7 +924,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (player->powers[pw_super]) return; - player->gotflag |= flagflag; + player->gotflag |= flagflag; // >:( CONS_Printf(M_GetText("%s picked up the %c%s%c!\n"), plname, flagcolor, flagtext, 0x80); (*flagmobj) = NULL; // code for dealing with abilities is handled elsewhere now diff --git a/src/p_mobj.c b/src/p_mobj.c index 4cfcebc1b..177fed973 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9194,6 +9194,8 @@ void P_MobjThinker(mobj_t *mobj) blueflag = flagmo; } + + CONS_Printf("Flag respawning at %d,%d,%d type %d\n", mobj->spawnpoint->x, mobj->spawnpoint->y, mobj->spawnpoint->z, mobj->spawnpoint->type); } P_RemoveMobj(mobj); return; diff --git a/src/p_saveg.c b/src/p_saveg.c index 589f23a10..94f4e19be 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2870,6 +2870,10 @@ static void P_NetUnArchiveThinkers(void) sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = NULL; } + // clear flags (necessary for level-preserving loads) + redflag = NULL; + blueflag = NULL; + // read in saved thinkers for (;;) {