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.
This commit is contained in:
Randy Heit 2016-01-08 22:41:23 -06:00
parent bf31d66d31
commit 786caaf36b
2 changed files with 3 additions and 3 deletions

View file

@ -423,8 +423,8 @@ void FCajunMaster::RemoveAllBots (bool fromlist)
} }
} }
} }
FBehavior::StaticStartTypedScripts (SCRIPT_Disconnect, players[i].mo, true, i, true);
ClearPlayer (i, !fromlist); ClearPlayer (i, !fromlist);
FBehavior::StaticStartTypedScripts (SCRIPT_Disconnect, NULL, true, i);
} }
} }

View file

@ -1713,6 +1713,8 @@ void G_DoPlayerPop(int playernum)
// [RH] Make the player disappear // [RH] Make the player disappear
FBehavior::StaticStopMyScripts(players[playernum].mo); 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) if (players[playernum].mo != NULL)
{ {
P_DisconnectEffect(players[playernum].mo); P_DisconnectEffect(players[playernum].mo);
@ -1726,8 +1728,6 @@ void G_DoPlayerPop(int playernum)
players[playernum].mo = NULL; players[playernum].mo = NULL;
players[playernum].camera = 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) void G_ScreenShot (char *filename)