Hotfix 1.1.18.1

This commit is contained in:
Markus Isberg
2023-10-20 18:05:28 +03:00
parent df7e8f1625
commit 6cc82976a1
19 changed files with 164 additions and 58 deletions
@@ -1,22 +1,19 @@
#nullable enable
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma; namespace Barotrauma;
partial class TutorialHighlightAction : EventAction partial class HighlightAction : EventAction
{ {
private static readonly Color highlightColor = Color.Orange; partial void SetHighlightProjSpecific(Entity entity, IEnumerable<Character>? targetCharacters)
partial void UpdateProjSpecific()
{ {
if (GameMain.GameSession?.GameMode is not TutorialMode) { return; } if (targetCharacters != null && !targetCharacters.Contains(Character.Controlled))
foreach (var target in ParentEvent.GetTargets(TargetTag))
{ {
SetHighlight(target); return;
} }
}
private void SetHighlight(Entity entity)
{
if (entity is Item i) if (entity is Item i)
{ {
SetItemHighlight(i); SetItemHighlight(i);
@@ -1540,6 +1540,23 @@ namespace Barotrauma
RemoveFromDroppedStack(allowClientExecute: true); RemoveFromDroppedStack(allowClientExecute: true);
} }
break; break;
case EventType.SetHighlight:
bool isTargetedForThisClient = msg.ReadBoolean();
if (isTargetedForThisClient)
{
bool highlight = msg.ReadBoolean();
ExternalHighlight = highlight;
if (highlight)
{
Color highlightColor = msg.ReadColorR8G8B8A8();
HighlightColor = highlightColor;
}
else
{
HighlightColor = null;
}
}
break;
default: default:
throw new Exception($"Malformed incoming item event: unsupported event type {eventType}"); throw new Exception($"Malformed incoming item event: unsupported event type {eventType}");
} }
@@ -583,7 +583,9 @@ namespace Barotrauma
if (saveFiles == null) if (saveFiles == null)
{ {
saveFiles = SaveUtil.GetSaveFiles(SaveUtil.SaveType.Singleplayer); //we don't need to log errors at this point,
//if any file fails to load the error will get logged when we try to extract the root from the game session doc later in the method
saveFiles = SaveUtil.GetSaveFiles(SaveUtil.SaveType.Singleplayer, logLoadErrors: false);
} }
var leftColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), loadGameContainer.RectTransform), childAnchor: Anchor.TopCenter) var leftColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), loadGameContainer.RectTransform), childAnchor: Anchor.TopCenter)
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product> <Product>Barotrauma</Product>
<Version>1.1.18.0</Version> <Version>1.1.18.1</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright> <Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName> <AssemblyName>Barotrauma</AssemblyName>
+1 -1
View File
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product> <Product>Barotrauma</Product>
<Version>1.1.18.0</Version> <Version>1.1.18.1</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright> <Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName> <AssemblyName>Barotrauma</AssemblyName>
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product> <Product>Barotrauma</Product>
<Version>1.1.18.0</Version> <Version>1.1.18.1</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright> <Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName> <AssemblyName>Barotrauma</AssemblyName>
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product> <Product>Barotrauma Dedicated Server</Product>
<Version>1.1.18.0</Version> <Version>1.1.18.1</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright> <Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName> <AssemblyName>DedicatedServer</AssemblyName>
+1 -1
View File
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product> <Product>Barotrauma Dedicated Server</Product>
<Version>1.1.18.0</Version> <Version>1.1.18.1</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright> <Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName> <AssemblyName>DedicatedServer</AssemblyName>
@@ -0,0 +1,24 @@
#nullable enable
using Barotrauma.Networking;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma;
partial class HighlightAction : EventAction
{
partial void SetHighlightProjSpecific(Entity entity, IEnumerable<Character>? targetCharacters)
{
if (entity is Item item && GameMain.Server != null)
{
IEnumerable<Client>? targetClients = null;
if (targetCharacters != null)
{
targetClients = targetCharacters
.Select(c => GameMain.Server.ConnectedClients.FirstOrDefault(client => client.Character == c))
.Where(c => c != null)!;
}
GameMain.Server?.CreateEntityEvent(item, new Item.SetHighlightEventData(State, highlightColor, targetClients));
}
}
}
@@ -161,6 +161,20 @@ namespace Barotrauma
msg.WriteUInt16(droppedItem.ID); msg.WriteUInt16(droppedItem.ID);
} }
break; break;
case SetHighlightEventData highlightEventData:
bool isTargetedForClient =
highlightEventData.TargetClients.IsEmpty ||
highlightEventData.TargetClients.Contains(c);
msg.WriteBoolean(isTargetedForClient);
if (isTargetedForClient)
{
msg.WriteBoolean(highlightEventData.Highlighted);
if (highlightEventData.Highlighted)
{
msg.WriteColorR8G8B8A8(highlightEventData.Color);
}
}
break;
default: default:
throw error($"Unsupported event type {itemEventData.GetType().Name}"); throw error($"Unsupported event type {itemEventData.GetType().Name}");
} }
@@ -1,4 +1,7 @@
using System.Collections.Generic; #nullable enable
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;
@@ -16,4 +19,20 @@ partial class Item
Items = items.Distinct().ToImmutableArray(); Items = items.Distinct().ToImmutableArray();
} }
} }
public readonly struct SetHighlightEventData : IEventData
{
public EventType EventType => EventType.SetHighlight;
public readonly bool Highlighted;
public readonly Color Color;
public readonly ImmutableArray<Client> TargetClients;
public SetHighlightEventData(bool highlighted, Color color, IEnumerable<Client>? targetClients)
{
Highlighted = highlighted;
Color = color;
TargetClients = (targetClients ?? Enumerable.Empty<Client>()).ToImmutableArray();
}
}
} }
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product> <Product>Barotrauma Dedicated Server</Product>
<Version>1.1.18.0</Version> <Version>1.1.18.1</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright> <Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName> <AssemblyName>DedicatedServer</AssemblyName>
@@ -140,7 +140,11 @@ namespace Barotrauma
Identifier typeName = element.Name.ToString().ToIdentifier(); Identifier typeName = element.Name.ToString().ToIdentifier();
if (typeName == "TutorialSegmentAction") if (typeName == "TutorialSegmentAction")
{ {
typeName = "EventObjectiveAction".ToIdentifier(); typeName = nameof(EventObjectiveAction).ToIdentifier();
}
else if (typeName == "TutorialHighlightAction")
{
typeName = nameof(HighlightAction).ToIdentifier();
} }
actionType = Type.GetType("Barotrauma." + typeName, throwOnError: true, ignoreCase: true); actionType = Type.GetType("Barotrauma." + typeName, throwOnError: true, ignoreCase: true);
if (actionType == null) { throw new NullReferenceException(); } if (actionType == null) { throw new NullReferenceException(); }
@@ -0,0 +1,43 @@
#nullable enable
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma;
partial class HighlightAction : EventAction
{
private static readonly Color highlightColor = Color.Orange;
[Serialize("", IsPropertySaveable.Yes)]
public Identifier TargetTag { get; set; }
[Serialize("", IsPropertySaveable.Yes, description: "Only the player controlling this character will see the highlight. If empty, all players will see it.")]
public Identifier TargetCharacter { get; set; }
[Serialize(true, IsPropertySaveable.Yes)]
public bool State { get; set; }
private bool isFinished;
public HighlightAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
{
}
public override void Update(float deltaTime)
{
if (isFinished) { return; }
var targetCharacters = TargetCharacter.IsEmpty ? null : ParentEvent.GetTargets(TargetCharacter).OfType<Character>();
foreach (var target in ParentEvent.GetTargets(TargetTag))
{
SetHighlightProjSpecific(target, targetCharacters);
}
isFinished = true;
}
partial void SetHighlightProjSpecific(Entity entity, IEnumerable<Character>? targetCharacters);
public override bool IsFinished(ref string goToLabel) => isFinished;
public override void Reset() => isFinished = false;
}
@@ -1,33 +0,0 @@
namespace Barotrauma;
partial class TutorialHighlightAction : EventAction
{
[Serialize("", IsPropertySaveable.Yes)]
public Identifier TargetTag { get; set; }
[Serialize(true, IsPropertySaveable.Yes)]
public bool State { get; set; }
private bool isFinished;
public TutorialHighlightAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
{
if (GameMain.NetworkMember != null)
{
DebugConsole.ThrowError($"Error in event \"{parentEvent.Prefab.Identifier}\": {nameof(TutorialHighlightAction)} is not supported in multiplayer.");
}
}
public override void Update(float deltaTime)
{
if (isFinished) { return; }
UpdateProjSpecific();
isFinished = true;
}
partial void UpdateProjSpecific();
public override bool IsFinished(ref string goToLabel) => isFinished;
public override void Reset() => isFinished = false;
}
@@ -294,6 +294,11 @@ namespace Barotrauma.Extensions
.Where(nullable => nullable.HasValue) .Where(nullable => nullable.HasValue)
.Select(nullable => nullable.Value); .Select(nullable => nullable.Value);
public static IEnumerable<T> NotNull<T>(this IEnumerable<T> source) where T : class
=> source
.Where(nullable => nullable != null)
.Select(nullable => nullable!);
public static IEnumerable<T> NotNone<T>(this IEnumerable<Option<T>> source) public static IEnumerable<T> NotNone<T>(this IEnumerable<Option<T>> source)
{ {
foreach (var o in source) foreach (var o in source)
@@ -23,9 +23,10 @@ namespace Barotrauma
Upgrade = 8, Upgrade = 8,
ItemStat = 9, ItemStat = 9,
DroppedStack = 10, DroppedStack = 10,
SetHighlight = 11,
MinValue = 0, MinValue = 0,
MaxValue = 10 MaxValue = 11
} }
public interface IEventData : NetEntityEvent.IData public interface IEventData : NetEntityEvent.IData
@@ -238,7 +238,7 @@ namespace Barotrauma
return folder; return folder;
} }
public static IReadOnlyList<CampaignMode.SaveInfo> GetSaveFiles(SaveType saveType, bool includeInCompatible = true) public static IReadOnlyList<CampaignMode.SaveInfo> GetSaveFiles(SaveType saveType, bool includeInCompatible = true, bool logLoadErrors = true)
{ {
string defaultFolder = saveType == SaveType.Singleplayer ? DefaultSaveFolder : DefaultMultiplayerSaveFolder; string defaultFolder = saveType == SaveType.Singleplayer ? DefaultSaveFolder : DefaultMultiplayerSaveFolder;
if (!Directory.Exists(defaultFolder)) if (!Directory.Exists(defaultFolder))
@@ -273,7 +273,7 @@ namespace Barotrauma
List<CampaignMode.SaveInfo> saveInfos = new List<CampaignMode.SaveInfo>(); List<CampaignMode.SaveInfo> saveInfos = new List<CampaignMode.SaveInfo>();
foreach (string file in files) foreach (string file in files)
{ {
var docRoot = ExtractGameSessionRootElementFromSaveFile(file); var docRoot = ExtractGameSessionRootElementFromSaveFile(file, logLoadErrors);
if (!includeInCompatible && !IsSaveFileCompatible(docRoot)) if (!includeInCompatible && !IsSaveFileCompatible(docRoot))
{ {
continue; continue;
@@ -561,7 +561,7 @@ namespace Barotrauma
/// Extract *only* the root element of the gamesession.xml file in the given save. /// Extract *only* the root element of the gamesession.xml file in the given save.
/// For performance reasons, none of its child elements are returned. /// For performance reasons, none of its child elements are returned.
/// </summary> /// </summary>
public static XElement? ExtractGameSessionRootElementFromSaveFile(string savePath) public static XElement? ExtractGameSessionRootElementFromSaveFile(string savePath, bool logLoadErrors = true)
{ {
const int maxRetries = 4; const int maxRetries = 4;
for (int i = 0; i <= maxRetries; i++) for (int i = 0; i <= maxRetries; i++)
@@ -617,12 +617,19 @@ namespace Barotrauma
if (i >= maxRetries || !File.Exists(savePath)) { throw; } if (i >= maxRetries || !File.Exists(savePath)) { throw; }
DebugConsole.NewMessage( DebugConsole.NewMessage(
$"Failed to decompress file \"{savePath}\" for root extraction {{{e.Message}}}, retrying in 250 ms...", $"Failed to decompress file \"{savePath}\" for root extraction ({e.Message}), retrying in 250 ms...",
Color.Red); Color.Red);
Thread.Sleep(250); Thread.Sleep(250);
} }
catch (System.IO.InvalidDataException e)
{
if (logLoadErrors)
{
DebugConsole.ThrowError($"Failed to decompress file \"{savePath}\" for root extraction.", e);
}
return null;
}
} }
return null; return null;
} }
@@ -1,3 +1,9 @@
-------------------------------------------------------------------------------------------------------------------------------------------------
v1.1.18.1
-------------------------------------------------------------------------------------------------------------------------------------------------
- Fixed opening the "load game" menu crashing the game if you have any corrupted/unloadable saves in the save folder. In multiplayer, this would just prevent opening the campaign setup menu without any error messages.
------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------
v1.1.18.0 v1.1.18.0
------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------