From 3c0200de19f5c3d3148128dfd6569c3d4fd0869e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Jan 2019 00:47:34 +0100 Subject: [PATCH] - run disconnect scripts on the level the disconnected player is on This is nearly always the primary one but let's keep the option of using bots on secondary levels. --- src/b_game.cpp | 3 +-- src/g_game.cpp | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/b_game.cpp b/src/b_game.cpp index beed7f3b33..0f6b699116 100644 --- a/src/b_game.cpp +++ b/src/b_game.cpp @@ -447,8 +447,7 @@ void FCajunMaster::RemoveAllBots (FLevelLocals *Level, bool fromlist) } // [ZZ] run event hook E_PlayerDisconnected(i); - // - level.Behaviors.StartTypedScripts (SCRIPT_Disconnect, players[i].mo, true, i, true); + Level->Behaviors.StartTypedScripts (SCRIPT_Disconnect, players[i].mo, true, i, true); ClearPlayer (i, !fromlist); } } diff --git a/src/g_game.cpp b/src/g_game.cpp index 09732db195..c0ba5398d8 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1691,22 +1691,23 @@ void G_DoPlayerPop(int playernum) } // [RH] Make the player disappear - level.Behaviors.StopMyScripts(players[playernum].mo); + auto mo = players[playernum].mo; + mo->Level->Behaviors.StopMyScripts(mo); // [ZZ] fire player disconnect hook E_PlayerDisconnected(playernum); // [RH] Let the scripts know the player left - level.Behaviors.StartTypedScripts(SCRIPT_Disconnect, players[playernum].mo, true, playernum, true); - if (players[playernum].mo != NULL) + mo->Level->Behaviors.StartTypedScripts(SCRIPT_Disconnect, mo, true, playernum, true); + if (mo != NULL) { - P_DisconnectEffect(players[playernum].mo); - players[playernum].mo->player = NULL; - players[playernum].mo->Destroy(); + P_DisconnectEffect(mo); + mo->player = NULL; + mo->Destroy(); if (!(players[playernum].mo->ObjectFlags & OF_EuthanizeMe)) { // We just destroyed a morphed player, so now the original player // has taken their place. Destroy that one too. players[playernum].mo->Destroy(); } - players[playernum].mo = NULL; + players[playernum].mo = nullptr; players[playernum].camera = nullptr; } @@ -2033,14 +2034,15 @@ void G_DoAutoSave () file = G_BuildSaveName ("auto", nextautosave); - if (!(level.flags2 & LEVEL2_NOAUTOSAVEHINT)) + // The hint flag is only relevant on the primary level. + if (!(currentUILevel->flags2 & LEVEL2_NOAUTOSAVEHINT)) { nextautosave = (nextautosave + 1) % count; } else { // This flag can only be used once per level - level.flags2 &= ~LEVEL2_NOAUTOSAVEHINT; + currentUILevel->flags2 &= ~LEVEL2_NOAUTOSAVEHINT; } readableTime = myasctime ();