From e6e5267dcb3c05c0aa773a3253d3e6ff15214b7e Mon Sep 17 00:00:00 2001 From: James Lambert Date: Sat, 2 Dec 2023 21:02:32 -0700 Subject: [PATCH] Prevent portals from being opened under signs --- src/scene/portal_surface.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/scene/portal_surface.c b/src/scene/portal_surface.c index 1185d26..6018e14 100644 --- a/src/scene/portal_surface.c +++ b/src/scene/portal_surface.c @@ -306,14 +306,17 @@ int portalSurfaceAdjustPosition(struct PortalSurface* surface, struct Transform* continue; } + struct Vector2s16 edgeDir; + vector2s16Sub(&b, &a, &edgeDir); + struct Vector2s16 offset; - int distance = portalMax.x - edgeMin.x; + int distance = edgeDir.y >= 0 ? portalMax.x - edgeMin.x : PORTAL_SURFACE_OVERLAP; offset.x = -distance; offset.y = 0; int distanceCheck = edgeMax.x - portalMin.x; - if (distanceCheck < distance) { + if (distanceCheck < distance && edgeDir.y <= 0) { distance = distanceCheck; offset.x = distance; offset.y = 0; @@ -321,7 +324,7 @@ int portalSurfaceAdjustPosition(struct PortalSurface* surface, struct Transform* distanceCheck = portalMax.y - edgeMin.y; - if (distanceCheck < distance) { + if (distanceCheck < distance && edgeDir.x <= 0) { distance = distanceCheck; offset.x = 0; offset.y = -distance; @@ -329,7 +332,7 @@ int portalSurfaceAdjustPosition(struct PortalSurface* surface, struct Transform* distanceCheck = edgeMax.y - portalMin.y; - if (distanceCheck < distance) { + if (distanceCheck < distance && edgeDir.x >= 0) { distance = distanceCheck; offset.x = 0; offset.y = distance;