From eed066687935970e9ad2c628f74a5a50a2835123 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sat, 18 May 2019 18:22:24 +0300 Subject: [PATCH] (76909c3c7) Fixed "clowncostume" and "crewaway" achievements not unlocking in multiplayer, fixed being able to get the "killclown" achievement by committing suicide while wearing a clown costume. Closes #1478 + merge fix --- .../Source/Networking/GameClient.cs | 2 +- .../Source/Screens/ServerListScreen.cs | 2 - .../Source/Characters/AI/HumanAIController.cs | 17 ------- .../Characters/AI/IndoorsSteeringManager.cs | 1 - .../BarotraumaShared/Source/GameSettings.cs | 1 - .../Source/SteamAchievementManager.cs | 46 +++++++++++++------ 6 files changed, 33 insertions(+), 36 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 9215d7d70..205820841 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -903,7 +903,7 @@ namespace Barotrauma.Networking connected = false; ConnectToServer(serverIP); } - if (clientID == myID) + else { string msg = ""; if (disconnectReason == DisconnectReason.Unknown) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs index 0344ba7c1..163e3f9ae 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs @@ -198,8 +198,6 @@ namespace Barotrauma UserData = "noresults" }; } - - return true; } private bool RefreshJoinButtonState(GUIComponent component, object obj) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index c68f451cb..cf27e30b6 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -82,23 +82,6 @@ namespace Barotrauma public override void Update(float deltaTime) { if (DisableCrewAI || Character.IsUnconscious) return; - - if (Character.Submarine != null || SelectedAiTarget?.Entity?.Submarine != null) - { - if (steeringManager != insideSteering) - { - insideSteering.Reset(); - } - steeringManager = insideSteering; - } - else - { - if (steeringManager != outsideSteering) - { - outsideSteering.Reset(); - } - steeringManager = outsideSteering; - } float maxDistanceToSub = 3000; if (Character.Submarine != null || SelectedAiTarget?.Entity?.Submarine != null && diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs index 40ebc5006..606696212 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using System; using System.Linq; -using Barotrauma.Extensions; namespace Barotrauma { diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index cb34e2230..3227f1413 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -1003,7 +1003,6 @@ namespace Barotrauma new XAttribute("autocheckupdates", AutoCheckUpdates), new XAttribute("musicvolume", musicVolume), new XAttribute("soundvolume", soundVolume), - new XAttribute("voicechatvolume", voiceChatVolume), new XAttribute("verboselogging", VerboseLogging), new XAttribute("savedebugconsolelogs", SaveDebugConsoleLogs), new XAttribute("enablesplashscreen", EnableSplashScreen), diff --git a/Barotrauma/BarotraumaShared/Source/SteamAchievementManager.cs b/Barotrauma/BarotraumaShared/Source/SteamAchievementManager.cs index 9dfe58a9e..cd5989c75 100644 --- a/Barotrauma/BarotraumaShared/Source/SteamAchievementManager.cs +++ b/Barotrauma/BarotraumaShared/Source/SteamAchievementManager.cs @@ -119,23 +119,40 @@ namespace Barotrauma } } - if (GameMain.GameSession != null && Character.Controlled != null) + if (GameMain.GameSession != null) { - if (Character.Controlled.HasEquippedItem("clownmask") && - Character.Controlled.HasEquippedItem("clowncostume")) +#if CLIENT + if (Character.Controlled != null) { CheckMidRoundAchievements(Character.Controlled); } +#else + foreach (Client client in GameMain.Server.ConnectedClients) { - UnlockAchievement(Character.Controlled, "clowncostume"); - } - - if (Submarine.MainSub != null && Character.Controlled.Submarine == null) - { - float dist = 500 / Physics.DisplayToRealWorldRatio; - if (Vector2.DistanceSquared(Character.Controlled.WorldPosition, Submarine.MainSub.WorldPosition) > - dist * dist) + if (client.Character != null) { - UnlockAchievement(Character.Controlled, "crewaway"); + CheckMidRoundAchievements(client.Character); } - } + } +#endif + } + } + + private static void CheckMidRoundAchievements(Character c) + { + if (c == null || c.Removed) { return; } + + if (c.HasEquippedItem("clownmask") && + c.HasEquippedItem("clowncostume")) + { + UnlockAchievement(c, "clowncostume"); + } + + if (Submarine.MainSub != null && c.Submarine == null) + { + float dist = 500 / Physics.DisplayToRealWorldRatio; + if (Vector2.DistanceSquared(c.WorldPosition, Submarine.MainSub.WorldPosition) > + dist * dist) + { + UnlockAchievement(c, "crewaway"); + } } } @@ -214,7 +231,8 @@ namespace Barotrauma } if (character.HasEquippedItem("clownmask") && - character.HasEquippedItem("clowncostume")) + character.HasEquippedItem("clowncostume") && + causeOfDeath.Killer != character) { UnlockAchievement(causeOfDeath.Killer, "killclown"); }