From 7700854935b45822afc0e166f1507b711f01c3c7 Mon Sep 17 00:00:00 2001 From: Regalis Date: Wed, 5 Apr 2017 21:09:24 +0300 Subject: [PATCH] Disabled AI crew commands in multiplayer, attempting to give commands to a character with no AIController doesn't crash the game --- Subsurface/Source/Characters/AI/CrewCommander.cs | 2 +- Subsurface/Source/GameSession/CrewManager.cs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Subsurface/Source/Characters/AI/CrewCommander.cs b/Subsurface/Source/Characters/AI/CrewCommander.cs index 47870e5d3..9f712422c 100644 --- a/Subsurface/Source/Characters/AI/CrewCommander.cs +++ b/Subsurface/Source/Characters/AI/CrewCommander.cs @@ -148,7 +148,7 @@ namespace Barotrauma frame.RemoveChild(child); } - List aliveCharacters = crewManager.characters.FindAll(c => !c.IsDead); + List aliveCharacters = crewManager.characters.FindAll(c => !c.IsDead && c.AIController is HumanAIController); characterFrameBottom = 0; diff --git a/Subsurface/Source/GameSession/CrewManager.cs b/Subsurface/Source/GameSession/CrewManager.cs index 62245a1b3..d49908e18 100644 --- a/Subsurface/Source/GameSession/CrewManager.cs +++ b/Subsurface/Source/GameSession/CrewManager.cs @@ -138,6 +138,11 @@ namespace Barotrauma frame.SelectedColor = Color.Gold * 0.5f; var ai = character.AIController as HumanAIController; + if (ai == null) + { + DebugConsole.ThrowError("Error in crewmanager - attempted to give orders to a character with no HumanAIController"); + return; + } SetCharacterOrder(character, ai.CurrentOrder); } @@ -151,9 +156,10 @@ namespace Barotrauma public void Update(float deltaTime) { guiFrame.Update(deltaTime); - - - if (GameMain.Config.KeyBind(InputType.CrewOrders).IsHit()) + + //TODO: implement AI commands in multiplayer? + if (GameMain.NetworkMember != null && + GameMain.Config.KeyBind(InputType.CrewOrders).IsHit()) { //deselect construction unless it's the ladders the character is climbing if (!commander.IsOpen && Character.Controlled != null &&