diff --git a/src/g_level.cpp b/src/g_level.cpp index a2b15b02d5e..0ee56d6c3d0 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -129,7 +129,7 @@ int starttime; extern FString BackupSaveName; bool savegamerestore; -int finishstate; +int finishstate = FINISH_NoHub; extern int mousex, mousey; extern bool sendpause, sendsave, sendturn180, SendLand; @@ -852,6 +852,8 @@ void G_DoCompleted (void) level.maptime = 0; } + finishstate = mode; + if (!deathmatch && ((level.flags & LEVEL_NOINTERMISSION) || ((nextcluster == thiscluster) && (thiscluster->flags & CLUSTER_HUB) && !(thiscluster->flags & CLUSTER_ALLOWINTERMISSION)))) @@ -861,7 +863,6 @@ void G_DoCompleted (void) } gamestate = GS_INTERMISSION; - finishstate = mode; viewactive = false; automapactive = false; @@ -1039,12 +1040,20 @@ void G_DoLoadLevel (int position, bool autosave) { players[ii].camera = players[ii].mo; } - if (!savegamerestore) + + if (savegamerestore) + { + continue; + } + + const bool fromSnapshot = level.FromSnapshot; + E_PlayerEntered(ii, fromSnapshot && finishstate == FINISH_SameHub); + + if (fromSnapshot) { - 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. + FBehavior::StaticStartTypedScripts(SCRIPT_Return, players[ii].mo, true); } - // ENTER scripts are being handled when the player gets spawned, this cannot be changed due to its effect on voodoo dolls. - if (level.FromSnapshot && !savegamerestore) FBehavior::StaticStartTypedScripts(SCRIPT_Return, players[ii].mo, true); } } diff --git a/src/p_things.cpp b/src/p_things.cpp index 06a0252ab2e..0ff35bdcc50 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -945,3 +945,25 @@ int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, do caller->SetOrigin(old, true); return false; } + +//========================================================================== +// +// A_Warp +// +//========================================================================== + +DEFINE_ACTION_FUNCTION(AActor, Warp) +{ + PARAM_SELF_PROLOGUE(AActor) + PARAM_OBJECT_DEF(destination, AActor) + PARAM_FLOAT_DEF(xofs) + PARAM_FLOAT_DEF(yofs) + PARAM_FLOAT_DEF(zofs) + PARAM_ANGLE_DEF(angle) + PARAM_INT_DEF(flags) + PARAM_FLOAT_DEF(heightoffset) + PARAM_FLOAT_DEF(radiusoffset) + PARAM_ANGLE_DEF(pitch) + + ACTION_RETURN_INT(!!P_Thing_Warp(self, destination, xofs, yofs, zofs, angle, flags, heightoffset, radiusoffset, pitch)); +} diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 540b61a367b..c746c536d7d 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -1225,6 +1225,15 @@ DEFINE_ACTION_FUNCTION(FStringStruct, Truncate) return 0; } +DEFINE_ACTION_FUNCTION(FStringStruct, Remove) +{ + PARAM_SELF_STRUCT_PROLOGUE(FString); + PARAM_UINT(index); + PARAM_UINT(remlen); + self->Remove(index, remlen); + return 0; +} + // CharAt and CharCodeAt is how JS does it, and JS is similar here in that it doesn't have char type as int. DEFINE_ACTION_FUNCTION(FStringStruct, CharAt) { diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 3d272b05d84..13f5140c9ef 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -683,6 +683,7 @@ class Actor : Thinker native native float AccuracyFactor(); native bool MorphMonster (Class spawntype, int duration, int style, Class enter_flash, Class exit_flash); action native void SetCamera(Actor cam, bool revert = false); + native bool Warp(Actor dest, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0, int flags = 0, double heightoffset = 0, double radiusoffset = 0, double pitch = 0); // DECORATE compatible functions native clearscope int CountInv(class itemtype, int ptr_select = AAPTR_DEFAULT) const; diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 9cba0cb0926..89dd0ab7df7 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -684,6 +684,7 @@ struct StringStruct native native String Left(int len) const; native String Mid(int pos = 0, int len = 2147483647) const; native void Truncate(int newlen); + native void Remove(int index, int remlen); native String CharAt(int pos) const; native int CharCodeAt(int pos) const; native String Filter();