another attempt to fix netgame reload (#490)

* another attempt to fix netgame reload

* remove unused variable

* change rngseed calculation

* fix complevel boom desync

* fix complevel mbf netgame desync
This commit is contained in:
Roman Fomin 2022-04-11 00:21:54 +07:00 committed by GitHub
parent fa899ac25d
commit eb82b4f64d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 12 deletions

View File

@ -692,8 +692,6 @@ extern int ddt_cheating;
static void G_ReloadLevel(void) static void G_ReloadLevel(void)
{ {
int i;
if (demorecording || netgame) if (demorecording || netgame)
{ {
gamemap = startmap; gamemap = startmap;
@ -701,10 +699,7 @@ static void G_ReloadLevel(void)
} }
basetic = gametic; basetic = gametic;
rngseed = time(NULL); rngseed += gametic;
M_ClearRandom();
AM_clearMarks();
totalleveltimes = 0;
if (demorecording) if (demorecording)
{ {
@ -714,12 +709,8 @@ static void G_ReloadLevel(void)
G_BeginRecording(); G_BeginRecording();
} }
// force players to be initialized upon first level load G_InitNew(gameskill, gameepisode, gamemap);
for (i = 0; i<MAXPLAYERS; i++) gameaction = ga_nothing;
if (playeringame[i])
players[i].playerstate = PST_REBORN;
G_DoLoadLevel();
} }
// //

View File

@ -849,7 +849,23 @@ static boolean P_LookForPlayers(mobj_t *actor, boolean allaround)
// killough 2/15/98, 9/9/98: // killough 2/15/98, 9/9/98:
if (c++ == stopc || actor->lastlook == stop) // done looking if (c++ == stopc || actor->lastlook == stop) // done looking
{
// Andrey Budko
// Fixed Boom incompatibilities. The following code was missed.
// There are no more desyncs on Donce's demos on horror.wad
// Use last known enemy if no players sighted -- killough 2/15/98:
if (demo_version < 203 && !demo_compatibility && monsters_remember)
{
if (actor->lastenemy && actor->lastenemy->health > 0)
{
actor->target = actor->lastenemy;
actor->lastenemy = NULL;
return true;
}
}
return false; return false;
}
player = &players[actor->lastlook]; player = &players[actor->lastlook];

View File

@ -692,6 +692,30 @@ static void P_KillMobj(mobj_t *source, mobj_t *target)
if (!(target->flags & MF_FRIEND)) if (!(target->flags & MF_FRIEND))
players->killcount++; players->killcount++;
} }
#ifndef MBF_STRICT
// For compatibility with PrBoom+ complevel 11 netgame
else
if (
(target->flags & MF_COUNTKILL) &&
(demo_version >= 203) && netgame && !deathmatch &&
!(
target->lastenemy &&
target->lastenemy->health > 0 &&
target->lastenemy->player
)
)
{
int i;
for (i = 0; i < MAXPLAYERS; ++i)
{
if (playeringame[i])
{
P_Random(pr_friends);
break;
}
}
}
#endif
if (target->player) if (target->player)
{ {