Fixed, "Select Similar" action: in some cases map elements flags were incorrectly compared resulting in map elements not being selected when they should have been.

This commit is contained in:
MaxED 2016-06-15 22:57:39 +00:00 committed by spherallic
parent e34fe0d32f
commit 98e5c5b9b4
5 changed files with 48 additions and 9 deletions

View File

@ -965,6 +965,15 @@ namespace CodeImp.DoomBuilder.Map
{
return new Dictionary<string, bool>(flags);
}
//mxd. This returns enabled flags
public HashSet<string> GetEnabledFlags()
{
HashSet<string> result = new HashSet<string>();
foreach(KeyValuePair<string, bool> group in flags)
if(group.Value) result.Add(group.Key);
return result;
}
// This clears all flags
public void ClearFlags()

View File

@ -516,6 +516,15 @@ namespace CodeImp.DoomBuilder.Map
return new Dictionary<string, bool>(flags);
}
//mxd. This returns enabled flags
public HashSet<string> GetEnabledFlags()
{
HashSet<string> result = new HashSet<string>();
foreach(KeyValuePair<string, bool> group in flags)
if(group.Value) result.Add(group.Key);
return result;
}
// This clears all flags
public void ClearFlags()
{

View File

@ -323,6 +323,15 @@ namespace CodeImp.DoomBuilder.Map
return new Dictionary<string, bool>(flags);
}
//mxd. This returns enabled flags
public HashSet<string> GetEnabledFlags()
{
HashSet<string> result = new HashSet<string>();
foreach(KeyValuePair<string, bool> group in flags)
if(group.Value) result.Add(group.Key);
return result;
}
// This clears all flags
public void ClearFlags()
{

View File

@ -649,8 +649,17 @@ namespace CodeImp.DoomBuilder.Map
if (General.Map.SRB2) pos.z = value >> 4;
}
// This clears all flags
public void ClearFlags()
//mxd. This returns enabled flags
public HashSet<string> GetEnabledFlags()
{
HashSet<string> result = new HashSet<string>();
foreach(KeyValuePair<string, bool> group in flags)
if(group.Value) result.Add(group.Key);
return result;
}
// This clears all flags
public void ClearFlags()
{
BeforePropsChange();

View File

@ -804,7 +804,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(flags.CeilingTexture && source.CeilTexture != target.CeilTexture) return false;
if(flags.Brightness && source.Brightness != target.Brightness) return false;
if(flags.Tag && !TagsMatch(source.Tags, target.Tags)) return false;
if(flags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
if(flags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags())) return false;
// Generalized effects require more tender loving care...
if(flags.Special && source.Effect != target.Effect)
@ -871,7 +871,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(!UniFields.ValuesMatch("arg4str", source, target)) return false;
}
}
if(linedefflags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
if(linedefflags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags())) return false;
if(General.Map.UDMF)
{
@ -907,7 +907,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(!General.Map.UDMF) return true;
// UDMF-specific properties
if(flags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
if(flags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags())) return false;
// UI fields
if(flags.UpperTextureScale && !UniFields.ValuesMatch("scalex_top", "scaley_top", source, target)) return false;
@ -949,7 +949,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
if(flags.Tag && source.Tag != target.Tag) return false;
if(flags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
if(flags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags())) return false;
if(!General.Map.UDMF) return true;
// UDMF-specific properties
@ -973,11 +973,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion
private static bool FlagsMatch(Dictionary<string, bool> flags1, Dictionary<string, bool> flags2)
private static bool FlagsMatch(HashSet<string> flags1, HashSet<string> flags2)
{
if(flags1.Count != flags2.Count) return false;
foreach(KeyValuePair<string, bool> group in flags1)
if(!flags2.ContainsKey(group.Key) || flags2[group.Key] != flags1[group.Key]) return false;
foreach(string flag in flags1)
{
if(!flags2.Contains(flag)) return false;
}
return true;
}