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

View File

@ -849,7 +849,23 @@ static boolean P_LookForPlayers(mobj_t *actor, boolean allaround)
// killough 2/15/98, 9/9/98:
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;
}
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))
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)
{