diff --git a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/ConfigService.cs b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/ConfigService.cs index ab00224e5..b9de7b917 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/ConfigService.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/ConfigService.cs @@ -7,7 +7,7 @@ using FluentResults; namespace Barotrauma.LuaCs.Services; -public partial class ConfigService +public sealed partial class ConfigService { public ImmutableArray GetDisplayableConfigs() { diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Configuration/SettingEntry.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Configuration/SettingEntry.cs index 37d7d5e9f..4c1193e2d 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Configuration/SettingEntry.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Configuration/SettingEntry.cs @@ -73,12 +73,12 @@ public class SettingEntry : ISettingEntry where T : IEquatable public Guid InstanceId { get; } public NetSync SyncType { get; } public ClientPermissions WritePermissions { get; } - public void ReadNetMessage(INetReadMessage message) + public void ReadNetMessage(IReadMessage message) { throw new NotImplementedException(); } - public void WriteNetMessage(INetWriteMessage message) + public void WriteNetMessage(IWriteMessage message) { throw new NotImplementedException(); } diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Networking/INetworkSyncEntity.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Networking/INetworkSyncEntity.cs index e0cb5713d..3a93e787b 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Networking/INetworkSyncEntity.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Networking/INetworkSyncEntity.cs @@ -28,14 +28,14 @@ public interface INetworkSyncEntity /// machine. /// /// Wrapper for the internal type: - void ReadNetMessage(INetReadMessage message); + void ReadNetMessage(IReadMessage message); /// /// Called when a network send-event involving this entity is triggered. Any data expected to be read by the recipient /// network object on the other instance(s) should be written to the packet. /// /// Wrapper for the internal type: - void WriteNetMessage(INetWriteMessage message); + void WriteNetMessage(IWriteMessage message); } /// diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Networking/NetInterfaceCompat.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Networking/NetInterfaceCompat.cs deleted file mode 100644 index 161bf3e1c..000000000 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Networking/NetInterfaceCompat.cs +++ /dev/null @@ -1,161 +0,0 @@ -using Barotrauma.Networking; -using Microsoft.Xna.Framework; - -namespace Barotrauma.LuaCs.Services; - -#region Wrapper-IWriteMessage - -/// -/// Literally just exists because Barotrauma.IWriteMessage is internal only. -/// -public interface INetWriteMessage -{ - internal IWriteMessage Message { get; } - internal INetWriteMessage SetMessage(IWriteMessage msg); - - void WriteBoolean(bool val) => Message.WriteBoolean(val); - - void WritePadBits() => Message.WritePadBits(); - - void WriteByte(byte val) => Message.WriteByte(val); - - void WriteInt16(short val) => Message.WriteInt16(val); - - void WriteUInt16(ushort val) => Message.WriteUInt16(val); - - void WriteInt32(int val) => Message.WriteInt32(val); - - void WriteUInt32(uint val) => Message.WriteUInt32(val); - - void WriteInt64(long val) => Message.WriteInt64(val); - - void WriteUInt64(ulong val) => Message.WriteUInt64(val); - - void WriteSingle(float val) => Message.WriteSingle(val); - - void WriteDouble(double val) => Message.WriteDouble(val); - - void WriteColorR8G8B8(Color val) => Message.WriteColorR8G8B8(val); - - void WriteColorR8G8B8A8(Color val) => Message.WriteColorR8G8B8A8(val); - - void WriteVariableUInt32(uint val) => Message.WriteVariableUInt32(val); - - void WriteString(string val) => Message.WriteString(val); - - void WriteIdentifier(Identifier val) => Message.WriteIdentifier(val); - - void WriteRangedInteger(int val, int min, int max) => Message.WriteRangedInteger(val, min, max); - - void WriteRangedSingle(float val, float min, float max, int bitCount) => - Message.WriteRangedSingle(val, min, max, bitCount); - - void WriteBytes(byte[] val, int startIndex, int length) => Message.WriteBytes(val, startIndex, length); - - byte[] PrepareForSending(bool compressPastThreshold, out bool isCompressed, out int outLength) => - Message.PrepareForSending(compressPastThreshold, out isCompressed, out outLength); - - int BitPosition - { - get => Message.BitPosition; - set => Message.BitPosition = value; - } - - int BytePosition => Message.BytePosition; - - byte[] Buffer => Message.Buffer; - - int LengthBits - { - get => Message.LengthBits; - set => Message.LengthBits = value; - } - - int LengthBytes => Message.LengthBytes; -} - -#endregion - -#region Wrapper-IReadMessage - -/// -/// Literally just exists because Barotrauma.IReadMessage is internal only. -/// -public interface INetReadMessage -{ - internal IReadMessage Message { get; } - internal INetReadMessage SetMessage(IReadMessage msg); - - bool ReadBoolean() => Message.ReadBoolean(); - void ReadPadBits() => Message.ReadPadBits(); - byte ReadByte() => Message.ReadByte(); - byte PeekByte() => Message.PeekByte(); - ushort ReadUInt16() => Message.ReadUInt16(); - short ReadInt16() => Message.ReadInt16(); - uint ReadUInt32() => Message.ReadUInt32(); - int ReadInt32() => Message.ReadInt32(); - ulong ReadUInt64() => Message.ReadUInt64(); - long ReadInt64() => Message.ReadInt64(); - float ReadSingle() => Message.ReadSingle(); - double ReadDouble() => Message.ReadDouble(); - uint ReadVariableUInt32() => Message.ReadVariableUInt32(); - string ReadString() => Message.ReadString(); - Identifier ReadIdentifier() => Message.ReadIdentifier(); - Color ReadColorR8G8B8() => Message.ReadColorR8G8B8(); - Color ReadColorR8G8B8A8() => Message.ReadColorR8G8B8A8(); - int ReadRangedInteger(int min, int max) => Message.ReadRangedInteger(min, max); - float ReadRangedSingle(float min, float max, int bitCount) => Message.ReadRangedSingle(min, max, bitCount); - byte[] ReadBytes(int numberOfBytes) => Message.ReadBytes(numberOfBytes); - int BitPosition - { - get => Message.BitPosition; - set => Message.BitPosition = value; - } - int BytePosition => Message.BytePosition; - byte[] Buffer => Message.Buffer; - int LengthBits - { - get => Message.LengthBits; - set => Message.LengthBits = value; - } - int LengthBytes => Message.LengthBytes; -} - -#endregion - -#region HelperImplementations - -public class NetWriteMessage : INetWriteMessage -{ - private IWriteMessage Message { get; set; } - - IWriteMessage INetWriteMessage.Message => Message; - - INetWriteMessage INetWriteMessage.SetMessage(IWriteMessage msg) - { - Message = msg; - return this; - } -} - -internal static class NetHelperExtensions -{ - internal static INetWriteMessage ToNetWriteMessage(this IWriteMessage msg) => - ((INetWriteMessage)new NetWriteMessage()).SetMessage(msg); - internal static INetReadMessage ToNetReadMessage(this IReadMessage msg) => - ((INetReadMessage)new NetReadMessage()).SetMessage(msg); -} - -public class NetReadMessage : INetReadMessage -{ - private IReadMessage Message { get; set; } - IReadMessage INetReadMessage.Message => Message; - - INetReadMessage INetReadMessage.SetMessage(IReadMessage msg) - { - Message = msg; - return this; - } -} - -#endregion diff --git a/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/AccountInfo.cs b/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/AccountInfo.cs index 5ef184891..1c9ff1907 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/AccountInfo.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/AccountInfo.cs @@ -5,7 +5,7 @@ using System.Linq; namespace Barotrauma.Networking { [NetworkSerialize] - readonly struct AccountInfo : INetSerializableStruct + public readonly struct AccountInfo : INetSerializableStruct { public static readonly AccountInfo None = new AccountInfo(Option.None()); @@ -48,4 +48,4 @@ namespace Barotrauma.Networking public static bool operator !=(AccountInfo a, AccountInfo b) => !(a == b); } -} \ No newline at end of file +} diff --git a/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Endpoint/Endpoint.cs b/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Endpoint/Endpoint.cs index f1599e654..ad6ef6e00 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Endpoint/Endpoint.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Endpoint/Endpoint.cs @@ -2,7 +2,7 @@ namespace Barotrauma.Networking { - abstract class Endpoint + public abstract class Endpoint { public abstract string StringRepresentation { get; } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Message/IReadMessage.cs b/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Message/IReadMessage.cs index 2bfc7eec4..6259e7678 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Message/IReadMessage.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Message/IReadMessage.cs @@ -4,7 +4,7 @@ using System.Text; namespace Barotrauma.Networking { - interface IReadMessage + public interface IReadMessage { bool ReadBoolean(); void ReadPadBits(); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Message/IWriteMessage.cs b/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Message/IWriteMessage.cs index b5721153d..47580b4bb 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Message/IWriteMessage.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/Message/IWriteMessage.cs @@ -2,7 +2,7 @@ namespace Barotrauma.Networking { - interface IWriteMessage + public interface IWriteMessage { void WriteBoolean(bool val); void WritePadBits(); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/NetworkConnection/NetworkConnection.cs b/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/NetworkConnection/NetworkConnection.cs index 040321b59..2189a166a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/NetworkConnection/NetworkConnection.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Networking/Primitives/NetworkConnection/NetworkConnection.cs @@ -8,14 +8,14 @@ namespace Barotrauma.Networking Disconnected = 0x2 } - abstract class NetworkConnection : NetworkConnection where T : Endpoint + public abstract class NetworkConnection : NetworkConnection where T : Endpoint { protected NetworkConnection(T endpoint) : base(endpoint) { } public new T Endpoint => (base.Endpoint as T)!; } - abstract class NetworkConnection + public abstract class NetworkConnection { public static double TimeoutThresholdNotInGame => GameMain.NetworkMember?.ServerSettings?.TimeoutThresholdNotInGame ?? 60.0; //full minute for timeout because loading screens can take quite a while public static double TimeoutThresholdInGame => GameMain.NetworkMember?.ServerSettings?.TimeoutThresholdInGame ?? 10.0;