From 8d75bfc3d2e996befe9b94b76b9f5e1644d02ebe Mon Sep 17 00:00:00 2001 From: biwa Date: Thu, 20 Jun 2019 14:53:51 +0200 Subject: [PATCH] - The missing textures checker now finds missing upper/lower textures on 3D floors when the appropriate flags of the Sector_Set3dFloor special are used. Fixes #269 --- .../ErrorChecks/CheckMissingTextures.cs | 125 ++++++++++++++++-- 1 file changed, 116 insertions(+), 9 deletions(-) diff --git a/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingTextures.cs b/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingTextures.cs index b99e9b7a..37a94be3 100755 --- a/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingTextures.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingTextures.cs @@ -17,7 +17,9 @@ #region ================== Namespaces using CodeImp.DoomBuilder.Map; +using System.Collections.Generic; using System.Threading; +using System; #endregion @@ -43,6 +45,18 @@ namespace CodeImp.DoomBuilder.BuilderModes #endregion + #region ================== Enum + + [Flags] + private enum Flags3DFloor + { + UseUpper = 1, + UseLower = 2, + RenderInside = 4 + } + + #endregion + #region ================== Methods // This runs the check @@ -51,18 +65,79 @@ namespace CodeImp.DoomBuilder.BuilderModes int progress = 0; int stepprogress = 0; + Dictionary sector3dfloors = new Dictionary(); + + // Create a cache of sectors that have 3D floors, with their flags relevant to the error checker + foreach (Linedef ld in General.Map.Map.Linedefs) + { + if (ld.Action == 160) + { + if ((ld.Args[1] & 4) == 4) // Type render inside + { + if (!sector3dfloors.ContainsKey(ld.Args[0])) + sector3dfloors.Add(ld.Args[0], Flags3DFloor.RenderInside); + } + + if ((ld.Args[2] & 16) == 16) // Flag use upper + { + if (!sector3dfloors.ContainsKey(ld.Args[0])) + sector3dfloors.Add(ld.Args[0], Flags3DFloor.UseUpper); + else + sector3dfloors[ld.Args[0]] |= Flags3DFloor.UseUpper; + } + + if ((ld.Args[2] & 32) == 32) // Flag use lower + { + if (!sector3dfloors.ContainsKey(ld.Args[0])) + sector3dfloors.Add(ld.Args[0], Flags3DFloor.UseLower); + else + sector3dfloors[ld.Args[0]] |= Flags3DFloor.UseLower; + } + } + } + // Go for all the sidedefs foreach(Sidedef sd in General.Map.Map.Sidedefs) { // Check upper texture. Also make sure not to return a false // positive if the sector on the other side has the ceiling // set to be sky - if(sd.HighRequired() && sd.HighTexture == "-") - { - if(sd.Line.Action == 181 && sd.Line.Args[1] > 0) continue; //mxd. Ceiling slopes doesn't require upper texture - if(sd.Other != null && sd.Other.Sector.CeilTexture != General.Map.Config.SkyFlatName) + if (sd.HighTexture == "-") { + if (sd.HighRequired()) { - SubmitResult(new ResultMissingTexture(sd, SidedefPart.Upper)); + if (sd.Line.Action == 181 && sd.Line.Args[1] > 0) continue; //mxd. Ceiling slopes doesn't require upper texture + if (sd.Other != null && sd.Other.Sector.CeilTexture != General.Map.Config.SkyFlatName) + { + SubmitResult(new ResultMissingTexture(sd, SidedefPart.Upper)); + } + } + else if (sd.Other != null) + { + // Check if the sidedef's sector is a 3D floor. Since it points toward the 3D floor it only needs a texture if inside rendering is enabled + if (sd.Sector.Tags.Count > 0) + { + foreach (int tag in sd.Sector.Tags) + { + if (sector3dfloors.ContainsKey(tag) && sector3dfloors[tag].HasFlag(Flags3DFloor.UseUpper) && sector3dfloors[tag].HasFlag(Flags3DFloor.RenderInside)) + { + SubmitResult(new ResultMissingTexture(sd, SidedefPart.Upper)); + break; + } + } + } + + // Check if the other sidedef's sector is a 3D floor, since we still might need a texture on this one depending on the flags + if (sd.Other.Sector.Tags.Count > 0) + { + foreach (int tag in sd.Other.Sector.Tags) + { + if (sector3dfloors.ContainsKey(tag) && sector3dfloors[tag].HasFlag(Flags3DFloor.UseUpper)) + { + SubmitResult(new ResultMissingTexture(sd, SidedefPart.Upper)); + break; + } + } + } } } @@ -75,13 +150,45 @@ namespace CodeImp.DoomBuilder.BuilderModes // Check lower texture. Also make sure not to return a false // positive if the sector on the other side has the floor // set to be sky - if(sd.LowRequired() && sd.LowTexture == "-") + if(sd.LowTexture == "-") { - if(sd.Line.Action == 181 && sd.Line.Args[0] > 0) continue; //mxd. Floor slopes doesn't require lower texture - if(sd.Other != null && sd.Other.Sector.FloorTexture != General.Map.Config.SkyFlatName) + if (sd.LowRequired()) { - SubmitResult(new ResultMissingTexture(sd, SidedefPart.Lower)); + if (sd.Line.Action == 181 && sd.Line.Args[0] > 0) continue; //mxd. Floor slopes doesn't require lower texture + if (sd.Other != null && sd.Other.Sector.FloorTexture != General.Map.Config.SkyFlatName) + { + SubmitResult(new ResultMissingTexture(sd, SidedefPart.Lower)); + } } + else if (sd.Other != null) + { + // Check if the sidedef's sector is a 3D floor. Since it points toward the 3D floor it only needs a texture if inside rendering is enabled + if (sd.Sector.Tags.Count > 0) + { + foreach (int tag in sd.Sector.Tags) + { + if (sector3dfloors.ContainsKey(tag) && sector3dfloors[tag].HasFlag(Flags3DFloor.UseLower) && sector3dfloors[tag].HasFlag(Flags3DFloor.RenderInside)) + { + SubmitResult(new ResultMissingTexture(sd, SidedefPart.Lower)); + break; + } + } + } + + // Check if the other sidedef's sector is a 3D floor, since we still might need a texture on this one depending on the flags + if (sd.Other.Sector.Tags.Count > 0) + { + foreach (int tag in sd.Other.Sector.Tags) + { + if (sector3dfloors.ContainsKey(tag) && sector3dfloors[tag].HasFlag(Flags3DFloor.UseLower)) + { + SubmitResult(new ResultMissingTexture(sd, SidedefPart.Lower)); + break; + } + } + } + } + } // Handle thread interruption