Skip to content

Commit

Permalink
forced casing, added size checks, prevent duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
Stalker2106 committed Dec 1, 2024
1 parent 50e3a7c commit eba5e4b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,33 @@ static void Main(string[] args)

static bool Bundle(string[] bitmapsPath, string outputWAD)
{
List<string> processedTextures = new List<string>();
// Create wad
WadFile wad = new WadFile(Sledge.Formats.Texture.Wad.Version.Wad3);
foreach (var imagePath in bitmapsPath)
{
string textureName = Path.GetFileNameWithoutExtension(imagePath);
if (textureName.Length > 16) textureName = textureName.Substring(0, 16);
string textureName = Path.GetFileNameWithoutExtension(imagePath).ToLower();
if (textureName.Length > 16) {
string shortTexName = textureName.Substring(0, 16);
Console.WriteLine($"WARNING: Texture {textureName} is longer than 16 chars, truncating to {shortTexName}");
textureName = shortTexName;
}
if (processedTextures.Contains(textureName)) {
Console.WriteLine($"ERROR: Texture {textureName} is duplicated in source, aborting...");
return false;
}
MipTextureLump mipTexLump = new MipTextureLump();
ColorPalette palette = new ColorPalette(256);
mipTexLump.Name = textureName;
mipTexLump.NumMips = 4;
mipTexLump.MipData = new byte[mipTexLump.NumMips][];
// Set properties
SKBitmap bitmap = SKBitmap.Decode(imagePath);
if (bitmap.Width / 16 != 0.0f || bitmap.Height / 16 != 0.0f)
{
Console.WriteLine($"ERROR: Texture {textureName} size is not a multiple of 16, aborting...");
return false;
}
mipTexLump.Width = (uint)bitmap.Width;
mipTexLump.Height = (uint)bitmap.Height;
// Quantize image (erode image to 256 colors)
Expand Down

0 comments on commit eba5e4b

Please sign in to comment.