From 111479063f7120ff2b05b19ee558a0d3c98f8a6d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 4 Jan 2016 21:05:09 +0100 Subject: [PATCH] - fixed a potential overflow issue with calculating a portal's origin point. - fixed: Sector_SetPortal's Eternity translation was not correct. The ZDoom variant allows specifying the plane as part of the portal, Eternity does not. Added a new 'plane' type 3 which just means 'any'. --- src/p_spec.cpp | 11 ++++++----- wadsrc/static/xlat/eternity.txt | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index e2cc0025b..95995bdab 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1125,10 +1125,11 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha) lines[i].args[2] == plane && lines[i].args[3] == 1) { - fixed_t x1 = (line->v1->x + line->v2->x) >> 1; - fixed_t y1 = (line->v1->y + line->v2->y) >> 1; - fixed_t x2 = (lines[i].v1->x + lines[i].v2->x) >> 1; - fixed_t y2 = (lines[i].v1->y + lines[i].v2->y) >> 1; + // beware of overflows. + fixed_t x1 = fixed_t((SQWORD(line->v1->x) + SQWORD(line->v2->x)) >> 1); + fixed_t y1 = fixed_t((SQWORD(line->v1->y) + SQWORD(line->v2->y)) >> 1); + fixed_t x2 = fixed_t((SQWORD(lines[i].v1->x) + SQWORD(lines[i].v2->x)) >> 1); + fixed_t y2 = fixed_t((SQWORD(lines[i].v1->y) + SQWORD(lines[i].v2->y)) >> 1); fixed_t alpha = Scale (lines[i].args[4], OPAQUE, 255); AStackPoint *anchor = Spawn(x1, y1, 0, NO_REPLACE); @@ -1155,7 +1156,7 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha) // This must be done here to ensure that it gets done only after the portal is set up if (lines[j].special == Sector_SetPortal && lines[j].args[1] == 1 && - lines[j].args[2] == plane && + (lines[j].args[2] == plane || lines[j].args[2] == 3) && lines[j].args[3] == sectortag) { if (lines[j].args[0] == 0) diff --git a/wadsrc/static/xlat/eternity.txt b/wadsrc/static/xlat/eternity.txt index ad270beb4..7b4367ee3 100644 --- a/wadsrc/static/xlat/eternity.txt +++ b/wadsrc/static/xlat/eternity.txt @@ -170,7 +170,7 @@ define Unsupported (0) 384 = 0, Static_Init(0, 3, 0, 10) // "Attach_MirrorCeilingToControl" // Attach tagged portal to front sector -385 = 0, Sector_SetPortal(0, 1, 2, tag) // "Apply_PortalToFrontsector" +385 = 0, Sector_SetPortal(0, 1, 3, tag) // "Apply_PortalToFrontsector" // Slopes! 386 = 0, Plane_Align (1, 0) // "Slope_FrontsectorFloor"