P_PostLoadLevel: Move all events directly requiring finalised player lists into this function

- Grand Prix (& backup) and Match Race bot initialisation
    - Fixes rival selection
- P_InitPlayers
    - Has to be after bot init
- Beginning of demo recording
    - Grand Prix and Match Race replays appear to both function far better, and equivalently to boot.
        - A desync in "RNG seed 24" is reported. This is PR_BOTS. This is the only notable desync I can see!
- ACS_LoadLevelScripts
    - I'm not ironclad sold on this being the forever home, but it's also a not-from-netsave thing, and barring external input I could see some scripts being dependent on a finalised player list.
This commit is contained in:
toaster 2023-07-17 18:06:57 +01:00
parent 7c3d3282f0
commit 5b4fc18264
2 changed files with 44 additions and 42 deletions

View file

@ -3230,12 +3230,6 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
if (demo.timing)
G_DoneLevelLoad();
if (metalrecording)
G_BeginMetal();
if (demo.recording) // Okay, level loaded, character spawned and skinned,
G_BeginRecording(); // I AM NOW READY TO RECORD.
demo.deferstart = true;
#ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence();
#endif

View file

@ -7789,33 +7789,6 @@ static void P_InitGametype(void)
spectateGriefed = 0;
K_CashInPowerLevels(); // Pushes power level changes even if intermission was skipped
if (grandprixinfo.gp == true)
{
if (savedata.lives > 0)
{
K_LoadGrandPrixSaveGame();
savedata.lives = 0;
}
else if (grandprixinfo.initalize == true)
{
K_InitGrandPrixRank(&grandprixinfo.rank);
K_InitGrandPrixBots();
grandprixinfo.initalize = false;
}
else if (grandprixinfo.wonround == true)
{
K_UpdateGrandPrixBots();
grandprixinfo.wonround = false;
}
}
else
{
// We're in a Match Race, use simplistic randomized bots.
K_UpdateMatchRaceBots();
}
P_InitPlayers();
if (modeattacking && !demo.playback)
P_LoadRecordGhosts();
@ -8344,12 +8317,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
K_InitDirector();
}
// Initialize ACS scripts
if (!fromnetsave)
{
ACS_LoadLevelScripts(gamemap-1);
}
// Remove the loading shit from the screen
if (rendermode != render_none && !titlemapinaction && !reloadinggamestate)
F_WipeColorFill(levelfadecol);
@ -8415,6 +8382,49 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
void P_PostLoadLevel(void)
{
P_MapStart();
if (demo.playback)
;
else if (grandprixinfo.gp == true)
{
if (savedata.lives > 0)
{
K_LoadGrandPrixSaveGame();
savedata.lives = 0;
}
else if (grandprixinfo.initalize == true)
{
K_InitGrandPrixRank(&grandprixinfo.rank);
K_InitGrandPrixBots();
grandprixinfo.initalize = false;
}
else if (grandprixinfo.wonround == true)
{
K_UpdateGrandPrixBots();
grandprixinfo.wonround = false;
}
}
else
{
// We're in a Match Race, use simplistic randomized bots.
K_UpdateMatchRaceBots();
}
P_InitPlayers();
if (metalrecording)
G_BeginMetal();
if (demo.recording) // Okay, level loaded, character spawned and skinned,
G_BeginRecording(); // I AM NOW READY TO RECORD.
demo.deferstart = true;
// Initialize ACS scripts
//if (!fromnetsave) -- I don't know if it's appropriate to remove this entirely yet
{
ACS_LoadLevelScripts(gamemap-1);
}
K_TimerInit();
nextmapoverride = 0;
@ -8429,12 +8439,10 @@ void P_PostLoadLevel(void)
marathonmode &= ~MA_INIT;
}
P_MapStart(); // just in case MapLoad modifies tm.thing
ACS_RunLevelStartScripts();
LUA_HookInt(gamemap, HOOK(MapLoad));
P_MapEnd(); // just in case MapLoad modifies tm.thing
P_MapEnd();
// We're now done loading the level.
levelloading = false;