From 5b4fc1826440acaca3fc777d295c20a481ca171a Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 17 Jul 2023 18:06:57 +0100 Subject: [PATCH] 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. --- src/d_netcmd.c | 6 ---- src/p_setup.c | 80 +++++++++++++++++++++++++++----------------------- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 35c3fed88..30ac6377c 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -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 diff --git a/src/p_setup.c b/src/p_setup.c index 27b771df1..4a6d41e73 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -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;