Unstable 0.1300.2.11
This commit is contained in:
@@ -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<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;
|
||||
|
||||
@@ -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)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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<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
|
||||
{
|
||||
@@ -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<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);
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user