From 65a117b575068b4168ab0d3a369f0a87b51d3cc3 Mon Sep 17 00:00:00 2001 From: Jesse Fish Date: Tue, 5 Jul 2016 12:16:08 -0700 Subject: [PATCH] Change Vector2d GetStateHash to GetHashCode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vector2d’s GetStateHash function should be overriding object GetHashCode. This change fixes the issue and all references to Vector2d’s GetStateHash. --- Core/Game/Agents/AgentController.cs | 6 +++--- Core/Game/Agents/LSAgent.cs | 6 +++--- Core/Simulation/Math/Vector2d.cs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Core/Game/Agents/AgentController.cs b/Core/Game/Agents/AgentController.cs index 749db71f..d09a6e14 100644 --- a/Core/Game/Agents/AgentController.cs +++ b/Core/Game/Agents/AgentController.cs @@ -216,7 +216,7 @@ public static int GetStateHash() if (GlobalAgentActive [i]) { LSAgent agent = GlobalAgents [i]; - int n1 = agent.Body._position.GetStateHash() + agent.Body._rotation.GetStateHash(); + int n1 = agent.Body._position.GetHashCode() + agent.Body._rotation.GetHashCode(); switch (operationToggle) { case 0: @@ -236,8 +236,8 @@ public static int GetStateHash() } if (agent.Body.IsNotNull()) { - hash ^= agent.Body._position.GetStateHash(); - hash ^= agent.Body._position.GetStateHash(); + hash ^= agent.Body._position.GetHashCode(); + hash ^= agent.Body._position.GetHashCode(); } } } diff --git a/Core/Game/Agents/LSAgent.cs b/Core/Game/Agents/LSAgent.cs index 2e4f03fe..6b23e18e 100644 --- a/Core/Game/Agents/LSAgent.cs +++ b/Core/Game/Agents/LSAgent.cs @@ -423,9 +423,9 @@ public long GetStateHash () { long hash = 3; hash ^= this.GlobalID; hash ^= this.LocalID; - hash ^= this.Body._position.GetStateHash (); - hash ^= this.Body._rotation.GetStateHash (); - hash ^= this.Body.Velocity.GetStateHash (); + hash ^= this.Body._position.GetHashCode (); + hash ^= this.Body._rotation.GetHashCode (); + hash ^= this.Body.Velocity.GetHashCode (); return hash; } diff --git a/Core/Simulation/Math/Vector2d.cs b/Core/Simulation/Math/Vector2d.cs index 0c495539..30933453 100644 --- a/Core/Simulation/Math/Vector2d.cs +++ b/Core/Simulation/Math/Vector2d.cs @@ -452,7 +452,7 @@ public long GetLongHashCode() return x * 31 + y * 7; } - public int GetStateHash() + public override int GetHashCode() { return (int)(GetLongHashCode() % int.MaxValue); }