mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 12:50:52 +00:00
Error checks: PlaneAlign action is now taken into account when checking for missing upper/lower textures.
Several fixes in flat/texture/patch loading and precedence. Texture loading will no longer fail when there's a texture and a flat with the same name.
This commit is contained in:
parent
cd50592cd5
commit
d9439850f7
7 changed files with 151 additions and 114 deletions
|
@ -93,13 +93,17 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Mix the textures and flats
|
||||
internal void MixTexturesAndFlats()
|
||||
{
|
||||
Dictionary<long, ImageData> newflats = new Dictionary<long, ImageData>(); //mxd
|
||||
|
||||
// Add flats to textures
|
||||
foreach(KeyValuePair<long, ImageData> f in flats) {
|
||||
if(!textures.ContainsKey(f.Key))
|
||||
textures.Add(f.Key, f.Value);
|
||||
else
|
||||
newflats.Add(f.Key, f.Value); //mxd
|
||||
}
|
||||
|
||||
flats.Clear(); //mxd
|
||||
flats = newflats; //mxd
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -342,32 +342,29 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
}
|
||||
|
||||
// Process flats
|
||||
foreach(KeyValuePair<long, ImageData> f in flatsonly)
|
||||
{
|
||||
flats.Add(f.Key, f.Value);
|
||||
flatnames.Add(f.Value.Name);
|
||||
}
|
||||
|
||||
// Mixed textures and flats?
|
||||
if(General.Map.Config.MixTexturesFlats)
|
||||
{
|
||||
if (General.Map.Config.MixTexturesFlats) {
|
||||
// Add flats to textures
|
||||
foreach(KeyValuePair<long, ImageData> f in flatsonly)
|
||||
{
|
||||
if(!textures.ContainsKey(f.Key))
|
||||
{
|
||||
foreach (KeyValuePair<long, ImageData> f in flatsonly) {
|
||||
if (!textures.ContainsKey(f.Key)) {
|
||||
textures.Add(f.Key, f.Value);
|
||||
texturenames.Add(f.Value.Name);
|
||||
} else {
|
||||
//mxd. If there are flats with the same name as textures - add them to flats
|
||||
flats.Add(f.Key, f.Value);
|
||||
flatnames.Add(f.Value.Name);
|
||||
}
|
||||
}
|
||||
|
||||
flats.Clear(); //mxd
|
||||
flatnames.Clear(); //mxd
|
||||
|
||||
// Do the same on the data readers
|
||||
foreach(DataReader dr in containers)
|
||||
foreach (DataReader dr in containers)
|
||||
dr.TextureSet.MixTexturesAndFlats();
|
||||
} else {
|
||||
// Process flats
|
||||
foreach(KeyValuePair<long, ImageData> f in flatsonly) {
|
||||
flats.Add(f.Key, f.Value);
|
||||
flatnames.Add(f.Value.Name);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort names
|
||||
|
@ -704,11 +701,9 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// Set used on all flats
|
||||
if(!General.Map.Config.MixTexturesFlats) {
|
||||
foreach(KeyValuePair<long, ImageData> i in flats) {
|
||||
i.Value.SetUsedInMap(usedimages.ContainsKey(i.Key));
|
||||
if(i.Value.IsImageLoaded != i.Value.IsReferenced) ProcessImage(i.Value);
|
||||
}
|
||||
foreach(KeyValuePair<long, ImageData> i in flats) {
|
||||
i.Value.SetUsedInMap(usedimages.ContainsKey(i.Key));
|
||||
if(i.Value.IsImageLoaded != i.Value.IsReferenced) ProcessImage(i.Value);
|
||||
}
|
||||
|
||||
// Done
|
||||
|
@ -980,13 +975,13 @@ namespace CodeImp.DoomBuilder.Data
|
|||
public bool GetFlatExists(string name)
|
||||
{
|
||||
long longname = Lump.MakeLongName(name);
|
||||
return General.Map.Config.MixTexturesFlats ? textures.ContainsKey(longname) : flats.ContainsKey(longname);
|
||||
return General.Map.Config.MixTexturesFlats ? flats.ContainsKey(longname) || textures.ContainsKey(longname) : flats.ContainsKey(longname);
|
||||
}
|
||||
|
||||
// This checks if a flat is known
|
||||
public bool GetFlatExists(long longname)
|
||||
{
|
||||
return General.Map.Config.MixTexturesFlats ? textures.ContainsKey(longname) : flats.ContainsKey(longname);
|
||||
return General.Map.Config.MixTexturesFlats ? flats.ContainsKey(longname) || textures.ContainsKey(longname) : flats.ContainsKey(longname);
|
||||
}
|
||||
|
||||
// This returns an image by string
|
||||
|
@ -1000,16 +995,12 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This returns an image by long
|
||||
public ImageData GetFlatImage(long longname)
|
||||
{
|
||||
if(General.Map.Config.MixTexturesFlats) { //mxd
|
||||
// Does this flat exist?
|
||||
if(textures.ContainsKey(longname)) {
|
||||
// Return flat
|
||||
return textures[longname];
|
||||
}
|
||||
} else if(flats.ContainsKey(longname)) { // Does this flat exist?
|
||||
// Return flat
|
||||
return flats[longname];
|
||||
}
|
||||
// Does this flat exist?
|
||||
if(flats.ContainsKey(longname)) return flats[longname];
|
||||
|
||||
//mxd. Probably a texture will do?
|
||||
if(General.Map.Config.MixTexturesFlats && textures.ContainsKey(longname))
|
||||
return textures[longname];
|
||||
|
||||
// Return null image
|
||||
return unknownImage; //mxd
|
||||
|
@ -1018,8 +1009,14 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This returns an image by long and doesn't check if it exists
|
||||
public ImageData GetFlatImageKnown(long longname)
|
||||
{
|
||||
//mxd. Err... can't it do without checks...
|
||||
if(General.Map.Config.MixTexturesFlats) {
|
||||
if(flats.ContainsKey(longname)) return flats[longname];
|
||||
return textures[longname];
|
||||
}
|
||||
|
||||
// Return flat
|
||||
return General.Map.Config.MixTexturesFlats ? textures[longname] : flats[longname]; //mxd
|
||||
return flats[longname]; //mxd
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -126,12 +126,18 @@ namespace CodeImp.DoomBuilder.Data
|
|||
reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMPICTURE, General.Map.Data.Palette);
|
||||
if(reader is UnknownImageReader)
|
||||
{
|
||||
// Data is in an unknown format!
|
||||
General.ErrorLogger.Add(ErrorType.Error, "Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'");
|
||||
failCount++; //mxd
|
||||
//mxd. Probably that's a flat?..
|
||||
if (General.Map.Config.MixTexturesFlats) {
|
||||
reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMFLAT, General.Map.Data.Palette);
|
||||
}
|
||||
if (reader is UnknownImageReader) {
|
||||
// Data is in an unknown format!
|
||||
General.ErrorLogger.Add(ErrorType.Error, "Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'");
|
||||
failCount++; //mxd
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(!(reader is UnknownImageReader)) {
|
||||
// Get the patch
|
||||
mem.Seek(0, SeekOrigin.Begin);
|
||||
Bitmap patchbmp = null;
|
||||
|
|
|
@ -43,69 +43,66 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This check image data and returns the appropriate image reader
|
||||
public static IImageReader GetImageReader(Stream data, int guessformat, Playpal palette)
|
||||
{
|
||||
DoomPictureReader picreader;
|
||||
DoomFlatReader flatreader;
|
||||
DoomColormapReader colormapreader;
|
||||
|
||||
// First check the formats that provide the means to 'ensure' that
|
||||
// it actually is that format. Then guess the Doom image format.
|
||||
|
||||
// Data long enough to check for signatures?
|
||||
if(data.Length > 10)
|
||||
{
|
||||
// Check for PNG signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if(CheckSignature(data, PNG_SIGNATURE)) return new FileImageReader(DevilImageType.IL_PNG);
|
||||
|
||||
// Check for DDS signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if (CheckSignature(data, DDS_SIGNATURE)) return new FileImageReader(DevilImageType.IL_DDS);
|
||||
|
||||
// Check for GIF signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if (CheckSignature(data, GIF_SIGNATURE)) return new FileImageReader(DevilImageType.IL_GIF);
|
||||
|
||||
//mxd. Check for PCX signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if (CheckSignature(data, PCX_SIGNATURE)) return new FileImageReader(DevilImageType.IL_PCX);
|
||||
|
||||
//mxd. Check for JPG signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if (CheckSignature(data, JPG_SIGNATURE)) return new FileImageReader(DevilImageType.IL_JPG);
|
||||
|
||||
//mxd. Check for TGA signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if (CheckSignature(data, TGA_SIGNATURE)) return new FileImageReader(DevilImageType.IL_TGA);
|
||||
|
||||
// Check for BMP signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if (CheckSignature(data, BMP_SIGNATURE)) return new UnknownImageReader(); //mxd. Not supported in (G)ZDoom
|
||||
}
|
||||
|
||||
//mxd. Try to read it as "classic" image format first...
|
||||
// Could it be a doom picture?
|
||||
if(guessformat == DOOMPICTURE)
|
||||
{
|
||||
if(guessformat == DOOMPICTURE) {
|
||||
// Check if data is valid for a doom picture
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
picreader = new DoomPictureReader(palette);
|
||||
DoomPictureReader picreader = new DoomPictureReader(palette);
|
||||
if(picreader.Validate(data)) return picreader;
|
||||
}
|
||||
// Could it be a doom flat?
|
||||
else if(guessformat == DOOMFLAT)
|
||||
{
|
||||
else if(guessformat == DOOMFLAT) {
|
||||
// Check if data is valid for a doom flat
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
flatreader = new DoomFlatReader(palette);
|
||||
DoomFlatReader flatreader = new DoomFlatReader(palette);
|
||||
if(flatreader.Validate(data)) return flatreader;
|
||||
}
|
||||
// Could it be a doom colormap?
|
||||
else if(guessformat == DOOMCOLORMAP)
|
||||
{
|
||||
else if(guessformat == DOOMCOLORMAP) {
|
||||
// Check if data is valid for a doom colormap
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
colormapreader = new DoomColormapReader(palette);
|
||||
DoomColormapReader colormapreader = new DoomColormapReader(palette);
|
||||
if(colormapreader.Validate(data)) return colormapreader;
|
||||
}
|
||||
|
||||
// Data long enough to check for signatures?
|
||||
if(data.Length > 10) {
|
||||
// Check for PNG signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if(CheckSignature(data, PNG_SIGNATURE))
|
||||
return new FileImageReader(DevilImageType.IL_PNG);
|
||||
|
||||
// Check for DDS signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if(CheckSignature(data, DDS_SIGNATURE))
|
||||
return new FileImageReader(DevilImageType.IL_DDS);
|
||||
|
||||
// Check for GIF signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if(CheckSignature(data, GIF_SIGNATURE))
|
||||
return new FileImageReader(DevilImageType.IL_GIF);
|
||||
|
||||
//mxd. Check for PCX signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if(CheckSignature(data, PCX_SIGNATURE))
|
||||
return new FileImageReader(DevilImageType.IL_PCX);
|
||||
|
||||
//mxd. Check for JPG signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if(CheckSignature(data, JPG_SIGNATURE))
|
||||
return new FileImageReader(DevilImageType.IL_JPG);
|
||||
|
||||
//mxd. Check for TGA signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if(CheckSignature(data, TGA_SIGNATURE))
|
||||
return new FileImageReader(DevilImageType.IL_TGA);
|
||||
|
||||
// Check for BMP signature
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
if(CheckSignature(data, BMP_SIGNATURE))
|
||||
return new UnknownImageReader(); //mxd. Not supported in (G)ZDoom
|
||||
}
|
||||
|
||||
// Format not supported
|
||||
return new UnknownImageReader();
|
||||
|
|
|
@ -118,13 +118,19 @@ namespace CodeImp.DoomBuilder.Data
|
|||
reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMPICTURE, General.Map.Data.Palette);
|
||||
if(reader is UnknownImageReader)
|
||||
{
|
||||
// Data is in an unknown format!
|
||||
General.ErrorLogger.Add(ErrorType.Error, "Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'. Does this lump contain valid picture data at all?");
|
||||
loadfailed = true;
|
||||
failCount++; //mxd
|
||||
//mxd. Probably that's a flat?..
|
||||
if (General.Map.Config.MixTexturesFlats) {
|
||||
reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMFLAT, General.Map.Data.Palette);
|
||||
}
|
||||
if (reader is UnknownImageReader) {
|
||||
// Data is in an unknown format!
|
||||
General.ErrorLogger.Add(ErrorType.Error, "Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'. Does this lump contain valid picture data at all?");
|
||||
loadfailed = true;
|
||||
failCount++; //mxd
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(!(reader is UnknownImageReader)) {
|
||||
// Draw the patch
|
||||
mem.Seek(0, SeekOrigin.Begin);
|
||||
try { reader.DrawToPixelData(mem, pixels, width, height, p.x, p.y); }
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
// Lump ranges
|
||||
private List<LumpRange> flatranges;
|
||||
private List<LumpRange> invertedflatranges; //mxd
|
||||
private List<LumpRange> patchranges;
|
||||
private List<LumpRange> spriteranges;
|
||||
private List<LumpRange> textureranges;
|
||||
|
@ -93,6 +94,33 @@ namespace CodeImp.DoomBuilder.Data
|
|||
FindRanges(textureranges, General.Map.Config.TextureRanges, "textures");
|
||||
FindRanges(colormapranges, General.Map.Config.ColormapRanges, "colormaps");
|
||||
|
||||
//mxd
|
||||
invertedflatranges = new List<LumpRange>();
|
||||
|
||||
if(flatranges.Count > 0 && flatranges[0].start > 0) {
|
||||
LumpRange range = new LumpRange();
|
||||
range.start = 0;
|
||||
range.end = flatranges[0].start - 1;
|
||||
invertedflatranges.Add(range);
|
||||
}
|
||||
|
||||
for (int i = 0; i < flatranges.Count; i++) {
|
||||
if (flatranges[i].start == 0) continue;
|
||||
LumpRange range = new LumpRange();
|
||||
|
||||
if(i == flatranges.Count - 1) {
|
||||
if (flatranges[i].end < file.Lumps.Count - 1) {
|
||||
range.start = flatranges[i].end + 1;
|
||||
range.end = file.Lumps.Count - 1;
|
||||
invertedflatranges.Add(range);
|
||||
}
|
||||
} else {
|
||||
range.start = flatranges[i - 1].end + 1;
|
||||
range.end = flatranges[i].start - 1;
|
||||
invertedflatranges.Add(range);
|
||||
}
|
||||
}
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
@ -445,8 +473,8 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// Determine actual scales
|
||||
if(scalebytex == 0) scalex = defaultscale; else scalex = 1f / ((float)scalebytex / 8f);
|
||||
if(scalebytey == 0) scaley = defaultscale; else scaley = 1f / ((float)scalebytey / 8f);
|
||||
if(scalebytex == 0) scalex = defaultscale; else scalex = 1f / (scalebytex / 8f);
|
||||
if(scalebytey == 0) scaley = defaultscale; else scaley = 1f / (scalebytey / 8f);
|
||||
|
||||
// Validate data
|
||||
if((width > 0) && (height > 0) && (patches > 0) &&
|
||||
|
@ -532,22 +560,23 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Error when suspended
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
// Strictly read patches only between P_START and P_END?
|
||||
if(strictpatches)
|
||||
{
|
||||
// Find the lump in ranges
|
||||
foreach(LumpRange range in patchranges)
|
||||
{
|
||||
// mxd. First strictly read patches between P_START and P_END
|
||||
foreach(LumpRange range in patchranges) {
|
||||
lump = file.FindLump(pname, range.start, range.end);
|
||||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
|
||||
if (!strictpatches) {
|
||||
//mxd. Find the lump anywhere EXCEPT flat ranges (the way it's done in ZDoom)
|
||||
foreach (LumpRange range in invertedflatranges) {
|
||||
lump = file.FindLump(pname, range.start, range.end);
|
||||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the lump anywhere
|
||||
lump = file.FindLump(pname);
|
||||
if (lump != null) {
|
||||
return lump.Stream;
|
||||
|
||||
// Find the lump anywhere IN flat ranges
|
||||
foreach (LumpRange range in flatranges) {
|
||||
lump = file.FindLump(pname, range.start, range.end);
|
||||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -623,12 +652,8 @@ namespace CodeImp.DoomBuilder.Data
|
|||
private void LoadFlatsRange(string startlump, string endlump, ref List<ImageData> images)
|
||||
{
|
||||
int startindex, endindex;
|
||||
float defaultscale;
|
||||
FlatImage image;
|
||||
|
||||
// Determine default scale
|
||||
defaultscale = General.Map.Config.DefaultTextureScale;
|
||||
|
||||
// Continue until no more start can be found
|
||||
startindex = file.FindLumpIndex(startlump);
|
||||
while(startindex > -1)
|
||||
|
|
|
@ -59,6 +59,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// 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)
|
||||
{
|
||||
SubmitResult(new ResultMissingTexture(sd, SidedefPart.Upper));
|
||||
|
@ -76,6 +77,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// set to be sky
|
||||
if (sd.LowRequired() && 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)
|
||||
{
|
||||
SubmitResult(new ResultMissingTexture(sd, SidedefPart.Lower));
|
||||
|
|
Loading…
Reference in a new issue