Fixed a crash when opening Thing Filters form when non-UDMF map was loaded.

Fixed a possible crash when rendering thing arrows in classic modes caused by incorrect vertex buffer size calculation.
Reverted changes to texture\flat access when "mixtexturesflats" option is set to true in game configuration.
This commit is contained in:
MaxED 2013-12-03 10:50:33 +00:00
parent d9439850f7
commit bf2f520a8e
7 changed files with 60 additions and 57 deletions

View file

@ -42,7 +42,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Properties #region ================== Properties
public ICollection<ImageData> Textures { get { return textures; } } public ICollection<ImageData> Textures { get { return textures; } }
public ICollection<ImageData> Flats { get { if(General.Map.Config.MixTexturesFlats) return textures; return flats; } } //mxd public ICollection<ImageData> Flats { get { return flats; } }
#endregion #endregion

View file

@ -42,7 +42,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Properties #region ================== Properties
public ICollection<ImageData> Textures { get { return textures; } } public ICollection<ImageData> Textures { get { return textures; } }
public ICollection<ImageData> Flats { get { if(General.Map.Config.MixTexturesFlats) return textures; return flats; } } //mxd public ICollection<ImageData> Flats { get { return flats; } } //mxd
#endregion #endregion

View file

@ -41,7 +41,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Properties #region ================== Properties
public ICollection<ImageData> Textures { get { return textures.Values; } } public ICollection<ImageData> Textures { get { return textures.Values; } }
public ICollection<ImageData> Flats { get { return General.Map.Config.MixTexturesFlats ? textures.Values : flats.Values; } } public ICollection<ImageData> Flats { get { return flats.Values; } }
public DataLocation Location { get { return location; } } public DataLocation Location { get { return location; } }
#endregion #endregion
@ -86,24 +86,26 @@ namespace CodeImp.DoomBuilder.Config
// Check if this set has a flat // Check if this set has a flat
internal bool FlatExists(ImageData image) internal bool FlatExists(ImageData image)
{ {
if(General.Map.Config.MixTexturesFlats) return textures.ContainsKey(image.LongName); //mxd
return flats.ContainsKey(image.LongName); return flats.ContainsKey(image.LongName);
} }
// Mix the textures and flats // Mix the textures and flats
internal void MixTexturesAndFlats() internal void MixTexturesAndFlats()
{ {
Dictionary<long, ImageData> newflats = new Dictionary<long, ImageData>(); //mxd // Make a copy of the flats only
Dictionary<long, ImageData> flatsonly = new Dictionary<long, ImageData>(flats);
// Add flats to textures // Add textures to flats
foreach(KeyValuePair<long, ImageData> f in flats) { foreach(KeyValuePair<long, ImageData> t in textures)
if(!textures.ContainsKey(f.Key)) {
textures.Add(f.Key, f.Value); if(!flats.ContainsKey(t.Key)) flats.Add(t.Key, t.Value);
else
newflats.Add(f.Key, f.Value); //mxd
} }
flats = newflats; //mxd // Add flats to textures
foreach(KeyValuePair<long, ImageData> f in flatsonly)
{
if(!textures.ContainsKey(f.Key)) textures.Add(f.Key, f.Value);
}
} }
#endregion #endregion

View file

@ -113,9 +113,9 @@ namespace CodeImp.DoomBuilder.Data
public Playpal Palette { get { return palette; } } public Playpal Palette { get { return palette; } }
public PreviewManager Previews { get { return previews; } } public PreviewManager Previews { get { return previews; } }
public ICollection<ImageData> Textures { get { return textures.Values; } } public ICollection<ImageData> Textures { get { return textures.Values; } }
public ICollection<ImageData> Flats { get { return (General.Map.Config.MixTexturesFlats ? textures.Values : flats.Values); } } //mxd public ICollection<ImageData> Flats { get { return flats.Values; } }
public List<string> TextureNames { get { return texturenames; } } public List<string> TextureNames { get { return texturenames; } }
public List<string> FlatNames { get { return (General.Map.Config.MixTexturesFlats ? texturenames : flatnames); } } //mxd public List<string> FlatNames { get { return flatnames; } }
public bool IsDisposed { get { return isdisposed; } } public bool IsDisposed { get { return isdisposed; } }
public ImageData MissingTexture3D { get { return missingtexture3d; } } public ImageData MissingTexture3D { get { return missingtexture3d; } }
public ImageData UnknownTexture3D { get { return unknowntexture3d; } } public ImageData UnknownTexture3D { get { return unknowntexture3d; } }
@ -342,29 +342,38 @@ namespace CodeImp.DoomBuilder.Data
} }
} }
// Mixed textures and flats? // Process flats
if (General.Map.Config.MixTexturesFlats) { foreach(KeyValuePair<long, ImageData> f in flatsonly)
// Add flats to textures {
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); flats.Add(f.Key, f.Value);
flatnames.Add(f.Value.Name); flatnames.Add(f.Value.Name);
} }
// Mixed textures and flats?
if (General.Map.Config.MixTexturesFlats) {
// Add textures to flats
foreach(KeyValuePair<long, ImageData> t in texturesonly)
{
if(!flats.ContainsKey(t.Key))
{
flats.Add(t.Key, t.Value);
flatnames.Add(t.Value.Name);
}
}
// Add flats to textures
foreach(KeyValuePair<long, ImageData> f in flatsonly)
{
if(!textures.ContainsKey(f.Key))
{
textures.Add(f.Key, f.Value);
texturenames.Add(f.Value.Name);
}
} }
// Do the same on the data readers // Do the same on the data readers
foreach (DataReader dr in containers) foreach (DataReader dr in containers)
dr.TextureSet.MixTexturesAndFlats(); 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 // Sort names
@ -975,13 +984,13 @@ namespace CodeImp.DoomBuilder.Data
public bool GetFlatExists(string name) public bool GetFlatExists(string name)
{ {
long longname = Lump.MakeLongName(name); long longname = Lump.MakeLongName(name);
return General.Map.Config.MixTexturesFlats ? flats.ContainsKey(longname) || textures.ContainsKey(longname) : flats.ContainsKey(longname); return flats.ContainsKey(longname);
} }
// This checks if a flat is known // This checks if a flat is known
public bool GetFlatExists(long longname) public bool GetFlatExists(long longname)
{ {
return General.Map.Config.MixTexturesFlats ? flats.ContainsKey(longname) || textures.ContainsKey(longname) : flats.ContainsKey(longname); return flats.ContainsKey(longname);
} }
// This returns an image by string // This returns an image by string
@ -998,10 +1007,6 @@ namespace CodeImp.DoomBuilder.Data
// Does this flat exist? // Does this flat exist?
if(flats.ContainsKey(longname)) return flats[longname]; 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 null image
return unknownImage; //mxd return unknownImage; //mxd
} }
@ -1009,14 +1014,8 @@ namespace CodeImp.DoomBuilder.Data
// This returns an image by long and doesn't check if it exists // This returns an image by long and doesn't check if it exists
public ImageData GetFlatImageKnown(long longname) 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 flat
return flats[longname]; //mxd return flats[longname];
} }
#endregion #endregion

