diff --git a/OpenRA.Game/Primitives/LongBitSet.cs b/OpenRA.Game/Primitives/LongBitSet.cs index 74f48dd38a..a8ef80ab76 100644 --- a/OpenRA.Game/Primitives/LongBitSet.cs +++ b/OpenRA.Game/Primitives/LongBitSet.cs @@ -18,6 +18,7 @@ namespace OpenRA.Primitives static class LongBitSetAllocator where T : class { static readonly Cache Bits = new Cache(Allocate); + static long allBits = 1; static long nextBits = 1; static long Allocate(string value) @@ -25,6 +26,7 @@ namespace OpenRA.Primitives lock (Bits) { var bits = nextBits; + allBits |= bits; nextBits <<= 1; if (nextBits == 0) @@ -85,6 +87,8 @@ namespace OpenRA.Primitives nextBits = 1; } } + + public static long Mask { get { return allBits; } } } // Opitmized BitSet to be used only when guaranteed to be no more than 64 values. @@ -114,6 +118,7 @@ namespace OpenRA.Primitives public static bool operator ==(LongBitSet me, LongBitSet other) { return me.bits == other.bits; } public static bool operator !=(LongBitSet me, LongBitSet other) { return !(me == other); } + public static LongBitSet operator ~(LongBitSet me) { return new LongBitSet(me.bits ^ LongBitSetAllocator.Mask); } public bool Equals(LongBitSet other) { return other == this; } public override bool Equals(object obj) { return obj is LongBitSet && Equals((LongBitSet)obj); } diff --git a/OpenRA.Mods.Cnc/Traits/Mine.cs b/OpenRA.Mods.Cnc/Traits/Mine.cs index 3fbeccc551..c8fa445cae 100644 --- a/OpenRA.Mods.Cnc/Traits/Mine.cs +++ b/OpenRA.Mods.Cnc/Traits/Mine.cs @@ -65,7 +65,7 @@ namespace OpenRA.Mods.Cnc.Traits return self.World.NoPlayersMask; // Friendly units should move around! - return info.BlockFriendly ? self.Owner.EnemyPlayersMask : self.World.AllPlayersMask; + return info.BlockFriendly ? ~self.Owner.AlliedPlayersMask : self.World.AllPlayersMask; } } diff --git a/OpenRA.Mods.Common/Traits/Crushable.cs b/OpenRA.Mods.Common/Traits/Crushable.cs index 39b65ff530..267c4571c6 100644 --- a/OpenRA.Mods.Common/Traits/Crushable.cs +++ b/OpenRA.Mods.Common/Traits/Crushable.cs @@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits if (IsTraitDisabled || !self.IsAtGroundLevel() || !Info.CrushClasses.Overlaps(crushClasses)) return self.World.NoPlayersMask; - return Info.CrushedByFriendlies ? self.World.AllPlayersMask : self.Owner.EnemyPlayersMask; + return Info.CrushedByFriendlies ? self.World.AllPlayersMask : ~self.Owner.AlliedPlayersMask; } bool CrushableInner(BitSet crushClasses, Player crushOwner)