2009-05-24 22:26:25 +00:00
|
|
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
2019-06-20 12:53:51 +00:00
|
|
|
|
using System.Collections.Generic;
|
2009-05-24 22:26:25 +00:00
|
|
|
|
using System.Threading;
|
2019-06-20 12:53:51 +00:00
|
|
|
|
using System;
|
2009-05-24 22:26:25 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
[ErrorChecker("Check missing textures", true, 80)]
|
2019-08-08 13:06:10 +00:00
|
|
|
|
public class CheckMissingTextures : BaseCheckTextures
|
2013-09-11 09:47:53 +00:00
|
|
|
|
{
|
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
2014-06-30 08:17:43 +00:00
|
|
|
|
private const int PROGRESS_STEP = 1000;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor / Destructor
|
|
|
|
|
|
|
|
|
|
// Constructor
|
2019-08-08 13:06:10 +00:00
|
|
|
|
public CheckMissingTextures() : base()
|
2013-09-11 09:47:53 +00:00
|
|
|
|
{
|
2019-06-20 12:53:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
|
|
// This runs the check
|
|
|
|
|
public override void Run()
|
|
|
|
|
{
|
|
|
|
|
int progress = 0;
|
|
|
|
|
int stepprogress = 0;
|
|
|
|
|
|
2019-08-08 13:06:10 +00:00
|
|
|
|
Build3DFloorCache();
|
2019-06-20 12:53:51 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Go for all the sidedefs
|
2015-12-28 15:01:53 +00:00
|
|
|
|
foreach(Sidedef sd in General.Map.Map.Sidedefs)
|
2013-09-11 09:47:53 +00:00
|
|
|
|
{
|
|
|
|
|
// 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
|
2019-08-08 13:06:10 +00:00
|
|
|
|
if (sd.LongHighTexture == MapSet.EmptyLongName) {
|
2019-06-20 12:53:51 +00:00
|
|
|
|
if (sd.HighRequired())
|
|
|
|
|
{
|
2023-05-26 12:09:04 +00:00
|
|
|
|
if (sd.Line.Action == 700 && sd.Line.Args[1] > 0) continue; //mxd. Ceiling slopes doesn't require upper texture
|
2021-08-14 09:33:52 +00:00
|
|
|
|
|
|
|
|
|
SubmitResult(new ResultMissingTexture(sd, SidedefPart.Upper));
|
2019-06-20 12:53:51 +00:00
|
|
|
|
}
|
|
|
|
|
else if (sd.Other != null)
|
2013-09-11 09:47:53 +00:00
|
|
|
|
{
|
2019-06-20 12:53:51 +00:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check middle texture
|
2015-12-28 15:01:53 +00:00
|
|
|
|
if(sd.MiddleRequired() && sd.MiddleTexture == "-")
|
2013-09-11 09:47:53 +00:00
|
|
|
|
{
|
|
|
|
|
SubmitResult(new ResultMissingTexture(sd, SidedefPart.Middle));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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
|
2019-08-08 13:06:10 +00:00
|
|
|
|
if(sd.LongLowTexture == MapSet.EmptyLongName)
|
2013-09-11 09:47:53 +00:00
|
|
|
|
{
|
2019-06-20 12:53:51 +00:00
|
|
|
|
if (sd.LowRequired())
|
2013-09-11 09:47:53 +00:00
|
|
|
|
{
|
2023-05-26 12:09:04 +00:00
|
|
|
|
if (sd.Line.Action == 700 && sd.Line.Args[0] > 0) continue; //mxd. Floor slopes doesn't require lower texture
|
2021-08-14 09:33:52 +00:00
|
|
|
|
|
|
|
|
|
SubmitResult(new ResultMissingTexture(sd, SidedefPart.Lower));
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2019-06-20 12:53:51 +00:00
|
|
|
|
else if (sd.Other != null)
|
|
|
|
|
{
|
|
|
|
|
if (sd.Sector.Tags.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (int tag in sd.Sector.Tags)
|
|
|
|
|
{
|
2021-09-03 16:31:36 +00:00
|
|
|
|
// 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
|
2019-06-20 12:53:51 +00:00
|
|
|
|
if (sector3dfloors.ContainsKey(tag) && sector3dfloors[tag].HasFlag(Flags3DFloor.UseLower) && sector3dfloors[tag].HasFlag(Flags3DFloor.RenderInside))
|
|
|
|
|
{
|
|
|
|
|
SubmitResult(new ResultMissingTexture(sd, SidedefPart.Lower));
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-09-03 16:31:36 +00:00
|
|
|
|
|
|
|
|
|
// Check if the sector is a floor to be lowered.
|
|
|
|
|
if (floorlowertolowest.RequiresTexture(sd, tag))
|
|
|
|
|
{
|
|
|
|
|
SubmitResult(new ResultMissingTexture(sd, SidedefPart.Lower));
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-20 12:53:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sd.Other.Sector.Tags.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (int tag in sd.Other.Sector.Tags)
|
|
|
|
|
{
|
2021-09-03 16:31:36 +00:00
|
|
|
|
// 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
|
2019-06-20 12:53:51 +00:00
|
|
|
|
if (sector3dfloors.ContainsKey(tag) && sector3dfloors[tag].HasFlag(Flags3DFloor.UseLower))
|
|
|
|
|
{
|
|
|
|
|
SubmitResult(new ResultMissingTexture(sd, SidedefPart.Lower));
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-09-03 16:31:36 +00:00
|
|
|
|
|
|
|
|
|
// Check if the other sidedef's sector is a floor to be raised.
|
|
|
|
|
if (floorraisetonexthigher.RequiresTexture(sd.Other, tag) || floorraisetohighest.RequiresTexture(sd.Other, tag))
|
|
|
|
|
{
|
|
|
|
|
SubmitResult(new ResultMissingTexture(sd, SidedefPart.Lower));
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-20 12:53:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle thread interruption
|
|
|
|
|
try { Thread.Sleep(0); }
|
2016-02-01 22:04:00 +00:00
|
|
|
|
catch(ThreadInterruptedException) { return; }
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
|
|
|
|
// We are making progress!
|
2015-12-28 15:01:53 +00:00
|
|
|
|
if((++progress / PROGRESS_STEP) > stepprogress)
|
2013-09-11 09:47:53 +00:00
|
|
|
|
{
|
|
|
|
|
stepprogress = (progress / PROGRESS_STEP);
|
|
|
|
|
AddProgress(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
2009-05-24 22:26:25 +00:00
|
|
|
|
}
|