Merge remote-tracking branch 'upstream/master' into develop

This commit is contained in:
EvilFactory
2024-06-18 12:19:13 -03:00
263 changed files with 7788 additions and 2849 deletions
@@ -18,10 +18,13 @@ namespace Barotrauma.Items.Components
private bool needsServerInitialization;
/// <summary>
/// When in multiplayer and the circuit box is loaded from the players inventory,
/// We only load the components from XML on server side since only the server has access to CharacterCampaignData
/// and then send a network event syncing the loaded properties. But circuit box properties are too complex to
/// sync using the existing syncing logic so we instead send the state using <see cref="CircuitBoxInitializeStateFromServerEvent"/>.
/// When in multiplayer and the circuit box are loaded from the player inventory,
/// We only load the components from XML on the server side
/// since only the server has access to CharacterCampaignData
/// and then send a network event syncing the loaded properties.
/// But circuit box properties are too complex to
/// sync using the existing syncing logic,
/// so we instead send the state using <see cref="CircuitBoxInitializeStateFromServerEvent"/>.
/// </summary>
public void MarkServerRequiredInitialization()
=> needsServerInitialization = true;
@@ -280,6 +283,15 @@ namespace Barotrauma.Items.Components
CreateServerEvent(data with { Size = Vector2.Max(data.Size, CircuitBoxLabelNode.MinSize) });
break;
}
case CircuitBoxOpcode.RenameConnections:
{
var data = INetSerializableStruct.Read<CircuitBoxRenameConnectionLabelsEvent>(msg);
if (!CanAccessAndUnlocked(c)) { break; }
RenameConnectionLabelsInternal(data.Type, data.Override.ToDictionary());
CreateServerEvent(data);
break;
}
default:
throw new ArgumentOutOfRangeException(nameof(header), header, "This opcode cannot be handled using entity events");
}
@@ -327,6 +339,7 @@ namespace Barotrauma.Items.Components
Components: Components.Select(EventFromComponent).ToImmutableArray(),
Wires: Wires.Select(EventFromWire).ToImmutableArray(),
Labels: Labels.Select(EventFromLabel).ToImmutableArray(),
LabelOverrides: InputOutputNodes.Select(EventFromLabelOverride).ToImmutableArray(),
InputPos: inputPos,
OutputPos: outputPos);
@@ -347,6 +360,9 @@ namespace Barotrauma.Items.Components
static CircuitBoxServerAddLabelEvent EventFromLabel(CircuitBoxLabelNode label)
=> new(label.ID, label.Position, label.Size, label.Color, label.HeaderText, label.BodyText);
static CircuitBoxRenameConnectionLabelsEvent EventFromLabelOverride(CircuitBoxInputOutputNode node)
=> new(node.NodeType, node.ConnectionLabelOverrides.ToNetDictionary());
}
// we don't care about updating the view on server
@@ -98,7 +98,7 @@ namespace Barotrauma.Items.Components
//existing wire not in the list of new wires -> disconnect it
if (!wires[i].Contains(existingWire))
{
if (existingWire.Locked)
if (existingWire.Locked || existingWire.Item.IsLayerHidden)
{
//this should not be possible unless the client is running a modified version of the game
GameServer.Log(GameServer.CharacterLogName(c.Character) + " attempted to disconnect a locked wire from " +
@@ -166,18 +166,6 @@ namespace Barotrauma.Items.Components
}
}
foreach (Wire disconnectedWire in DisconnectedWires.ToList())
{
if (disconnectedWire.Connections[0] == null &&
disconnectedWire.Connections[1] == null &&
!clientSideDisconnectedWires.Contains(disconnectedWire) &&
disconnectedWire.Item.ParentInventory == null)
{
disconnectedWire.Item.Drop(c.Character);
GameServer.Log(GameServer.CharacterLogName(c.Character) + " dropped " + disconnectedWire.Name, ServerLog.MessageType.Inventory);
}
}
//go through new wires
for (int i = 0; i < Connections.Count; i++)
{
@@ -205,6 +193,18 @@ namespace Barotrauma.Items.Components
}
}
}
foreach (Wire disconnectedWire in DisconnectedWires.ToList())
{
if (disconnectedWire.Connections[0] == null &&
disconnectedWire.Connections[1] == null &&
!clientSideDisconnectedWires.Contains(disconnectedWire) &&
disconnectedWire.Item.ParentInventory == null)
{
disconnectedWire.Item.Drop(c.Character);
GameServer.Log(GameServer.CharacterLogName(c.Character) + " dropped " + disconnectedWire.Name, ServerLog.MessageType.Inventory);
}
}
}
public void ServerEventWrite(IWriteMessage msg, Client c, NetEntityEvent.IData extraData = null)