From 4d66e9a8bbdf7517c4f107263abfccc450f63add Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 14 Nov 2019 14:23:53 -0500 Subject: [PATCH] - remove SetLineSideRefs - this actually cannot be exported right now, due to the fact that both sides and lines have backreferences to themselves and their ancestry, and that linedefs have forward references to the sectors on their respective sides. - made FlipLineSideRefs native, due to the SetLineSideRefs removal - fixed a bug with FlipLineSideRefs that rendered upper and lower textures incorrectly due to incorrect sector references - FlipLineSideRefs now should only work on single-sided lines --- src/maploader/postprocessor.cpp | 23 +++++++++++--------- wadsrc/static/zscript/level_postprocessor.zs | 9 +------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/maploader/postprocessor.cpp b/src/maploader/postprocessor.cpp index 8428c32be..74dc576ea 100644 --- a/src/maploader/postprocessor.cpp +++ b/src/maploader/postprocessor.cpp @@ -459,23 +459,26 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetLineVertexes) return 0; } -DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetLineSideRefs) +DEFINE_ACTION_FUNCTION(DLevelPostProcessor, FlipLineSideRefs) { PARAM_SELF_PROLOGUE(DLevelPostProcessor); PARAM_UINT(lineidx); - PARAM_UINT(sideidx1); - PARAM_UINT(sideidx2); - if (lineidx < self->Level->lines.Size() && - sideidx1 < self->Level->sides.Size() && - sideidx2 < self->Level->sides.Size()) + if (lineidx < self->Level->lines.Size()) { line_t *line = &self->Level->lines[lineidx]; - side_t *side1 = &self->Level->sides[sideidx1]; - side_t *side2 = &self->Level->sides[sideidx2]; + side_t *side1 = line->sidedef[1]; + side_t *side2 = line->sidedef[0]; - line->sidedef[0] = side1; - line->sidedef[1] = side2; + if (!!side1 && !!side2) // don't flip single-sided lines + { + sector_t *frontsector = line->sidedef[1]->sector; + sector_t *backsector = line->sidedef[0]->sector; + line->sidedef[0] = side1; + line->sidedef[1] = side2; + line->frontsector = frontsector; + line->backsector = backsector; + } } self->loader->ForceNodeBuild = true; return 0; diff --git a/wadsrc/static/zscript/level_postprocessor.zs b/wadsrc/static/zscript/level_postprocessor.zs index 0ca307b7e..9b3b7b750 100644 --- a/wadsrc/static/zscript/level_postprocessor.zs +++ b/wadsrc/static/zscript/level_postprocessor.zs @@ -48,7 +48,7 @@ class LevelPostProcessor native play protected native void SetVertex(uint vertex, double x, double y); protected native void SetLineVertexes(uint Line, uint v1, uint v2); - protected native void SetLineSideRefs(uint Line, uint s1, uint s2); + protected native void FlipLineSideRefs(uint Line); protected native void SetLineSectorRef(uint line, uint side, uint sector); protected native Actor GetDefaultActor(Name actorclass); @@ -59,13 +59,6 @@ class LevelPostProcessor native play SetLineVertexes(Line, v2, v1); } - protected void FlipLineSideRefs(uint Line) - { - uint s1 = level.lines[Line].sidedef[0].Index(); - uint s2 = level.lines[Line].sidedef[1].Index(); - SetLineSideRefs(Line, s2, s1); - } - protected void SetWallTexture(int line, int side, int texpart, String texture) { SetWallTextureID(line, side, texpart, TexMan.CheckForTexture(texture, TexMan.Type_Wall));