Skip to content

Commit

Permalink
Unstable 0.1300.2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
3e849f2e5c committed Apr 27, 2021
1 parent 2c75028 commit bf743f1
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public ServerContentPackage(string name, string hash, UInt64 workshopId, DateTim

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);
Expand Down Expand Up @@ -156,20 +156,12 @@ protected void ReadConnectionInitializationStep(IReadMessage inc)
{
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)
{
Expand Down Expand Up @@ -225,7 +217,9 @@ protected void ReadConnectionInitializationStep(IReadMessage inc)
msgBox.Buttons[0].OnClicked = (yesBtn, userdata) =>
{
GameMain.ServerListScreen.Select();
GameMain.ServerListScreen.DownloadWorkshopItems(missingPackages.Select(p => p.WorkshopId), serverName, ServerConnection.EndPointString);
IEnumerable<ServerListScreen.PendingWorkshopDownload> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ public static void ForceRedownload(Steamworks.Data.PublishedFileId itemId, Actio
}
catch (Exception e) { DebugConsole.ThrowError("Failed to delete Workshop item cache", e); }
}
itemToNuke.Download(onDownloadFinished, highPriority: true);
DebugConsole.NewMessage($"{itemToNuke.Download(onDownloadFinished, highPriority: true)}");
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,32 @@ class ServerListScreen : Screen
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<ulong, Steamworks.Ugc.Item?> pendingWorkshopDownloads = null;
private Dictionary<ulong, PendingWorkshopDownload> pendingWorkshopDownloads = null;
private string autoConnectName;
public string AutoConnectEndpoint { get; private set; }
public string LastAutoConnectEndpoint;
private string autoConnectEndpoint;

private enum TernaryOption
{
Expand Down Expand Up @@ -1043,7 +1063,7 @@ public override void Update(double deltaTime)
{
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;
Expand All @@ -1054,6 +1074,7 @@ public override void Update(double deltaTime)
{
TaskPool.Add("SubscribeToServerMod", item?.Subscribe(), (t) => { });
}
PendingWorkshopDownload clearedDownload = pendingWorkshopDownloads[itemId];
pendingWorkshopDownloads.Remove(itemId);
currentlyDownloadingWorkshopItem = null;

Expand All @@ -1070,14 +1091,23 @@ public override void Update(double deltaTime)
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;
}
}
}
Expand Down Expand Up @@ -2134,46 +2164,46 @@ private void MasterServerCallBack(IRestResponse response)
masterServerResponded = true;
}

public void DownloadWorkshopItems(IEnumerable<ulong> ids, string serverName, string endPointString)
public void DownloadWorkshopItems(IEnumerable<PendingWorkshopDownload> 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<ulong, Steamworks.Ugc.Item?>();
pendingWorkshopDownloads = new Dictionary<ulong, PendingWorkshopDownload>();

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<Steamworks.Ugc.Item?>)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);

Expand All @@ -2199,17 +2229,21 @@ public void DownloadWorkshopItems(IEnumerable<ulong> ids, string serverName, str
{
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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,9 @@ private void CreateWorkshopItemFrame(Steamworks.Ugc.Item? item, GUIListBox listB
DebugConsole.ThrowError($"Failed to reinstall \"{item?.Title}\": {errorMsg}", null, true);
elem.Flash(GUI.Style.Red);
}
RefreshSubscribedItems();
});
RefreshSubscribedItems();
}
catch (Exception e)
{
Expand All @@ -705,6 +707,7 @@ private void CreateWorkshopItemFrame(Steamworks.Ugc.Item? item, GUIListBox listB
}
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"),
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/LinuxClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>0.1300.1.11</Version>
<Version>0.1300.2.11</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/MacClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>0.1300.1.11</Version>
<Version>0.1300.2.11</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/WindowsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>0.1300.1.11</Version>
<Version>0.1300.2.11</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/LinuxServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>0.1300.1.11</Version>
<Version>0.1300.2.11</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/MacServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>0.1300.1.11</Version>
<Version>0.1300.2.11</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/WindowsServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>0.1300.1.11</Version>
<Version>0.1300.2.11</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ public void ParsePath(bool parseSpritePath)
// 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);
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaShared/SharedSource/Map/Explosion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ public static Dictionary<Structure, float> RangedStructureDamage(Vector2 worldPo
{
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;
}
}
Expand Down
26 changes: 25 additions & 1 deletion Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,12 +1068,36 @@ public void EnableMaintainPosition()
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<Steering>();
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<ConnectionPanel>()?.Connections.Find(c => c.Name == "velocity_x_out");
Connection connectionY = item.GetComponent<ConnectionPanel>()?.Connections.Find(c => c.Name == "velocity_y_out");
if (connectionX != null)
{
foreach (Engine engine in steering.Item.GetConnectedComponentsRecursive<Engine>(connectionX))
{
if (engine.Item.Submarine == this) { steeringValue++; }
}
}
if (connectionY != null)
{
foreach (Pump pump in steering.Item.GetConnectedComponentsRecursive<Pump>(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<Hull> ballastHulls = new HashSet<Hull>();
Expand Down
19 changes: 18 additions & 1 deletion Barotrauma/BarotraumaShared/changelog.txt
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Loading

0 comments on commit bf743f1

Please sign in to comment.