Rewrite our Equals implementations so they don't crash when comparing incompatible objects
This commit is contained in:
@@ -40,10 +40,8 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Pair<T, U>))
|
||||
return false;
|
||||
|
||||
return (Pair<T, U>)obj == this;
|
||||
var o = obj as Pair<T, U>?;
|
||||
return o != null && o == this;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
||||
@@ -73,11 +73,8 @@ namespace OpenRA
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
float2 o = (float2)obj;
|
||||
return o == this;
|
||||
var o = obj as float2?;
|
||||
return o != null && o == this;
|
||||
}
|
||||
|
||||
public static readonly float2 Zero = new float2(0, 0);
|
||||
|
||||
@@ -43,11 +43,8 @@ namespace OpenRA
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
int2 o = (int2)obj;
|
||||
return o == this;
|
||||
var o = obj as int2?;
|
||||
return o != null && o == this;
|
||||
}
|
||||
|
||||
public static readonly int2 Zero = new int2(0, 0);
|
||||
|
||||
Reference in New Issue
Block a user