From e431cc775f7563f4ef6ac741702fcf6f9c7c40f9 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 4 Jul 2017 22:32:14 +0300 Subject: [PATCH] Some null checks, clients log initial lobby update, minor lighting optimization --- .../Source/Characters/AI/EnemyAIController.cs | 9 +-------- .../BarotraumaClient/Source/Map/Lights/LightSource.cs | 2 +- .../BarotraumaClient/Source/Networking/GameClient.cs | 6 +++++- .../Source/Characters/AI/EnemyAIController.cs | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs index 451477959..9d9e6ce33 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs @@ -19,7 +19,7 @@ namespace Barotrauma Vector2 pos = Character.WorldPosition; pos.Y = -pos.Y; - if (selectedAiTarget != null) + if (selectedAiTarget?.Entity != null) { GUI.DrawLine(spriteBatch, pos, new Vector2(selectedAiTarget.WorldPosition.X, -selectedAiTarget.WorldPosition.Y), Color.Red); @@ -31,13 +31,6 @@ namespace Barotrauma GUI.Font.DrawString(spriteBatch, targetValue.ToString(), pos - Vector2.UnitY * 20.0f, Color.Red); } - if (selectedAiTarget != null) - { - GUI.DrawLine(spriteBatch, - new Vector2(Character.DrawPosition.X, -Character.DrawPosition.Y), - new Vector2(selectedAiTarget.WorldPosition.X, -selectedAiTarget.WorldPosition.Y), Color.Red); - } - GUI.Font.DrawString(spriteBatch, targetValue.ToString(), pos - Vector2.UnitY * 80.0f, Color.Red); GUI.Font.DrawString(spriteBatch, "updatetargets: " + updateTargetsTimer, pos - Vector2.UnitY * 100.0f, Color.Red); diff --git a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs index e8bae993e..34e7c80c2 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs @@ -413,7 +413,7 @@ namespace Barotrauma.Lights if (intersection != null) { - float dist = Vector2.Distance((Vector2)intersection, rayStart); + float dist = Vector2.DistanceSquared((Vector2)intersection, rayStart); if (closestIntersection == null || dist < closestDist) { closestDist = dist; diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 703e945ad..9a1e69919 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -818,7 +818,11 @@ namespace Barotrauma.Networking if (inc.ReadBoolean()) { - ReadInitialUpdate(inc, !NetIdUtils.IdMoreRecent(updateID,GameMain.NetLobbyScreen.LastUpdateID)); + if (GameSettings.VerboseLogging) + { + DebugConsole.NewMessage("Received initial lobby update, ID: " + updateID + ", last ID: " + GameMain.NetLobbyScreen.LastUpdateID, Color.Gray); + } + ReadInitialUpdate(inc, !NetIdUtils.IdMoreRecent(updateID, GameMain.NetLobbyScreen.LastUpdateID)); } string selectSubName = inc.ReadString(); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs index 6133f4429..85fa6b0e1 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -213,7 +213,7 @@ namespace Barotrauma return; } - if (attachToWalls && Character.Submarine == null) + if (attachToWalls && Character.Submarine == null && Level.Loaded != null) { raycastTimer -= deltaTime; //check if there are any walls nearby the character could attach to