diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 12396e460..9ca24580f 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -1973,7 +1973,8 @@ namespace Barotrauma.Networking msg.Write(true); msg.WritePadBits(); msg.Write(savePath); msg.Write(mapSeed); - msg.Write(sub.FilePath); + msg.Write(sub.Name); + msg.Write(sub.MD5Hash.Hash); client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered); diff --git a/Barotrauma/BarotraumaServer/Source/GameSession/GameModes/MultiPlayerCampaign.cs b/Barotrauma/BarotraumaServer/Source/GameSession/GameModes/MultiPlayerCampaign.cs index b94525388..14667cf7f 100644 --- a/Barotrauma/BarotraumaServer/Source/GameSession/GameModes/MultiPlayerCampaign.cs +++ b/Barotrauma/BarotraumaServer/Source/GameSession/GameModes/MultiPlayerCampaign.cs @@ -11,11 +11,11 @@ namespace Barotrauma { private List characterData = new List(); - public static void StartNewCampaign(string savePath, string subName, string seed) + public static void StartNewCampaign(string savePath, string subPath, string seed) { if (string.IsNullOrWhiteSpace(savePath)) return; - GameMain.GameSession = new GameSession(new Submarine(subName, ""), savePath, + GameMain.GameSession = new GameSession(new Submarine(subPath, ""), savePath, GameModePreset.List.Find(g => g.Identifier == "multiplayercampaign")); var campaign = ((MultiPlayerCampaign)GameMain.GameSession.GameMode); campaign.GenerateMap(seed); diff --git a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs index 88c5a0712..f51fd45f1 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs @@ -715,23 +715,25 @@ namespace Barotrauma.Networking { string savePath = inc.ReadString(); string seed = inc.ReadString(); - string subPath = inc.ReadString(); + string subName = inc.ReadString(); + string subHash = inc.ReadString(); - if (!File.Exists(subPath)) + var matchingSub = Submarine.SavedSubmarines.FirstOrDefault(s => s.Name == subName && s.MD5Hash.Hash == subHash); + + if (matchingSub == null) { SendDirectChatMessage( - TextManager.Get("CampaignStartFailedSubNotFound").Replace("[subpath]", subPath), + TextManager.Get("CampaignStartFailedSubNotFound").Replace("[subname]", subName), connectedClient, ChatMessageType.MessageBox); } else { - if (connectedClient.HasPermission(ClientPermissions.SelectMode)) MultiPlayerCampaign.StartNewCampaign(savePath, subPath, seed); + if (connectedClient.HasPermission(ClientPermissions.SelectMode)) MultiPlayerCampaign.StartNewCampaign(savePath, matchingSub.FilePath, seed); } } else { string saveName = inc.ReadString(); - if (connectedClient.HasPermission(ClientPermissions.SelectMode)) MultiPlayerCampaign.LoadCampaign(saveName); } break; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index f1d72e0b4..74062db2e 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -1666,10 +1666,12 @@ namespace Barotrauma focusedItem = null; } findFocusedTimer -= deltaTime; - } + } #endif //climb ladders automatically when pressing up/down inside their trigger area - if (SelectedConstruction == null && !AnimController.InWater && Screen.Selected != GameMain.SubEditorScreen) + Ladder currentLadder = SelectedConstruction?.GetComponent(); + if ((SelectedConstruction == null || currentLadder != null) && + !AnimController.InWater && Screen.Selected != GameMain.SubEditorScreen) { bool climbInput = IsKeyDown(InputType.Up) || IsKeyDown(InputType.Down); bool isControlled = Controlled == this; @@ -1680,6 +1682,19 @@ namespace Barotrauma float minDist = float.PositiveInfinity; foreach (Ladder ladder in Ladder.List) { + if (ladder == currentLadder) + { + continue; + } + else if (currentLadder != null) + { + //only switch from ladder to another if the ladders are above the current ladders and pressing up, or vice versa + if (ladder.Item.WorldPosition.Y > currentLadder.Item.WorldPosition.Y != IsKeyDown(InputType.Up)) + { + continue; + } + } + if (CanInteractWith(ladder.Item, out float dist, checkLinked: false) && dist < minDist) { minDist = dist; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Ladder.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Ladder.cs index 572a9b66b..004b00809 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Ladder.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Ladder.cs @@ -5,16 +5,12 @@ namespace Barotrauma.Items.Components { class Ladder : ItemComponent { - private static List list = new List(); - public static List List - { - get { return list; } - } + public static List List { get; } = new List(); public Ladder(Item item, XElement element) : base(item, element) { - list.Add(this); + List.Add(this); } public override bool Select(Character character) @@ -27,7 +23,7 @@ namespace Barotrauma.Items.Components protected override void RemoveComponentSpecific() { - list.Remove(this); + List.Remove(this); } } }