From 917b869b92b3075a0b6f66559e02296f45f285e0 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sun, 10 Jun 2018 21:30:41 +0300 Subject: [PATCH] Fixed exceptions in RespawnManager if the selected respawn shuttle doesn't have a nav terminal or any other item with a Steering component. Closes #438 --- .../Source/Networking/RespawnManager.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs b/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs index 913795949..f32d873ce 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs @@ -204,8 +204,11 @@ namespace Barotrauma.Networking respawnShuttle.Velocity = Vector2.Zero; - shuttleSteering.AutoPilot = false; - shuttleSteering.MaintainPos = false; + if (shuttleSteering != null) + { + shuttleSteering.AutoPilot = false; + shuttleSteering.MaintainPos = false; + } } private void UpdateTransporting(float deltaTime) @@ -264,7 +267,10 @@ namespace Barotrauma.Networking respawnShuttle.PhysicsBody.FarseerBody.IgnoreCollisionWith(Level.Loaded.TopBarrier); - shuttleSteering.SetDestinationLevelStart(); + if (shuttleSteering != null) + { + shuttleSteering.SetDestinationLevelStart(); + } foreach (Door door in shuttleDoors) { @@ -284,7 +290,7 @@ namespace Barotrauma.Networking if (!CoroutineManager.IsCoroutineRunning("forcepos")) { - if (shuttleSteering.SteeringPath != null && shuttleSteering.SteeringPath.Finished + if ((shuttleSteering?.SteeringPath != null && shuttleSteering.SteeringPath.Finished) || (respawnShuttle.WorldPosition.Y + respawnShuttle.Borders.Y > Level.Loaded.StartPosition.Y - Level.ShaftHeight && Math.Abs(Level.Loaded.StartPosition.X - respawnShuttle.WorldPosition.X) < 1000.0f)) { @@ -323,7 +329,10 @@ namespace Barotrauma.Networking ResetShuttle(); - shuttleSteering.TargetVelocity = Vector2.Zero; + if (shuttleSteering != null) + { + shuttleSteering.TargetVelocity = Vector2.Zero; + } GameServer.Log("Dispatching the respawn shuttle.", ServerLog.MessageType.Spawning);