From 43c5fa93f93f09d9c13d69d9fe09b23237548b52 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 24 Feb 2017 21:45:53 +0100 Subject: [PATCH] - fixed handling of PlayerEntered event. This was done in P_SpawnPlayer where it would be called not only on voodoo dolls but also on temporary player pawns. The second case was attempted to avoid, but this would break intra-hub travels to unvisited levels. Moved the handling to G_DoLoadLevel for all cases where we have a clear and unambiguous situation with all players being set up and no voodoo dolls that might trigger an event. --- src/g_level.cpp | 36 ++++++++++++++++++------------------ src/p_mobj.cpp | 3 --- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index ab97ced00..b811c1215 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -125,6 +125,7 @@ int starttime; extern FString BackupSaveName; bool savegamerestore; +int finishstate; extern int mousex, mousey; extern bool sendpause, sendsave, sendturn180, SendLand; @@ -160,6 +161,7 @@ void G_DeferedInitNew (FGameStartup *gs) d_skill = gs->Skill; CheckWarpTransMap (d_mapname, true); gameaction = ga_newgame2; + finishstate = FINISH_NoHub; } //========================================================================== @@ -897,6 +899,7 @@ void G_DoCompleted (void) } gamestate = GS_INTERMISSION; + finishstate = mode; viewactive = 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 (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]); // unsafe world load E_WorldLoadedUnsafe(); @@ -1354,22 +1370,6 @@ void G_FinishTravel () 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 (); // make sure that, after travelling has completed, no travelling thinkers are left. diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index ef5908fda..fd0df678b 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5511,9 +5511,6 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) { 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); } else if (state == PST_REBORN)