(6e187d247) Fixed contained items' status effects being added twice to the list of an ItemContainer's active status effects when swapping items. For example, when swapping a fuel rod with another one, the status effect that increases AvailableFuel would be applied twice, causing the reactor to act as if there were 2 rods in it. Closes #1643 + merge fix
This commit is contained in:
@@ -2047,13 +2047,15 @@ namespace Barotrauma.Networking
|
||||
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||
}
|
||||
|
||||
public void SetupNewCampaign(Submarine sub, string savePath, string mapSeed)
|
||||
public void SetupNewCampaign(Submarine sub, string saveName, string mapSeed)
|
||||
{
|
||||
saveName = Path.GetFileNameWithoutExtension(saveName);
|
||||
|
||||
NetOutgoingMessage msg = client.CreateMessage();
|
||||
msg.Write((byte)ClientPacketHeader.CAMPAIGN_SETUP_INFO);
|
||||
|
||||
msg.Write(true); msg.WritePadBits();
|
||||
msg.Write(savePath);
|
||||
msg.Write(saveName);
|
||||
msg.Write(mapSeed);
|
||||
msg.Write(sub.Name);
|
||||
msg.Write(sub.MD5Hash.Hash);
|
||||
|
||||
@@ -590,12 +590,19 @@ namespace Barotrauma.Steam
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError("Publishing workshop item " + item.Title + " failed. " + item.Error);
|
||||
DebugConsole.NewMessage("Publishing workshop item " + item.Title + " failed. " + item.Error, Microsoft.Xna.Framework.Color.Red);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -927,28 +934,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)
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
localEnabled = box.Selected;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -145,16 +146,12 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (obj is WhiteListedPlayer)
|
||||
{
|
||||
WhiteListedPlayer wlp = obj as WhiteListedPlayer;
|
||||
if (wlp == null) return false;
|
||||
|
||||
if (!(obj is WhiteListedPlayer wlp)) return false;
|
||||
if (!localRemoved.Contains(wlp.UniqueIdentifier)) localRemoved.Add(wlp.UniqueIdentifier);
|
||||
}
|
||||
else if (obj is LocalAdded)
|
||||
{
|
||||
LocalAdded lad = obj as LocalAdded;
|
||||
if (lad == null) return false;
|
||||
|
||||
if (!(obj is LocalAdded lad)) return false;
|
||||
if (localAdded.Contains(lad)) localAdded.Remove(lad);
|
||||
}
|
||||
|
||||
@@ -210,7 +207,6 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
ip = "IP concealed by host";
|
||||
}
|
||||
DebugConsole.NewMessage("nerd: " + name, Color.Lime);
|
||||
whitelistedPlayers.Add(new WhiteListedPlayer(name, uniqueIdentifier, ip));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user