From 285834ae5b66eb66723a8b430ef65997cf1c7ba6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 12 Nov 2017 11:03:08 +0200 Subject: [PATCH 1/4] Fixed return state of player entered event https://forum.zdoom.org/viewtopic.php?t=58433 --- src/g_level.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index d5044942e..701d35b53 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -128,7 +128,7 @@ int starttime; extern FString BackupSaveName; bool savegamerestore; -int finishstate; +int finishstate = FINISH_NoHub; extern int mousex, mousey; extern bool sendpause, sendsave, sendturn180, SendLand; @@ -851,6 +851,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)))) @@ -860,7 +862,6 @@ void G_DoCompleted (void) } gamestate = GS_INTERMISSION; - finishstate = mode; viewactive = false; automapactive = false; @@ -1038,12 +1039,20 @@ void G_DoLoadLevel (int position, bool autosave) { players[ii].camera = players[ii].mo; } - if (!savegamerestore) + + if (savegamerestore) { - E_PlayerEntered(ii, finishstate == FINISH_SameHub); + continue; + } + + const bool fromSnapshot = level.FromSnapshot; + E_PlayerEntered(ii, fromSnapshot && finishstate == FINISH_SameHub); + + if (fromSnapshot) + { + // 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); } } From 5d83ee5e891d4da3be95a1d7eb9f74e69f856786 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 12 Nov 2017 14:44:21 +0200 Subject: [PATCH 2/4] Exposed String.Remove() function to ZScript https://forum.zdoom.org/viewtopic.php?t=58402 --- src/scripting/thingdef_data.cpp | 9 +++++++++ wadsrc/static/zscript/base.txt | 1 + 2 files changed, 10 insertions(+) diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 540b61a36..c746c536d 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/base.txt b/wadsrc/static/zscript/base.txt index 9cba0cb09..89dd0ab7d 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(); From 5935e14c098b8321d98a9cf67d36873370bf3614 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 13 Nov 2017 21:00:17 +0100 Subject: [PATCH 3/4] - exported P_Thing_Warp to ZScript. --- src/p_things.cpp | 22 ++++++++++++++++++++++ wadsrc/static/zscript/actor.txt | 1 + 2 files changed, 23 insertions(+) diff --git a/src/p_things.cpp b/src/p_things.cpp index 06a0252ab..0ff35bdcc 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/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 3d272b05d..28b4039c0 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(AActor *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; From 0dcb1fe74ce338613081c98e5be3e93935bc0192 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 14 Nov 2017 18:42:36 -0500 Subject: [PATCH 4/4] - fix zscript-side definition for Warp --- wadsrc/static/zscript/actor.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 28b4039c0..13f5140c9 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -683,7 +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(AActor *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); + 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;