Fixed, Find & Replace mode: fixed a bug when "Find Sector Effect" search mode returned all map sectors when the effect to find was not generalized.

Updated ZDoom_DECORATE.cfg.
This commit is contained in:
MaxED 2016-06-22 13:38:27 +00:00 committed by spherallic
parent 97dcfb0275
commit 83c63bc5c7
2 changed files with 30 additions and 41 deletions

View file

@ -1120,15 +1120,19 @@ namespace CodeImp.DoomBuilder.Config
if(effect > 0)
{
int cureffect = effect;
for(int i = options.Count - 1; i > -1; i--)
if(General.Map.Config.GeneralizedEffects)
{
for(int j = options[i].Bits.Count - 1; j > -1; j--)
for(int i = options.Count - 1; i > -1; i--)
{
GeneralizedBit bit = options[i].Bits[j];
if(bit.Index > 0 && (cureffect & bit.Index) == bit.Index)
for(int j = options[i].Bits.Count - 1; j > -1; j--)
{
cureffect -= bit.Index;
result.GeneralizedBits.Add(bit.Index);
GeneralizedBit bit = options[i].Bits[j];
if(bit.Index > 0 && (cureffect & bit.Index) == bit.Index)
{
cureffect -= bit.Index;
result.GeneralizedBits.Add(bit.Index);
}
}
}
}

View file

@ -93,16 +93,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(int.TryParse(value, out effect))
{
//mxd
List<int> expectedbits = GetGeneralizedBits(effect);
SectorEffectData sd = General.Map.Config.GetSectorEffectData(effect);
// Where to search?
ICollection<Sector> list = withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors;
ICollection<Sector> list = (withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors);
// Go for all sectors
foreach(Sector s in list)
{
// Effect matches? -1 means any effect (mxd)
if((effect == -1 && s.Effect > 0) || (effect > -1 && (s.Effect == effect || BitsMatch(s.Effect, expectedbits))))
bool match = false;
//mxd. Effect matches? -1 means any effect
if(effect == -1)
{
match = s.Effect > 0;
}
else if(effect == s.Effect)
{
match = true;
}
else if(General.Map.Config.GeneralizedEffects && effect != 0 && s.Effect != 0)
{
SectorEffectData sdo = General.Map.Config.GetSectorEffectData(s.Effect);
match = (sd.Effect == sdo.Effect || (sd.GeneralizedBits.Count == sdo.GeneralizedBits.Count && sd.GeneralizedBits.Overlaps(sdo.GeneralizedBits)));
}
if(match)
{
// Replace
if(replace) s.Effect = replaceeffect;
@ -119,37 +135,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
return objs.ToArray();
}
//mxd
private static List<int> GetGeneralizedBits(int effect)
{
if(!General.Map.Config.GeneralizedEffects) return new List<int>();
List<int> bits = new List<int>();
foreach(GeneralizedOption option in General.Map.Config.GenEffectOptions)
{
foreach(GeneralizedBit bit in option.Bits)
{
if(bit.Index > 0 && (effect & bit.Index) == bit.Index)
bits.Add(bit.Index);
}
}
return bits;
}
//mxd
private static bool BitsMatch(int effect, IEnumerable<int> expectedbits)
{
if(!General.Map.Config.GeneralizedEffects) return false;
foreach(int bit in expectedbits)
{
if((effect & bit) != bit) return false;
}
return true;
}
#endregion
}
}