This commit is contained in:
Paul Chote
2013-07-11 17:59:34 +12:00
parent 7b3c322b13
commit 60f49b39d4

View File

@@ -82,27 +82,27 @@ namespace OpenRA
} }
else if (type == typeof(WRange)) else if (type == typeof(WRange))
{ {
il.EmitCall(OpCodes.Call, ((Func<WRange, int>)(a => a.GetHashCode())).Method, null); il.EmitCall(OpCodes.Call, ((Func<WRange, int>)hash<WRange>).Method, null);
il.Emit(OpCodes.Xor); il.Emit(OpCodes.Xor);
} }
else if (type == typeof(WPos)) else if (type == typeof(WPos))
{ {
il.EmitCall(OpCodes.Call, ((Func<WPos, int>)(a => a.GetHashCode())).Method, null); il.EmitCall(OpCodes.Call, ((Func<WPos, int>)hash<WPos>).Method, null);
il.Emit(OpCodes.Xor); il.Emit(OpCodes.Xor);
} }
else if (type == typeof(WVec)) else if (type == typeof(WVec))
{ {
il.EmitCall(OpCodes.Call, ((Func<WVec, int>)(a => a.GetHashCode())).Method, null); il.EmitCall(OpCodes.Call, ((Func<WVec, int>)hash<WVec>).Method, null);
il.Emit(OpCodes.Xor); il.Emit(OpCodes.Xor);
} }
else if (type == typeof(WAngle)) else if (type == typeof(WAngle))
{ {
il.EmitCall(OpCodes.Call, ((Func<WAngle, int>)(a => a.GetHashCode())).Method, null); il.EmitCall(OpCodes.Call, ((Func<WAngle, int>)hash<WAngle>).Method, null);
il.Emit(OpCodes.Xor); il.Emit(OpCodes.Xor);
} }
else if (type == typeof(WRot)) else if (type == typeof(WRot))
{ {
il.EmitCall(OpCodes.Call, ((Func<WRot, int>)(a => a.GetHashCode())).Method, null); il.EmitCall(OpCodes.Call, ((Func<WRot, int>)hash<WRot>).Method, null);
il.Emit(OpCodes.Xor); il.Emit(OpCodes.Xor);
} }
else if (type == typeof(TypeDictionary)) else if (type == typeof(TypeDictionary))
@@ -217,6 +217,11 @@ namespace OpenRA
return 0; return 0;
} }
public static int hash<T>(T t)
{
return t.GetHashCode();
}
public static void CheckSyncUnchanged( World world, Action fn ) public static void CheckSyncUnchanged( World world, Action fn )
{ {
CheckSyncUnchanged( world, () => { fn(); return true; } ); CheckSyncUnchanged( world, () => { fn(); return true; } );