Fixed a crash introduced in r1972 when trying to add second patch with the same name to a texture.

"Texture 'XXX' is double defined in resource 'YYY'." warning is no longer displayed if a TEXTURE1/2 texture contains a patch with the same name as the texture.
This commit is contained in:
MaxED 2014-07-15 08:08:57 +00:00
parent f2ba13d509
commit c462eb7bfd
4 changed files with 11 additions and 11 deletions

View file

@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.Config
// Add a texture
internal void AddTexture(ImageData image)
{
if(textures.ContainsKey(image.LongName) && (!(image is HighResImage) || !(image as HighResImage).ContainsPatch(image.Name)) )
if(textures.ContainsKey(image.LongName) && !image.HasPatchWithSameName)
General.ErrorLogger.Add(ErrorType.Warning, "Texture \"" + image.Name + "\" is double defined in resource \"" + this.Location.location + "\".");
textures[image.LongName] = image;
}

View file

@ -32,7 +32,7 @@ namespace CodeImp.DoomBuilder.Data
{
#region ================== Variables
private Dictionary<string, TexturePatch> patches; //mxd
private List<TexturePatch> patches; //mxd
private bool gotFullName;//mxd
private string type;
@ -49,7 +49,7 @@ namespace CodeImp.DoomBuilder.Data
this.scale.x = scalex;
this.scale.y = scaley;
this.worldpanning = worldpanning;
this.patches = new Dictionary<string, TexturePatch>(1);
this.patches = new List<TexturePatch>(1);
this.type = type;
SetName(name);
@ -65,13 +65,15 @@ namespace CodeImp.DoomBuilder.Data
public void AddPatch(TexturePatch patch)
{
// Add it
patches.Add(patch.lumpname, patch);
patches.Add(patch);
//mxd. Get full name from first patch
if (!gotFullName) {
fullName = General.Map.Data.GetPatchLocation(patch.lumpname);
gotFullName = true;
}
if (patch.lumpname == Name) hasPatchWithSameName = true; //mxd
}
// This loads the image
@ -111,7 +113,7 @@ namespace CodeImp.DoomBuilder.Data
if(!loadfailed)
{
// Go for all patches
foreach(TexturePatch p in patches.Values)
foreach(TexturePatch p in patches)
{
// Get the patch data stream
Stream patchdata;
@ -338,12 +340,6 @@ namespace CodeImp.DoomBuilder.Data
}
}
//mxd
public bool ContainsPatch(string name)
{
return patches.ContainsKey(name);
}
#endregion
}
}

View file

@ -51,6 +51,7 @@ namespace CodeImp.DoomBuilder.Data
protected bool usecolorcorrection;
protected string fullName; //mxd. name with path;
protected bool isFlat; //mxd. if false, it's a texture
protected bool hasPatchWithSameName; //mxd
// Loading
private volatile ImageLoadState previewstate;
@ -82,6 +83,7 @@ namespace CodeImp.DoomBuilder.Data
public long LongName { get { return longname; } }
public string FullName { get { return fullName; } } //mxd
public bool IsFlat { get { return isFlat; } internal set { isFlat = value; } } //mxd
public bool HasPatchWithSameName { get { return hasPatchWithSameName; } } //mxd
public bool UseColorCorrection { get { return usecolorcorrection; } set { usecolorcorrection = value; } }
public Texture Texture { get { lock(this) { return texture; } } }
public bool IsPreviewLoaded { get { return (previewstate == ImageLoadState.Ready); } }

View file

@ -62,6 +62,8 @@ namespace CodeImp.DoomBuilder.Data
{
// Add it
patches.Add(patch);
if(patch.lumpname == Name) hasPatchWithSameName = true; //mxd
}
// This loads the image