From cb89a1a81aadcf6ed4141831c7c6df6aefd2fd5a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 8 Jan 2017 14:59:31 +0100 Subject: [PATCH] - fixed inconsistent use of line_t::portaltransferred. Some parts used 0 as 'nothing' others used UINT_MAX. 0 should refer to the map's default sky, not to nothing. --- src/gl/scene/gl_walls.cpp | 2 +- src/p_sectors.cpp | 14 ++++++++++++++ src/p_setup.cpp | 2 ++ src/p_udmf.cpp | 3 +++ wadsrc/static/zscript/base.txt | 4 +++- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 3acf209a6..89eb1d67f 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -1547,7 +1547,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) zbottom[1] = zfloor[1]; PutPortal(PORTALTYPE_LINETOLINE); } - else if (seg->linedef->portaltransferred > 0) + else if (seg->linedef->GetTransferredPortal()) { SkyLine(frontsector, seg->linedef); } diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index ef28af020..3d77b44c9 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -1772,6 +1772,19 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt) ACTION_RETURN_FLOAT(self->CenterCeiling()); } + DEFINE_ACTION_FUNCTION(_Sector, Index) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + unsigned ndx = self->Index(); + if (ndx >= level.sectors.Size()) + { + // This qualifies as an array out of bounds exception. Normally it can only happen when a sector copy is concerned which scripts should not be able to create. + va_list ap; + throw CVMAbortException(X_ARRAY_OUT_OF_BOUNDS, "Accessed invalid sector", ap); + } + ACTION_RETURN_INT(ndx); + } + //=========================================================================== // // @@ -2100,6 +2113,7 @@ DEFINE_FIELD_X(Line, line_t, backsector) DEFINE_FIELD_X(Line, line_t, validcount) DEFINE_FIELD_X(Line, line_t, locknumber) DEFINE_FIELD_X(Line, line_t, portalindex) +DEFINE_FIELD_X(Line, line_t, portaltransferred) DEFINE_FIELD_X(Secplane, secplane_t, normal) DEFINE_FIELD_X(Secplane, secplane_t, D) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index d81376abe..10f4265d3 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -2156,6 +2156,7 @@ void P_LoadLineDefs (MapData * map) { ld->alpha = 1.; // [RH] Opaque by default ld->portalindex = UINT_MAX; + ld->portaltransferred = UINT_MAX; // [RH] Translate old linedef special and flags to be // compatible with the new format. @@ -2249,6 +2250,7 @@ void P_LoadLineDefs2 (MapData * map) int j; ld->portalindex = UINT_MAX; + ld->portaltransferred = UINT_MAX; for (j = 0; j < 5; j++) ld->args[j] = mld->args[j]; diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index ba9805b1c..8e88fc89d 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1824,6 +1824,9 @@ public: { short tempalpha[2] = { SHRT_MIN, SHRT_MIN }; + lines[line].portalindex = UINT_MAX; + lines[line].portaltransferred = UINT_MAX; + lines[line] = ParsedLines[line]; for(int sd = 0; sd < 2; sd++) diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 673257a3c..b48f0ee58 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -226,7 +226,7 @@ struct Line native }; - //native readonly vertex v1, v2; // vertices, from v1 to v2 + native readonly vertex v1, v2; // vertices, from v1 to v2 native readonly Vector2 delta; // precalculated v2 - v1 for side checking native uint flags; native uint activation; // activation type @@ -239,6 +239,7 @@ struct Line native native int validcount; // if == validcount, already checked native int locknumber; // [Dusk] lock number for special native readonly uint portalindex; + native readonly uint portaltransferred; } struct SecPlane native @@ -378,6 +379,7 @@ struct Sector native native readonly int sectornum; + native int Index(); native double, Sector, F3DFloor NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0); native double, Sector, F3DFloor NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0);