From 449d4963ae23c20f3dc31fa1b6543a28e09e4946 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 16 Nov 2016 01:13:29 +0100 Subject: [PATCH] Mapping error workaround --- src/r_poly_wall.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/r_poly_wall.cpp b/src/r_poly_wall.cpp index cd932214d..6921b1a33 100644 --- a/src/r_poly_wall.cpp +++ b/src/r_poly_wall.cpp @@ -229,9 +229,29 @@ FTexture *RenderPolyWall::GetTexture() { FTexture *tex = TexMan(Line->sidedef->GetTexture(Texpart), true); if (tex == nullptr || tex->UseType == FTexture::TEX_Null) - return nullptr; - else - return tex; + { + // Mapping error. Doom floodfills this with a plane. + // This code doesn't do that, but at least it uses the "right" texture.. + + if (Line->linedef && Line->backsector && Line->linedef->sidedef[0] == Line->sidedef) + { + if (Texpart == side_t::top) + tex = TexMan(Line->linedef->backsector->GetTexture(sector_t::ceiling), true); + else if (Texpart == side_t::bottom) + tex = TexMan(Line->linedef->backsector->GetTexture(sector_t::floor), true); + } + if (Line->linedef && Line->backsector && Line->linedef->sidedef[1] == Line->sidedef) + { + if (Texpart == side_t::top) + tex = TexMan(Line->linedef->frontsector->GetTexture(sector_t::ceiling), true); + else if (Texpart == side_t::bottom) + tex = TexMan(Line->linedef->frontsector->GetTexture(sector_t::floor), true); + } + + if (tex == nullptr || tex->UseType == FTexture::TEX_Null) + return nullptr; + } + return tex; } int RenderPolyWall::GetLightLevel()