From 047384cb5a485f3b640a2c58b632146b8b748ce4 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sat, 19 Dec 2020 11:00:57 -0600 Subject: [PATCH] Merged https://github.com/coelckers/gzdoom/pull/1192 (CanCrossLine) --- src/playsim/p_map.cpp | 39 +++++++++++++++++++++++++++ wadsrc/static/zscript/actors/actor.zs | 6 +++++ 2 files changed, 45 insertions(+) diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index 9ba6dd8e1..151953d07 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -155,6 +155,38 @@ bool P_CanCollideWith(AActor *tmthing, AActor *thing) return true; } +//========================================================================== +// +// CanCrossLine +// +// Checks if an actor can cross a line after all checks are processed. +// If false, the line blocks them. +//========================================================================== + +bool P_CanCrossLine(AActor *mo, line_t *line, int side, DVector3 next) +{ + static unsigned VIndex = ~0u; + if (VIndex == ~0u) + { + VIndex = GetVirtualIndex(RUNTIME_CLASS(AActor), "CanCrossLine"); + assert(VIndex != ~0u); + } + + VMValue params[] = { mo, line, side, next.X, next.Y, next.Z, false }; + VMReturn ret; + int retval; + ret.IntAt(&retval); + + auto clss = mo->GetClass(); + VMFunction *func = clss->Virtuals.Size() > VIndex ? clss->Virtuals[VIndex] : nullptr; + if (func != nullptr) + { + VMCall(func, params, countof(params), &ret, 1); + return retval; + } + return true; +} + //========================================================================== // // FindRefPoint @@ -962,6 +994,13 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec } } + if (!P_CanCrossLine(tm.thing, ld, P_PointOnLineSide(cres.Position, ld), tm.pos)) + { + if (wasfit) + tm.thing->BlockingLine = ld; + + return false; + } // If the floor planes on both sides match we should recalculate open.bottom at the actual position we are checking // This is to avoid bumpy movement when crossing a linedef with the same slope on both sides. // This should never narrow down the opening, though, only widen it. diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 45662bdce..7cc252c7f 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -485,6 +485,12 @@ class Actor : Thinker native return true; } + // Called by PIT_CheckLine to check if an actor can cross a line. + virtual bool CanCrossLine(Line crossing, int side, Vector3 next) + { + return true; + } + // Called by revival/resurrection to check if one can resurrect the other. // "other" can be null when not passive. virtual bool CanResurrect(Actor other, bool passive)