diff --git a/OpenRA.Game/Sync.cs b/OpenRA.Game/Sync.cs index 9029849e16..285450fe61 100755 --- a/OpenRA.Game/Sync.cs +++ b/OpenRA.Game/Sync.cs @@ -14,6 +14,7 @@ using System.Linq; using System.Reflection; using System.Reflection.Emit; using OpenRA.FileFormats; +using OpenRA.Traits; namespace OpenRA { @@ -45,6 +46,7 @@ namespace OpenRA {typeof(TypeDictionary), ((Func)hash_tdict).Method}, {typeof(Actor), ((Func)hash_actor).Method}, {typeof(Player), ((Func)hash_player).Method}, + {typeof(Target), ((Func)hash_target).Method}, }; static void EmitSyncOpcodes(Type type, ILGenerator il) @@ -146,6 +148,25 @@ namespace OpenRA return 0; } + public static int hash_target(Target t) + { + switch (t.Type) + { + case TargetType.Actor: + return (int)(t.Actor.ActorID << 16) * 0x567; + + case TargetType.FrozenActor: + return (int)(t.FrozenActor.Actor.ActorID << 16) * 0x567; + + case TargetType.Terrain: + return hash(t.CenterPosition); + + default: + case TargetType.Invalid: + return 0; + } + } + public static int hash(T t) { return t.GetHashCode();