From 10da128475a0acfc2c67098d6e3522f239f15b0f Mon Sep 17 00:00:00 2001 From: MaxED Date: Sun, 12 Oct 2014 21:59:16 +0000 Subject: [PATCH] Changed: both DoomTexture and DoomFlat formats should be checked when determining an image format if "Mix textures and flats" flag is set. Changed: "imgz" images are now skipped while loading textures. --- Source/Core/Data/ImageDataFormat.cs | 16 ++++++++++++++++ Source/Core/Data/PK3StructuredReader.cs | 3 +++ Source/Core/IO/DoomColormapReader.cs | 4 +--- Source/Core/IO/DoomFlatReader.cs | 4 +--- Source/Core/IO/DoomPictureReader.cs | 4 +--- Source/Core/IO/FileImageReader.cs | 13 +++++++------ Source/Core/IO/IImageReader.cs | 3 --- Source/Core/IO/UnknownImageReader.cs | 3 --- 8 files changed, 29 insertions(+), 21 deletions(-) diff --git a/Source/Core/Data/ImageDataFormat.cs b/Source/Core/Data/ImageDataFormat.cs index 25bf3780..2e2e3337 100644 --- a/Source/Core/Data/ImageDataFormat.cs +++ b/Source/Core/Data/ImageDataFormat.cs @@ -88,6 +88,14 @@ namespace CodeImp.DoomBuilder.Data data.Seek(0, SeekOrigin.Begin); DoomPictureReader picreader = new DoomPictureReader(palette); if(picreader.Validate(data)) return picreader; + + // Also check if data is valid for a doom flat... (mxd) + if (General.Map.Config.MixTexturesFlats) + { + data.Seek(0, SeekOrigin.Begin); + DoomFlatReader flatpicreader = new DoomFlatReader(palette); + if(flatpicreader.Validate(data)) return flatpicreader; + } break; case DOOMFLAT: @@ -95,6 +103,14 @@ namespace CodeImp.DoomBuilder.Data data.Seek(0, SeekOrigin.Begin); DoomFlatReader flatreader = new DoomFlatReader(palette); if(flatreader.Validate(data)) return flatreader; + + // Also check if data is valid for a doom picture... (mxd) + if (General.Map.Config.MixTexturesFlats) + { + data.Seek(0, SeekOrigin.Begin); + DoomPictureReader picflatreader = new DoomPictureReader(palette); + if(picflatreader.Validate(data)) return picflatreader; + } break; case DOOMCOLORMAP: diff --git a/Source/Core/Data/PK3StructuredReader.cs b/Source/Core/Data/PK3StructuredReader.cs index 5398924c..45e68d1d 100644 --- a/Source/Core/Data/PK3StructuredReader.cs +++ b/Source/Core/Data/PK3StructuredReader.cs @@ -630,6 +630,9 @@ namespace CodeImp.DoomBuilder.Data string[] files = GetAllFiles(path, includesubdirs); foreach(string f in files) { + //mxd. Skip IMGZ files + if(Path.GetExtension(f).ToUpperInvariant() == ".IMGZ") continue; + // Make the texture name from filename without extension name = Path.GetFileNameWithoutExtension(f); diff --git a/Source/Core/IO/DoomColormapReader.cs b/Source/Core/IO/DoomColormapReader.cs index 727cc774..ee735750 100644 --- a/Source/Core/IO/DoomColormapReader.cs +++ b/Source/Core/IO/DoomColormapReader.cs @@ -32,8 +32,7 @@ namespace CodeImp.DoomBuilder.IO #region ================== Variables // Palette to use - private Playpal palette; - public uint ImageType { get; private set; } //mxd + private readonly Playpal palette; #endregion @@ -44,7 +43,6 @@ namespace CodeImp.DoomBuilder.IO { // Initialize this.palette = palette; - ImageType = DevilImageType.IL_TYPE_UNKNOWN; //mxd // We have no destructor GC.SuppressFinalize(this); diff --git a/Source/Core/IO/DoomFlatReader.cs b/Source/Core/IO/DoomFlatReader.cs index fda81b06..41f8f8f7 100644 --- a/Source/Core/IO/DoomFlatReader.cs +++ b/Source/Core/IO/DoomFlatReader.cs @@ -32,8 +32,7 @@ namespace CodeImp.DoomBuilder.IO #region ================== Variables // Palette to use - private Playpal palette; - public uint ImageType { get; private set; } //mxd + private readonly Playpal palette; #endregion @@ -44,7 +43,6 @@ namespace CodeImp.DoomBuilder.IO { // Initialize this.palette = palette; - ImageType = DevilImageType.IL_TYPE_UNKNOWN;//mxd // We have no destructor GC.SuppressFinalize(this); diff --git a/Source/Core/IO/DoomPictureReader.cs b/Source/Core/IO/DoomPictureReader.cs index e50a7467..99df4c78 100644 --- a/Source/Core/IO/DoomPictureReader.cs +++ b/Source/Core/IO/DoomPictureReader.cs @@ -32,8 +32,7 @@ namespace CodeImp.DoomBuilder.IO #region ================== Variables // Palette to use - private Playpal palette; - public uint ImageType { get; private set; } //mxd + private readonly Playpal palette; #endregion @@ -44,7 +43,6 @@ namespace CodeImp.DoomBuilder.IO { // Initialize this.palette = palette; - ImageType = DevilImageType.IL_TYPE_UNKNOWN; //mxd // We have no destructor GC.SuppressFinalize(this); diff --git a/Source/Core/IO/FileImageReader.cs b/Source/Core/IO/FileImageReader.cs index 5f458d4d..87e32f06 100644 --- a/Source/Core/IO/FileImageReader.cs +++ b/Source/Core/IO/FileImageReader.cs @@ -342,7 +342,7 @@ namespace CodeImp.DoomBuilder.IO private const int IL_IMAGE_CHANNELS = 0x0DFF;*/ //mxd - public uint ImageType { get; private set; } + private readonly uint imagetype; #endregion @@ -351,15 +351,16 @@ namespace CodeImp.DoomBuilder.IO // Constructor public FileImageReader() { - ImageType = DevilImageType.IL_TYPE_UNKNOWN;//mxd + imagetype = DevilImageType.IL_TYPE_UNKNOWN;//mxd // We have no destructor GC.SuppressFinalize(this); } //mxd - public FileImageReader(uint devilImageType) { - ImageType = devilImageType;//mxd + public FileImageReader(uint devilImagetype) + { + imagetype = devilImagetype;//mxd // We have no destructor GC.SuppressFinalize(this); @@ -394,7 +395,7 @@ namespace CodeImp.DoomBuilder.IO stream.Read(bytes, 0, bytes.Length); fixed(byte* bptr = bytes) { - if (!ilLoadL(ImageType, new IntPtr(bptr), (uint)bytes.Length)) + if (!ilLoadL(imagetype, new IntPtr(bptr), (uint)bytes.Length)) throw new BadImageFormatException(); } @@ -417,7 +418,7 @@ namespace CodeImp.DoomBuilder.IO ilDeleteImages(1, new IntPtr(&imageid)); //mxd. TGA fix - if (ImageType == DevilImageType.IL_TGA) + if (imagetype == DevilImageType.IL_TGA) bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); return bmp; diff --git a/Source/Core/IO/IImageReader.cs b/Source/Core/IO/IImageReader.cs index 64ff94fa..168b8e54 100644 --- a/Source/Core/IO/IImageReader.cs +++ b/Source/Core/IO/IImageReader.cs @@ -26,9 +26,6 @@ namespace CodeImp.DoomBuilder.IO { internal unsafe interface IImageReader { - //mxd. Variables - uint ImageType { get; } //holds Devil library Image type - // Methods Bitmap ReadAsBitmap(Stream stream); Bitmap ReadAsBitmap(Stream stream, out int offsetx, out int offsety); diff --git a/Source/Core/IO/UnknownImageReader.cs b/Source/Core/IO/UnknownImageReader.cs index d979891b..47b1094c 100644 --- a/Source/Core/IO/UnknownImageReader.cs +++ b/Source/Core/IO/UnknownImageReader.cs @@ -28,14 +28,11 @@ namespace CodeImp.DoomBuilder.IO { internal class UnknownImageReader : IImageReader { - public uint ImageType { get; private set; } //mxd - #region ================== Constructor / Disposer // Constructor public UnknownImageReader() { - ImageType = DevilImageType.IL_TYPE_UNKNOWN;//mxd // We have no destructor GC.SuppressFinalize(this); }