From 549a9d3cf0ae304d1ae40875e27fcad3e1eede03 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 3 Jan 2018 10:48:10 +0200 Subject: [PATCH] Extended Actor.CheckMove() with optional position information https://forum.zdoom.org/viewtopic.php?t=58964 --- src/p_map.cpp | 19 ++++++++++++++++--- wadsrc/static/zscript/actor.txt | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index ea4031eb48..7cab335c09 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2784,9 +2784,8 @@ DEFINE_ACTION_FUNCTION(AActor, TryMove) // //========================================================================== -bool P_CheckMove(AActor *thing, const DVector2 &pos, int flags) +static bool P_CheckMove(AActor *thing, const DVector2 &pos, FCheckPosition& tm, int flags) { - FCheckPosition tm; double newz = thing->Z(); auto f1 = thing->flags & MF_PICKUP; @@ -2879,13 +2878,27 @@ bool P_CheckMove(AActor *thing, const DVector2 &pos, int flags) return true; } +bool P_CheckMove(AActor *thing, const DVector2 &pos, int flags) +{ + FCheckPosition tm; + return P_CheckMove(thing, pos, tm, flags); +} + DEFINE_ACTION_FUNCTION(AActor, CheckMove) { PARAM_SELF_PROLOGUE(AActor); PARAM_FLOAT(x); PARAM_FLOAT(y); PARAM_INT_DEF(flags); - ACTION_RETURN_BOOL(P_CheckMove(self, DVector2(x, y), flags)); + PARAM_POINTER_DEF(tm, FCheckPosition); + if (tm == nullptr) + { + ACTION_RETURN_BOOL(P_CheckMove(self, DVector2(x, y), flags)); + } + else + { + ACTION_RETURN_BOOL(P_CheckMove(self, DVector2(x, y), *tm, flags)); + } } diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index d9847e2b14..6dd222fbfc 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -624,7 +624,7 @@ class Actor : Thinker native } native bool TryMove(vector2 newpos, int dropoff, bool missilecheck = false, FCheckPosition tm = null); - native bool CheckMove(vector2 newpos, int flags = 0); + native bool CheckMove(vector2 newpos, int flags = 0, FCheckPosition tm = null); native void NewChaseDir(); native void RandomChaseDir(); native bool CheckMissileRange();