diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/ClientPeer.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/ClientPeer.cs index 9eb592b78..cadf2a25b 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/ClientPeer.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/Primitives/Peers/ClientPeer.cs @@ -44,11 +44,11 @@ namespace Barotrauma.Networking protected string GetPackageStr(ContentPackage contentPackage) { - return "\"" + contentPackage.Name + "\" (hash " + contentPackage.MD5hash.ShortHash + ")"; + return $"\"{contentPackage.Name}\" (hash {contentPackage.MD5hash.ShortHash})"; } protected string GetPackageStr(ServerContentPackage contentPackage) { - return "\"" + contentPackage.Name + "\" (hash " + Md5Hash.GetShortHash(contentPackage.Hash) + ")"; + return $"\"{contentPackage.Name}\" (hash {Md5Hash.GetShortHash(contentPackage.Hash)})"; } public delegate void MessageCallback(IReadMessage message); @@ -156,20 +156,12 @@ namespace Barotrauma.Networking { return ContentPackage.AllPackages.Any(local => local.SteamWorkshopId != 0 && /* is a Workshop item */ - remote.WorkshopId == local.SteamWorkshopId /* ids match */); + remote.WorkshopId == local.SteamWorkshopId && /* ids match */ + remote.InstallTime < local.InstallTime/* remote is older than local */); }); - if (GameMain.ServerListScreen.LastAutoConnectEndpoint != ServerConnection.EndPointString) - { - mismatchedButDownloaded = mismatchedButDownloaded.Where(remote => - { - return ContentPackage.AllPackages.Any(local => - remote.InstallTime < local.InstallTime/* remote is older than local */); - }); - } if (mismatchedButDownloaded.Any()) { - GameMain.ServerListScreen.LastAutoConnectEndpoint = null; string disconnectMsg; if (mismatchedButDownloaded.Count() == 1) { @@ -225,7 +217,9 @@ namespace Barotrauma.Networking msgBox.Buttons[0].OnClicked = (yesBtn, userdata) => { GameMain.ServerListScreen.Select(); - GameMain.ServerListScreen.DownloadWorkshopItems(missingPackages.Select(p => p.WorkshopId), serverName, ServerConnection.EndPointString); + IEnumerable downloads = + missingPackages.Select(p => new ServerListScreen.PendingWorkshopDownload(p.Hash, p.WorkshopId)); + GameMain.ServerListScreen.DownloadWorkshopItems(downloads, serverName, ServerConnection.EndPointString); return true; }; msgBox.Buttons[0].OnClicked += msgBox.Close; diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/SteamManager.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/SteamManager.cs index 2ce80a884..2c8915596 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Networking/SteamManager.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/SteamManager.cs @@ -1001,7 +1001,7 @@ namespace Barotrauma.Steam } catch (Exception e) { DebugConsole.ThrowError("Failed to delete Workshop item cache", e); } } - itemToNuke.Download(onDownloadFinished, highPriority: true); + DebugConsole.NewMessage($"{itemToNuke.Download(onDownloadFinished, highPriority: true)}"); } /// diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/ServerListScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/ServerListScreen.cs index 1305ed850..1a316e4a8 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Screens/ServerListScreen.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/ServerListScreen.cs @@ -38,12 +38,32 @@ namespace Barotrauma private GUIListBox friendsDropdown; //Workshop downloads + public struct PendingWorkshopDownload + { + public readonly string ExpectedHash; + public readonly ulong Id; + public readonly Steamworks.Ugc.Item? Item; + + public PendingWorkshopDownload(string expectedHash, Steamworks.Ugc.Item item) + { + ExpectedHash = expectedHash; + Item = item; + Id = item.Id; + } + + public PendingWorkshopDownload(string expectedHash, ulong id) + { + ExpectedHash = expectedHash; + Item = null; + Id = id; + } + } + private GUIFrame workshopDownloadsFrame = null; private Steamworks.Ugc.Item? currentlyDownloadingWorkshopItem = null; - private Dictionary pendingWorkshopDownloads = null; + private Dictionary pendingWorkshopDownloads = null; private string autoConnectName; - public string AutoConnectEndpoint { get; private set; } - public string LastAutoConnectEndpoint; + private string autoConnectEndpoint; private enum TernaryOption { @@ -1043,7 +1063,7 @@ namespace Barotrauma { if (pendingWorkshopDownloads?.Any() ?? false) { - Steamworks.Ugc.Item? item = pendingWorkshopDownloads.Values.FirstOrDefault(it => it != null); + Steamworks.Ugc.Item? item = pendingWorkshopDownloads.Values.FirstOrDefault(it => it.Item != null).Item; if (item != null) { ulong itemId = item.Value.Id; @@ -1054,6 +1074,7 @@ namespace Barotrauma { TaskPool.Add("SubscribeToServerMod", item?.Subscribe(), (t) => { }); } + PendingWorkshopDownload clearedDownload = pendingWorkshopDownloads[itemId]; pendingWorkshopDownloads.Remove(itemId); currentlyDownloadingWorkshopItem = null; @@ -1070,14 +1091,23 @@ namespace Barotrauma workshopDownloadsFrame?.FindChild((c) => c.UserData is ulong l && l == itemId, true)?.Flash(GUI.Style.Red); DebugConsole.ThrowError(errorMsg); } + + ContentPackage resultingPackage = ContentPackage.AllPackages.FirstOrDefault(p => p.MD5hash.Hash == clearedDownload.ExpectedHash); + if (resultingPackage == null) + { + workshopDownloadsFrame?.FindChild((c) => c.UserData is ulong l && l == itemId, true)?.Flash(GUI.Style.Red); + CancelWorkshopDownloads(); + new GUIMessageBox( + TextManager.Get("ConnectionLost"), + TextManager.GetWithVariable("DisconnectMessage.MismatchedWorkshopMod", "incompatiblecontentpackage", $"\"{resultingPackage.Name}\" (hash {resultingPackage.MD5hash.ShortHash})")); + } }); } } - else if (!string.IsNullOrEmpty(AutoConnectEndpoint)) + else if (!string.IsNullOrEmpty(autoConnectEndpoint)) { - LastAutoConnectEndpoint = AutoConnectEndpoint; - JoinServer(AutoConnectEndpoint, autoConnectName); - AutoConnectEndpoint = null; + JoinServer(autoConnectEndpoint, autoConnectName); + autoConnectEndpoint = null; } } } @@ -2134,46 +2164,46 @@ namespace Barotrauma masterServerResponded = true; } - public void DownloadWorkshopItems(IEnumerable ids, string serverName, string endPointString) + public void DownloadWorkshopItems(IEnumerable downloads, string serverName, string endPointString) { if (workshopDownloadsFrame != null) { return; } - int rowCount = ids.Count() + 2; + int rowCount = downloads.Count() + 2; - autoConnectName = serverName; AutoConnectEndpoint = endPointString; + autoConnectName = serverName; autoConnectEndpoint = endPointString; workshopDownloadsFrame = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas), null, Color.Black * 0.5f); currentlyDownloadingWorkshopItem = null; - pendingWorkshopDownloads = new Dictionary(); + pendingWorkshopDownloads = new Dictionary(); var innerFrame = new GUIFrame(new RectTransform(new Vector2(0.5f, 0.1f + 0.03f * rowCount), workshopDownloadsFrame.RectTransform, Anchor.Center, Pivot.Center)); var innerLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, (float)rowCount / (float)(rowCount + 3)), innerFrame.RectTransform, Anchor.Center, Pivot.Center)); - foreach (ulong id in ids) + foreach (PendingWorkshopDownload entry in downloads) { - pendingWorkshopDownloads.Add(id, null); + pendingWorkshopDownloads.Add(entry.Id, entry); var itemLayout = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f / rowCount), innerLayout.RectTransform), true, Anchor.CenterLeft) { - UserData = id + UserData = entry.Id }; - TaskPool.Add("RetrieveWorkshopItemData", Steamworks.SteamUGC.QueryFileAsync(id), (t) => + TaskPool.Add("RetrieveWorkshopItemData", Steamworks.SteamUGC.QueryFileAsync(entry.Id), (t) => { if (t.IsFaulted) { - TaskPool.PrintTaskExceptions(t, $"Failed to retrieve Workshop item info (ID {id})"); + TaskPool.PrintTaskExceptions(t, $"Failed to retrieve Workshop item info (ID {entry.Id})"); return; } Steamworks.Ugc.Item? item = ((Task)t).Result; if (!item.HasValue) { - DebugConsole.ThrowError($"Failed to find a Steam Workshop item with the ID {id}."); + DebugConsole.ThrowError($"Failed to find a Steam Workshop item with the ID {entry.Id}."); return; } - if (pendingWorkshopDownloads.ContainsKey(id)) + if (pendingWorkshopDownloads.ContainsKey(entry.Id)) { - pendingWorkshopDownloads[id] = item; + pendingWorkshopDownloads[entry.Id] = new PendingWorkshopDownload(entry.ExpectedHash, item.Value); new GUITextBlock(new RectTransform(new Vector2(0.4f, 0.67f), itemLayout.RectTransform, Anchor.CenterLeft, Pivot.CenterLeft), item.Value.Title); @@ -2199,17 +2229,21 @@ namespace Barotrauma { OnClicked = (btn, obj) => { - AutoConnectEndpoint = null; - LastAutoConnectEndpoint = null; - autoConnectName = null; - pendingWorkshopDownloads.Clear(); - currentlyDownloadingWorkshopItem = null; - workshopDownloadsFrame = null; + CancelWorkshopDownloads(); return true; } }; } + public void CancelWorkshopDownloads() + { + autoConnectEndpoint = null; + autoConnectName = null; + pendingWorkshopDownloads.Clear(); + currentlyDownloadingWorkshopItem = null; + workshopDownloadsFrame = null; + } + private bool JoinServer(string endpoint, string serverName) { if (string.IsNullOrWhiteSpace(ClientNameBox.Text)) diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/SteamWorkshopScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/SteamWorkshopScreen.cs index f2562a9fb..4cc90ee24 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Screens/SteamWorkshopScreen.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/SteamWorkshopScreen.cs @@ -696,7 +696,9 @@ namespace Barotrauma DebugConsole.ThrowError($"Failed to reinstall \"{item?.Title}\": {errorMsg}", null, true); elem.Flash(GUI.Style.Red); } + RefreshSubscribedItems(); }); + RefreshSubscribedItems(); } catch (Exception e) { @@ -705,6 +707,7 @@ namespace Barotrauma } return true; }; + reinstallBtn.Enabled = !item.Value.IsDownloading && !item.Value.IsDownloadPending; var unsubBtn = new GUIButton(new RectTransform(new Point((int)(32 * GUI.Scale)), rightColumn.RectTransform), "", style: "GUIMinusButton") { ToolTip = TextManager.Get("WorkshopItemUnsubscribe"), diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj index 569b98aa5..0c55335e1 100644 --- a/Barotrauma/BarotraumaClient/LinuxClient.csproj +++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.1300.1.11 + 0.1300.2.11 Copyright © FakeFish 2018-2020 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj index b89bcc2ec..6c0919f6e 100644 --- a/Barotrauma/BarotraumaClient/MacClient.csproj +++ b/Barotrauma/BarotraumaClient/MacClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.1300.1.11 + 0.1300.2.11 Copyright © FakeFish 2018-2020 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj index 13a030cd3..0b2194b48 100644 --- a/Barotrauma/BarotraumaClient/WindowsClient.csproj +++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.1300.1.11 + 0.1300.2.11 Copyright © FakeFish 2018-2020 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaServer/LinuxServer.csproj b/Barotrauma/BarotraumaServer/LinuxServer.csproj index 5040a5efb..63f5215c3 100644 --- a/Barotrauma/BarotraumaServer/LinuxServer.csproj +++ b/Barotrauma/BarotraumaServer/LinuxServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.1300.1.11 + 0.1300.2.11 Copyright © FakeFish 2018-2020 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/MacServer.csproj b/Barotrauma/BarotraumaServer/MacServer.csproj index 2f45bd304..5d5b825b4 100644 --- a/Barotrauma/BarotraumaServer/MacServer.csproj +++ b/Barotrauma/BarotraumaServer/MacServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.1300.1.11 + 0.1300.2.11 Copyright © FakeFish 2018-2020 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj b/Barotrauma/BarotraumaServer/WindowsServer.csproj index 3333d2c00..6a084573d 100644 --- a/Barotrauma/BarotraumaServer/WindowsServer.csproj +++ b/Barotrauma/BarotraumaServer/WindowsServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.1300.1.11 + 0.1300.2.11 Copyright © FakeFish 2018-2020 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Wearable.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Wearable.cs index 3a6743bd7..d9a1ba7fd 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Wearable.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Wearable.cs @@ -144,6 +144,11 @@ namespace Barotrauma // If the variant does not exist, parse the path so that it uses first variant. SpritePath = tempPath.Replace("[VARIANT]", "1"); } + if (!File.Exists(SpritePath) && _gender == Gender.None) + { + // If there's no sprite for Gender.None does not exist, try to use male sprite + SpritePath = tempPath.Replace("[GENDER]", "male"); + } if (parseSpritePath) { Sprite.ParseTexturePath(file: SpritePath); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Explosion.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Explosion.cs index 6c606b0ce..7806c2708 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/Explosion.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Explosion.cs @@ -426,7 +426,7 @@ namespace Barotrauma { if (MathUtils.LineSegmentToPointDistanceSquared((edge.Point1 + cell.Translation).ToPoint(), (edge.Point2 + cell.Translation).ToPoint(), worldPosition.ToPoint()) < worldRange * worldRange) { - destructibleWall.AddDamage(damage, worldPosition); + destructibleWall.AddDamage(levelWallDamage, worldPosition); break; } } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs index e6e6254ee..9f81f4ab3 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs @@ -1068,12 +1068,36 @@ namespace Barotrauma public void NeutralizeBallast() { float neutralBallastLevel = 0.5f; + int selectedSteeringValue = 0; foreach (Item item in Item.ItemList) { if (item.Submarine != this) { continue; } var steering = item.GetComponent(); if (steering == null) { continue; } - neutralBallastLevel = Math.Min(neutralBallastLevel, steering.NeutralBallastLevel); + + //find how many pumps/engines in this sub the steering item is connected to + int steeringValue = 1; + Connection connectionX = item.GetComponent()?.Connections.Find(c => c.Name == "velocity_x_out"); + Connection connectionY = item.GetComponent()?.Connections.Find(c => c.Name == "velocity_y_out"); + if (connectionX != null) + { + foreach (Engine engine in steering.Item.GetConnectedComponentsRecursive(connectionX)) + { + if (engine.Item.Submarine == this) { steeringValue++; } + } + } + if (connectionY != null) + { + foreach (Pump pump in steering.Item.GetConnectedComponentsRecursive(connectionY)) + { + if (pump.Item.Submarine == this) { steeringValue++; } + } + } + //the nav terminal that's connected to the most engines/pumps in the sub most likely controls the sub (instead of a shuttle or some other system) + if (steeringValue > selectedSteeringValue) + { + neutralBallastLevel = steering.NeutralBallastLevel; + } } HashSet ballastHulls = new HashSet(); diff --git a/Barotrauma/BarotraumaShared/changelog.txt b/Barotrauma/BarotraumaShared/changelog.txt index 626c1a096..e934f0c60 100644 --- a/Barotrauma/BarotraumaShared/changelog.txt +++ b/Barotrauma/BarotraumaShared/changelog.txt @@ -1,5 +1,22 @@ --------------------------------------------------------------------------------------------------------- -v0.13.1.11 +v0.1300.2.11 (unstable) +--------------------------------------------------------------------------------------------------------- + +Changes: +- Made large monsters immune to sufforin. + +Fixes: +- More fixes to installing/updating mods. +- Fixed certain submarines spawning with a non-neutral ballast level (Kastrull seems to have been the only affected vanilla submarine). Happened because the game would determine the neutral ballast level from the first nav terminal it finds in the sub, without checking whether that terminal controls a shuttle or the sub itself. +- Fixed explosions using wall damage value instead of level wall damage when the explosion happens outside a level wall. +- Fixed oxygen shelves refilling oxygenite tanks (again). +- Readded traitor missions that were accidentally removed in the previous unstable build. + +Modding: +- Fixed console errors when a character with no gender tries to wear clothing that only has separate male and female sprites. + +--------------------------------------------------------------------------------------------------------- +v0.1300.1.11 (unstable) --------------------------------------------------------------------------------------------------------- Changes: diff --git a/Libraries/Facepunch.Steamworks/SteamUgc.cs b/Libraries/Facepunch.Steamworks/SteamUgc.cs index 9d41b8ebe..03ada053c 100644 --- a/Libraries/Facepunch.Steamworks/SteamUgc.cs +++ b/Libraries/Facepunch.Steamworks/SteamUgc.cs @@ -25,7 +25,20 @@ namespace Steamworks internal static void InstallEvents( bool server ) { - Dispatch.Install( x => OnDownloadItemResult?.Invoke( x.Result ), server ); + Dispatch.Install( x => + { + if (x.AppID == SteamClient.AppId) + { + OnDownloadItemResult?.Invoke(x.Result); + + Ugc.Item item = new Ugc.Item(x.PublishedFileId); + if (item.IsInstalled && (onItemInstalled?.ContainsKey(x.PublishedFileId) ?? false)) + { + onItemInstalled[x.PublishedFileId]?.Invoke(); + onItemInstalled.Remove(x.PublishedFileId); + } + } + }, server ); Dispatch.Install(x => { if (x.AppID == SteamClient.AppId)