(ded4a3e0a) v0.9.0.7
This commit is contained in:
@@ -214,6 +214,11 @@ namespace Barotrauma.Steam
|
||||
if (s.Rules.ContainsKey("message")) serverInfo.ServerMessage = s.Rules["message"];
|
||||
if (s.Rules.ContainsKey("version")) serverInfo.GameVersion = s.Rules["version"];
|
||||
|
||||
if (s.Rules.ContainsKey("playercount"))
|
||||
{
|
||||
if (int.TryParse(s.Rules["playercount"], out int playerCount)) serverInfo.PlayerCount = playerCount;
|
||||
}
|
||||
|
||||
if (s.Rules.ContainsKey("contentpackage")) serverInfo.ContentPackageNames.AddRange(s.Rules["contentpackage"].Split(','));
|
||||
if (s.Rules.ContainsKey("contentpackagehash")) serverInfo.ContentPackageHashes.AddRange(s.Rules["contentpackagehash"].Split(','));
|
||||
if (s.Rules.ContainsKey("contentpackageurl")) serverInfo.ContentPackageWorkshopUrls.AddRange(s.Rules["contentpackageurl"].Split(','));
|
||||
@@ -235,6 +240,8 @@ namespace Barotrauma.Steam
|
||||
if (Enum.TryParse(s.Rules["traitors"], out YesNoMaybe traitorsEnabled)) serverInfo.TraitorsEnabled = traitorsEnabled;
|
||||
}
|
||||
|
||||
if (s.Rules.ContainsKey("gamestarted")) serverInfo.GameStarted = s.Rules["gamestarted"] == "True";
|
||||
|
||||
if (serverInfo.ContentPackageNames.Count != serverInfo.ContentPackageHashes.Count ||
|
||||
serverInfo.ContentPackageHashes.Count != serverInfo.ContentPackageWorkshopUrls.Count)
|
||||
{
|
||||
@@ -252,7 +259,8 @@ namespace Barotrauma.Steam
|
||||
|
||||
private static bool ValidateServerInfo(ServerList.Server server)
|
||||
{
|
||||
if (string.IsNullOrEmpty(server.Name)) { return false; }
|
||||
if (string.IsNullOrWhiteSpace(server.Name)) { return false; }
|
||||
if (string.IsNullOrWhiteSpace(server.Name.Replace("\0", ""))) { return false; }
|
||||
if (server.Address == null) { return false; }
|
||||
|
||||
return true;
|
||||
@@ -592,8 +600,15 @@ namespace Barotrauma.Steam
|
||||
}
|
||||
|
||||
SaveUtil.ClearFolder(WorkshopItemStagingFolder);
|
||||
Directory.Delete(WorkshopItemStagingFolder);
|
||||
File.Delete(PreviewImageName);
|
||||
try
|
||||
{
|
||||
Directory.Delete(WorkshopItemStagingFolder);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to delete Workshop item staging folder.", e);
|
||||
}
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
@@ -925,28 +940,50 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
if (instance == null || !instance.isInitialized) { return false; }
|
||||
|
||||
bool itemsUpdated = false;
|
||||
foreach (ulong subscribedItemId in instance.client.Workshop.GetSubscribedItemIds())
|
||||
bool? itemsUpdated = null;
|
||||
bool timedOut = false;
|
||||
var query = instance.client.Workshop.CreateQuery();
|
||||
query.FileId = new List<ulong>(instance.client.Workshop.GetSubscribedItemIds());
|
||||
query.UploaderAppId = AppID;
|
||||
query.Run();
|
||||
query.OnResult = (Workshop.Query q) =>
|
||||
{
|
||||
//TODO: fix this, GetItem doesn't query item.Modified
|
||||
var item = instance.client.Workshop.GetItem(subscribedItemId);
|
||||
if (item.Installed && CheckWorkshopItemEnabled(item) && !CheckWorkshopItemUpToDate(item))
|
||||
if (timedOut) { return; }
|
||||
itemsUpdated = false;
|
||||
foreach (var item in q.Items)
|
||||
{
|
||||
if (!UpdateWorkshopItem(item, out string errorMsg))
|
||||
if (item.Installed && CheckWorkshopItemEnabled(item) && !CheckWorkshopItemUpToDate(item))
|
||||
{
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
new GUIMessageBox(
|
||||
TextManager.Get("Error"),
|
||||
TextManager.GetWithVariables("WorkshopItemUpdateFailed", new string[2] { "[itemname]", "[errormessage]" }, new string[2] { item.Title, errorMsg }));
|
||||
}
|
||||
else
|
||||
{
|
||||
new GUIMessageBox("", TextManager.GetWithVariable("WorkshopItemUpdated", "[itemname]", item.Title));
|
||||
itemsUpdated = true;
|
||||
if (!UpdateWorkshopItem(item, out string errorMsg))
|
||||
{
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
new GUIMessageBox(
|
||||
TextManager.Get("Error"),
|
||||
TextManager.GetWithVariables("WorkshopItemUpdateFailed", new string[2] { "[itemname]", "[errormessage]" }, new string[2] { item.Title, errorMsg }));
|
||||
}
|
||||
else
|
||||
{
|
||||
new GUIMessageBox("", TextManager.GetWithVariable("WorkshopItemUpdated", "[itemname]", item.Title));
|
||||
itemsUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
DateTime timeOut = DateTime.Now + new TimeSpan(0, 0, 10);
|
||||
while (!itemsUpdated.HasValue)
|
||||
{
|
||||
if (DateTime.Now > timeOut)
|
||||
{
|
||||
itemsUpdated = false;
|
||||
timedOut = true;
|
||||
break;
|
||||
}
|
||||
instance.client.Update();
|
||||
System.Threading.Thread.Sleep(10);
|
||||
}
|
||||
return itemsUpdated;
|
||||
|
||||
return itemsUpdated.Value;
|
||||
}
|
||||
|
||||
public static bool UpdateWorkshopItem(Workshop.Item item, out string errorMsg)
|
||||
|
||||
Reference in New Issue
Block a user