From 786caaf36b31d27d717a292ca6ef27fc1bde615d Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 8 Jan 2016 22:41:23 -0600 Subject: [PATCH] Execute disconnect scripts immediately before the player is destroyed. - Disconnect scripts were previously run at some point after the player left. Now they are run immediately before destroying the player. Since the player hasn't actually been destroyed yet, the player also gets to be the script's activator. This gives you a chance to scrape whatever data you want from the player before they're history. Note that if you do anything to make the script wait, the script's activator will become the world, as it was before. --- src/b_game.cpp | 2 +- src/g_game.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/b_game.cpp b/src/b_game.cpp index e136f3f29b..5f852d043d 100644 --- a/src/b_game.cpp +++ b/src/b_game.cpp @@ -423,8 +423,8 @@ void FCajunMaster::RemoveAllBots (bool fromlist) } } } + FBehavior::StaticStartTypedScripts (SCRIPT_Disconnect, players[i].mo, true, i, true); ClearPlayer (i, !fromlist); - FBehavior::StaticStartTypedScripts (SCRIPT_Disconnect, NULL, true, i); } } diff --git a/src/g_game.cpp b/src/g_game.cpp index 8101ca23d2..64e746cefb 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1713,6 +1713,8 @@ void G_DoPlayerPop(int playernum) // [RH] Make the player disappear FBehavior::StaticStopMyScripts(players[playernum].mo); + // [RH] Let the scripts know the player left + FBehavior::StaticStartTypedScripts(SCRIPT_Disconnect, players[playernum].mo, true, playernum, true); if (players[playernum].mo != NULL) { P_DisconnectEffect(players[playernum].mo); @@ -1726,8 +1728,6 @@ void G_DoPlayerPop(int playernum) players[playernum].mo = NULL; players[playernum].camera = NULL; } - // [RH] Let the scripts know the player left - FBehavior::StaticStartTypedScripts(SCRIPT_Disconnect, NULL, true, playernum); } void G_ScreenShot (char *filename)