2014-01-13 08:06:56 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
|
{
|
|
|
|
|
[ErrorChecker("Check unused textures", true, 60)]
|
2019-08-08 13:06:10 +00:00
|
|
|
|
public class CheckUnusedTextures : BaseCheckTextures
|
2014-01-13 08:06:56 +00:00
|
|
|
|
{
|
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
2014-06-30 08:17:43 +00:00
|
|
|
|
private const int PROGRESS_STEP = 1000;
|
2014-01-13 08:06:56 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor / Destructor
|
|
|
|
|
|
|
|
|
|
// Constructor
|
2019-08-08 13:06:10 +00:00
|
|
|
|
public CheckUnusedTextures() : base()
|
2014-01-13 08:06:56 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#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();
|
|
|
|
|
|
2014-01-13 08:06:56 +00:00
|
|
|
|
// Go for all the sidedefs
|
|
|
|
|
foreach(Sidedef sd in General.Map.Map.Sidedefs)
|
|
|
|
|
{
|
|
|
|
|
// Check upper texture
|
2014-03-05 09:21:28 +00:00
|
|
|
|
if(!sd.HighRequired() && sd.LongHighTexture != MapSet.EmptyLongName)
|
2014-01-13 08:06:56 +00:00
|
|
|
|
{
|
2019-08-08 13:06:10 +00:00
|
|
|
|
if (sd.Other == null)
|
|
|
|
|
SubmitResult(new ResultUnusedTexture(sd, SidedefPart.Upper));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bool unused = true;
|
|
|
|
|
|
|
|
|
|
// 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))
|
|
|
|
|
{
|
|
|
|
|
unused = false;
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
unused = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unused) SubmitResult(new ResultUnusedTexture(sd, SidedefPart.Upper));
|
|
|
|
|
}
|
2014-01-13 08:06:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check lower texture
|
2014-03-05 09:21:28 +00:00
|
|
|
|
if(!sd.LowRequired() && sd.LongLowTexture != MapSet.EmptyLongName)
|
2014-01-13 08:06:56 +00:00
|
|
|
|
{
|
2019-08-08 13:06:10 +00:00
|
|
|
|
if (sd.Other == null)
|
|
|
|
|
SubmitResult(new ResultUnusedTexture(sd, SidedefPart.Lower));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bool unused = true;
|
|
|
|
|
|
|
|
|
|
// 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))
|
|
|
|
|
{
|
|
|
|
|
unused = false;
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
unused = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unused) SubmitResult(new ResultUnusedTexture(sd, SidedefPart.Lower));
|
|
|
|
|
}
|
2014-01-13 08:06:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle thread interruption
|
|
|
|
|
try { Thread.Sleep(0); }
|
|
|
|
|
catch(ThreadInterruptedException) { return; }
|
|
|
|
|
|
|
|
|
|
// We are making progress!
|
|
|
|
|
if((++progress / PROGRESS_STEP) > stepprogress)
|
|
|
|
|
{
|
|
|
|
|
stepprogress = (progress / PROGRESS_STEP);
|
|
|
|
|
AddProgress(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|