diff --git a/OpenRA.FileFormats/Primitives/Pair.cs b/OpenRA.FileFormats/Primitives/Pair.cs index 1f3ac031dc..60f67df522 100644 --- a/OpenRA.FileFormats/Primitives/Pair.cs +++ b/OpenRA.FileFormats/Primitives/Pair.cs @@ -8,7 +8,9 @@ */ #endregion -using System.Collections.Generic; +using System.Collections.Generic; +using System; +using System.Drawing; namespace OpenRA.FileFormats { @@ -23,8 +25,8 @@ namespace OpenRA.FileFormats Second = second; } - static IEqualityComparer tc = EqualityComparer.Default; - static IEqualityComparer uc = EqualityComparer.Default; + internal static IEqualityComparer tc = EqualityComparer.Default; + internal static IEqualityComparer uc = EqualityComparer.Default; public static bool operator ==(Pair a, Pair b) { @@ -55,8 +57,6 @@ namespace OpenRA.FileFormats public static T AsFirst(Pair p) { return p.First; } public static U AsSecond(Pair p) { return p.Second; } - public Pair Swap() { return Pair.New(Second, First); } - public override string ToString() { return "({0},{1})".F(First, Second); @@ -64,7 +64,19 @@ namespace OpenRA.FileFormats } public static class Pair - { - public static Pair New(T t, U u) { return new Pair(t, u); } + { + public static Pair New(T t, U u) { return new Pair(t, u); } + + static Pair() + { + Pair.uc = new ColorEqualityComparer(); + } + + // avoid the default crappy one + class ColorEqualityComparer : IEqualityComparer + { + public bool Equals(Color x, Color y) { return x.ToArgb() == y.ToArgb(); } + public int GetHashCode(Color obj) { return obj.GetHashCode(); } + } } }