Files
Eero caec44c57d Fix concurrent access issues with ConnectedClients
Replaced direct access to GameMain.Server.ConnectedClients with array snapshots in multiple server-side classes to prevent concurrent modification issues during parallel updates. Also updated PhysicsBody and LevelTrigger to avoid static/shared state in parallel contexts, improving thread safety and reliability.
2026-01-08 00:26:29 +08:00

29 lines
965 B
C#

using Barotrauma.Networking;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma
{
partial class StatusEffectAction : EventAction
{
private void ServerWrite(IEnumerable<Entity> targets)
{
IWriteMessage outmsg = new WriteOnlyMessage();
outmsg.WriteByte((byte)ServerPacketHeader.EVENTACTION);
outmsg.WriteByte((byte)EventManager.NetworkEventType.STATUSEFFECT);
outmsg.WriteIdentifier(ParentEvent.Prefab.Identifier);
outmsg.WriteUInt16((UInt16)actionIndex);
outmsg.WriteUInt16((UInt16)targets.Count());
foreach (Entity target in targets)
{
outmsg.WriteUInt16(target.ID);
}
foreach (Client c in GameMain.Server.ConnectedClients)
{
GameMain.Server.ServerPeer?.Send(outmsg, c.Connection, DeliveryMethod.Reliable);
}
}
}
}