This commit is contained in:
Rachael Alexanderson 2017-02-25 01:24:45 -05:00
commit 05b092a8a1
2 changed files with 18 additions and 21 deletions

View file

@ -125,6 +125,7 @@ int starttime;
extern FString BackupSaveName; extern FString BackupSaveName;
bool savegamerestore; bool savegamerestore;
int finishstate;
extern int mousex, mousey; extern int mousex, mousey;
extern bool sendpause, sendsave, sendturn180, SendLand; extern bool sendpause, sendsave, sendturn180, SendLand;
@ -160,6 +161,7 @@ void G_DeferedInitNew (FGameStartup *gs)
d_skill = gs->Skill; d_skill = gs->Skill;
CheckWarpTransMap (d_mapname, true); CheckWarpTransMap (d_mapname, true);
gameaction = ga_newgame2; gameaction = ga_newgame2;
finishstate = FINISH_NoHub;
} }
//========================================================================== //==========================================================================
@ -897,6 +899,7 @@ void G_DoCompleted (void)
} }
gamestate = GS_INTERMISSION; gamestate = GS_INTERMISSION;
finishstate = mode;
viewactive = false; viewactive = false;
automapactive = false; automapactive = false;
@ -1068,11 +1071,24 @@ void G_DoLoadLevel (int position, bool autosave)
// For each player, if they are viewing through a player, make sure it is themselves. // For each player, if they are viewing through a player, make sure it is themselves.
for (int ii = 0; ii < MAXPLAYERS; ++ii) for (int ii = 0; ii < MAXPLAYERS; ++ii)
{ {
if (playeringame[ii] && (players[ii].camera == NULL || players[ii].camera->player != NULL)) if (playeringame[ii])
{ {
players[ii].camera = players[ii].mo; if (players[ii].camera == NULL || players[ii].camera->player != NULL)
{
players[ii].camera = players[ii].mo;
}
E_PlayerEntered(ii, finishstate == FINISH_SameHub);
// ENTER scripts are being handled when the player gets spawned, this cannot be changed due to its effect on voodoo dolls.
if (level.FromSnapshot) FBehavior::StaticStartTypedScripts(SCRIPT_Return, players[ii].mo, true);
} }
} }
if (level.FromSnapshot)
{
// [Nash] run REOPEN scripts upon map re-entry
FBehavior::StaticStartTypedScripts(SCRIPT_Reopen, NULL, false);
}
StatusBar->AttachToPlayer (&players[consoleplayer]); StatusBar->AttachToPlayer (&players[consoleplayer]);
// unsafe world load // unsafe world load
E_WorldLoadedUnsafe(); E_WorldLoadedUnsafe();
@ -1354,22 +1370,6 @@ void G_FinishTravel ()
pawns[pawnsnum++] = pawn; pawns[pawnsnum++] = pawn;
} }
// [ZZ] fire the reopen hook.
// if level is loaded from snapshot, and we don't have savegamerestore, this means we returned from a hub.
if (level.FromSnapshot)
{
// [Nash] run REOPEN scripts upon map re-entry
FBehavior::StaticStartTypedScripts(SCRIPT_Reopen, NULL, false);
for (int i = 0; i < pawnsnum; i++)
{
// [ZZ] fire the enter hook.
E_PlayerEntered(int(pawns[i]->player - players), true);
//
FBehavior::StaticStartTypedScripts(SCRIPT_Return, pawns[i], true);
}
}
bglobal.FinishTravel (); bglobal.FinishTravel ();
// make sure that, after travelling has completed, no travelling thinkers are left. // make sure that, after travelling has completed, no travelling thinkers are left.

View file

@ -5511,9 +5511,6 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
{ {
if (state == PST_ENTER || (state == PST_LIVE && !savegamerestore)) if (state == PST_ENTER || (state == PST_LIVE && !savegamerestore))
{ {
// [ZZ] fire non-hub ENTER event
// level.time is a hack to make sure that we don't call it on dummy player initialization during hub return.
if (!level.time) E_PlayerEntered(int(p - players), false);
FBehavior::StaticStartTypedScripts (SCRIPT_Enter, p->mo, true); FBehavior::StaticStartTypedScripts (SCRIPT_Enter, p->mo, true);
} }
else if (state == PST_REBORN) else if (state == PST_REBORN)