View file

@ -261,12 +261,8 @@ namespace CodeImp.DoomBuilder.Data
private void LoadColormapsRange(string startlump, string endlump, ref List<ImageData> images) private void LoadColormapsRange(string startlump, string endlump, ref List<ImageData> images)
{ {
int startindex, endindex; int startindex, endindex;
float defaultscale;
ColormapImage image; ColormapImage image;
// Determine default scale
defaultscale = General.Map.Config.DefaultTextureScale;
// Continue until no more start can be found // Continue until no more start can be found
startindex = file.FindLumpIndex(startlump); startindex = file.FindLumpIndex(startlump);
while(startindex > -1) while(startindex > -1)
@ -331,7 +327,6 @@ namespace CodeImp.DoomBuilder.Data
public override ICollection<ImageData> LoadTextures(PatchNames pnames) public override ICollection<ImageData> LoadTextures(PatchNames pnames)
{ {
List<ImageData> images = new List<ImageData>(); List<ImageData> images = new List<ImageData>();
//string rangestart, rangeend;
int lumpindex; int lumpindex;
Lump lump; Lump lump;
@ -433,8 +428,7 @@ namespace CodeImp.DoomBuilder.Data
TextureImage image = null; TextureImage image = null;
bool strifedata; bool strifedata;
if(texturedata.Length == 0) if(texturedata.Length == 0) return;
return;
// Determine default scale // Determine default scale
defaultscale = General.Map.Config.DefaultTextureScale; defaultscale = General.Map.Config.DefaultTextureScale;

View file

@ -1232,7 +1232,7 @@ namespace CodeImp.DoomBuilder.Rendering
buffercount = 0; buffercount = 0;
// Determine next lock size // Determine next lock size
locksize = ((things.Count - totalcount) > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : (things.Count - totalcount); locksize = ((group.Value.Count - totalcount) > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : (group.Value.Count - totalcount);
} }
} }
@ -1255,6 +1255,10 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.Shaders.Things2D.Texture1 = thingtexture[thingtextureindex].Texture; graphics.Shaders.Things2D.Texture1 = thingtexture[thingtextureindex].Texture;
graphics.Shaders.Things2D.BeginPass(0); graphics.Shaders.Things2D.BeginPass(0);
// Determine next lock size
locksize = (thingsByPosition.Count > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : thingsByPosition.Count;
verts = new FlatVertex[THING_BUFFER_SIZE * 6];
// Go for all things // Go for all things
buffercount = 0; buffercount = 0;
totalcount = 0; totalcount = 0;
@ -1279,7 +1283,7 @@ namespace CodeImp.DoomBuilder.Rendering
buffercount = 0; buffercount = 0;
// Determine next lock size // Determine next lock size
locksize = ((things.Count - totalcount) > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : (things.Count - totalcount); locksize = ((thingsByPosition.Count - totalcount) > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : (thingsByPosition.Count - totalcount);
} }
} }

View file

@ -62,8 +62,10 @@ namespace CodeImp.DoomBuilder.Windows
filteraction.AddInfo(General.Map.Config.SortedLinedefActions.ToArray()); filteraction.AddInfo(General.Map.Config.SortedLinedefActions.ToArray());
// Initialize custom fields editor // Initialize custom fields editor
if (General.Map.FormatInterface.HasCustomFields) { //mxd
fieldslist.ListNoFixedFields(); fieldslist.ListNoFixedFields();
fieldslist.Setup("thing"); fieldslist.Setup("thing");
}
// Fill checkboxes list // Fill checkboxes list
foreach(KeyValuePair<string, string> flag in General.Map.Config.ThingFlags) foreach(KeyValuePair<string, string> flag in General.Map.Config.ThingFlags)
@ -239,9 +241,11 @@ namespace CodeImp.DoomBuilder.Windows
} }
// Custom fields // Custom fields
if (General.Map.FormatInterface.HasCustomFields) { //mxd
fieldslist.ClearFields(); fieldslist.ClearFields();
fieldslist.Setup("thing"); fieldslist.Setup("thing");
fieldslist.SetValues(f.ThingCustomFields, true); fieldslist.SetValues(f.ThingCustomFields, true);
}
// Done // Done
settingup = false; settingup = false;