Unstable 0.15.22.0

This commit is contained in:
Markus Isberg
2021-12-17 00:19:56 +09:00
parent 7d43cb1e91
commit a864a98d4f
16 changed files with 78 additions and 33 deletions
@@ -18,7 +18,7 @@ namespace Barotrauma.Abilities
{
if (abilityObject is AbilitySkillGain abilitySkillGain)
{
if (ignoreAbilitySkillGain && !abilitySkillGain.GainedFromAbility) { return; }
if (ignoreAbilitySkillGain && abilitySkillGain.GainedFromAbility) { return; }
Character.Info?.IncreaseSkillLevel(skillIdentifier, abilitySkillGain.Value, gainedFromAbility: true);
}
else
@@ -17,7 +17,7 @@ namespace Barotrauma.Abilities
{
if (abilityObject is AbilitySkillGain abilitySkillGain && abilitySkillGain.Character != Character)
{
if (ignoreAbilitySkillGain && !abilitySkillGain.GainedFromAbility) { return; }
if (ignoreAbilitySkillGain && abilitySkillGain.GainedFromAbility) { return; }
Character.Info?.IncreaseSkillLevel(abilitySkillGain.String, 1.0f, gainedFromAbility: true);
}
}
@@ -2341,10 +2341,11 @@ namespace Barotrauma
}
if (e.InnerException != null)
{
error += "\n\nInner exception: " + e.InnerException.Message + "\n";
if (e.InnerException.StackTrace != null)
var innermost = e.GetInnermost();
error += "\n\nInner exception: " + innermost.Message + "\n";
if (innermost.StackTrace != null)
{
error += e.InnerException.StackTrace.CleanupStackTrace(); ;
error += innermost.StackTrace.CleanupStackTrace(); ;
}
}
}
@@ -203,12 +203,26 @@ namespace Barotrauma
private readonly Action? onQuit;
private void OnQuit()
{
if (assembly != null) { onQuit?.Invoke(); }
try
{
if (assembly != null) { onQuit?.Invoke(); }
}
catch (Exception e)
{
e = e.GetInnermost();
DebugConsole.AddWarning($"Failed to call GameAnalytics.OnQuit: {e.Message} {e.StackTrace}");
//If this happens then GameAnalytics is just broken,
//let's just hope that it uninitialized correctly and
//allow the game to keep running
}
}
public void Dispose()
{
if (loadContext is null) { return; }
OnQuit();
loadContext?.Unload();
loadContext = null;
@@ -280,10 +280,7 @@ namespace Barotrauma.Items.Components
{
foreach (Item subItem in containedItem.ContainedItems.ToList())
{
if (subItem.Combine(spawnedItem, null))
{
break;
}
if (subItem.Combine(spawnedItem, null)) { break; }
}
}
else if (containedItem?.Combine(spawnedItem, null) ?? false)
@@ -302,12 +299,9 @@ namespace Barotrauma.Items.Components
foreach (ItemContainer ic in targetItem.GetComponents<ItemContainer>())
{
if (ic?.Inventory == null || ic.RemoveContainedItemsOnDeconstruct) { continue; }
foreach (Item containedItem in ic.Inventory.AllItemsMod)
foreach (Item outputItem in ic.Inventory.AllItemsMod)
{
if (!outputContainer.Inventory.TryPutItem(containedItem, user: null))
{
containedItem.Drop(dropper: null);
}
tryPutInOutputSlots(outputItem);
}
}
inputContainer.Inventory.RemoveItem(targetItem);
@@ -317,13 +311,29 @@ namespace Barotrauma.Items.Components
}
else
{
if (!outputContainer.Inventory.CanBePut(targetItem) || (Entity.Spawner?.IsInRemoveQueue(targetItem) ?? false))
if (Entity.Spawner?.IsInRemoveQueue(targetItem) ?? false)
{
targetItem.Drop(dropper: null);
}
else
{
outputContainer.Inventory.TryPutItem(targetItem, user: null, createNetworkEvent: true);
tryPutInOutputSlots(targetItem);
}
}
void tryPutInOutputSlots(Item item)
{
for (int i = 0; i < outputContainer.Capacity; i++)
{
var containedItem = outputContainer.Inventory.GetItemAt(i);
if (containedItem?.OwnInventory != null && containedItem.OwnInventory.TryPutItem(item, user: null))
{
return;
}
}
if (!outputContainer.Inventory.TryPutItem(item, user: null))
{
item.Drop(dropper: null);
}
}
}
@@ -704,5 +704,12 @@ namespace Barotrauma
Point topLeft = new Point(center.X - halfSize.X, center.Y + halfSize.Y);
return new Rectangle(topLeft, size);
}
public static Exception GetInnermost(this Exception e)
{
while (e.InnerException != null) { e = e.InnerException; }
return e;
}
}
}