Build 1.1.4.0
This commit is contained in:
@@ -87,6 +87,7 @@ namespace Barotrauma.Networking
|
||||
if (character != null)
|
||||
{
|
||||
HasSpawned = true;
|
||||
UsingFreeCam = false;
|
||||
#if CLIENT
|
||||
GameMain.GameSession?.CrewManager?.SetPlayerVoiceIconState(this, muted, mutedLocally);
|
||||
|
||||
@@ -100,6 +101,11 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the client using the 'freecam' console command?
|
||||
/// </summary>
|
||||
public bool UsingFreeCam;
|
||||
|
||||
public UInt16 CharacterID;
|
||||
|
||||
private Vector2 spectatePos;
|
||||
|
||||
@@ -28,28 +28,30 @@ namespace Barotrauma.Networking
|
||||
ManageMap = 0x8000,
|
||||
ManageHires = 0x10000,
|
||||
ManageBotTalents = 0x20000,
|
||||
All = 0x3FFFF
|
||||
SpamImmunity = 0x40000,
|
||||
All = 0x7FFFF
|
||||
}
|
||||
|
||||
class PermissionPreset
|
||||
{
|
||||
public static readonly List<PermissionPreset> List = new List<PermissionPreset>();
|
||||
|
||||
public readonly LocalizedString Name;
|
||||
|
||||
public readonly Identifier Identifier;
|
||||
public readonly LocalizedString DisplayName;
|
||||
public readonly LocalizedString Description;
|
||||
public readonly ClientPermissions Permissions;
|
||||
public readonly HashSet<DebugConsole.Command> PermittedCommands;
|
||||
|
||||
public PermissionPreset(XElement element)
|
||||
{
|
||||
string name = element.GetAttributeString("name", "");
|
||||
Name = TextManager.Get("permissionpresetname." + name).Fallback(name);
|
||||
Description = TextManager.Get("permissionpresetdescription." + name) .Fallback(element.GetAttributeString("description", ""));
|
||||
Identifier = element.GetAttributeIdentifier("name", Identifier.Empty);
|
||||
DisplayName = TextManager.Get("permissionpresetname." + Identifier).Fallback(Identifier.ToString());
|
||||
Description = TextManager.Get("permissionpresetdescription." + Identifier) .Fallback(element.GetAttributeString("description", ""));
|
||||
|
||||
string permissionsStr = element.GetAttributeString("permissions", "");
|
||||
if (!Enum.TryParse(permissionsStr, out Permissions))
|
||||
{
|
||||
DebugConsole.ThrowError("Error in permission preset \"" + Name + "\" - " + permissionsStr + " is not a valid permission!");
|
||||
DebugConsole.ThrowError("Error in permission preset \"" + DisplayName + "\" - " + permissionsStr + " is not a valid permission!");
|
||||
}
|
||||
|
||||
PermittedCommands = new HashSet<DebugConsole.Command>();
|
||||
@@ -64,7 +66,7 @@ namespace Barotrauma.Networking
|
||||
if (command == null)
|
||||
{
|
||||
#if SERVER
|
||||
DebugConsole.ThrowError("Error in permission preset \"" + Name + "\" - " + commandName + "\" is not a valid console command.");
|
||||
DebugConsole.ThrowError("Error in permission preset \"" + DisplayName + "\" - " + commandName + "\" is not a valid console command.");
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -348,12 +348,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
private static T? ReadNullable<T>(IReadMessage inc, NetworkSerialize attribute, ReadOnlyBitField bitField) where T : struct =>
|
||||
ReadOption<T>(inc, attribute, bitField) switch
|
||||
{
|
||||
Some<T> { Value: var value } => value,
|
||||
None<T> _ => null,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
ReadOption<T>(inc, attribute, bitField).TryUnwrap(out var value) ? value : null;
|
||||
|
||||
private static void WriteNullable<T>(T? value, NetworkSerialize attribute, IWriteMessage msg, WriteOnlyBitField bitField) where T : struct =>
|
||||
WriteOption<T>(value.HasValue ? Option<T>.Some(value.Value) : Option<T>.None(), attribute, msg, bitField);
|
||||
@@ -378,7 +373,7 @@ namespace Barotrauma
|
||||
{
|
||||
ToolBox.ThrowIfNull(option);
|
||||
|
||||
if (option.TryUnwrap(out T value))
|
||||
if (option.TryUnwrap(out T? value))
|
||||
{
|
||||
bitField.WriteBoolean(true);
|
||||
if (TryFindBehavior(out ReadWriteBehavior<T> behavior))
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Barotrauma.Networking
|
||||
/// </summary>
|
||||
public OrderChatMessage(Order order, Character targetCharacter, Character sender, bool isNewOrder = true)
|
||||
: this(order,
|
||||
order?.GetChatMessage(targetCharacter?.Name, sender?.CurrentHull?.DisplayName?.Value, givingOrderToSelf: targetCharacter == sender, orderOption: order.Option, isNewOrder: isNewOrder),
|
||||
order?.GetChatMessage(targetCharacter?.Name, (order.TargetEntity as Hull ?? sender?.CurrentHull)?.DisplayName?.Value, givingOrderToSelf: targetCharacter == sender, orderOption: order.Option, isNewOrder: isNewOrder),
|
||||
targetCharacter, sender, isNewOrder)
|
||||
{
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Barotrauma.Networking
|
||||
WriteOrder(msg, Order, TargetCharacter, IsNewOrder);
|
||||
}
|
||||
|
||||
public struct OrderMessageInfo
|
||||
public readonly struct OrderMessageInfo
|
||||
{
|
||||
public Identifier OrderIdentifier { get; }
|
||||
public OrderPrefab OrderPrefab => OrderPrefab.Prefabs[OrderIdentifier];
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace Barotrauma.Networking
|
||||
ServerMessage,
|
||||
ConsoleUsage,
|
||||
Money,
|
||||
DoSProtection,
|
||||
Karma,
|
||||
Talent,
|
||||
Error,
|
||||
@@ -55,6 +56,7 @@ namespace Barotrauma.Networking
|
||||
{ MessageType.ServerMessage, new Color(157, 225, 160) },
|
||||
{ MessageType.ConsoleUsage, new Color(0, 162, 232) },
|
||||
{ MessageType.Money, Color.Green },
|
||||
{ MessageType.DoSProtection, Color.OrangeRed },
|
||||
{ MessageType.Karma, new Color(75, 88, 255) },
|
||||
{ MessageType.Talent, new Color(125, 125, 255) },
|
||||
{ MessageType.Error, Color.Red }
|
||||
@@ -71,6 +73,7 @@ namespace Barotrauma.Networking
|
||||
{ MessageType.ServerMessage, "ServerMessage" },
|
||||
{ MessageType.ConsoleUsage, "ConsoleUsage" },
|
||||
{ MessageType.Money, "Money" },
|
||||
{ MessageType.DoSProtection, "DoSProtection" },
|
||||
{ MessageType.Karma, "Karma" },
|
||||
{ MessageType.Talent, "Talent" },
|
||||
{ MessageType.Error, "Error" }
|
||||
|
||||
@@ -42,6 +42,11 @@ namespace Barotrauma.Networking
|
||||
|
||||
partial class ServerSettings : ISerializableEntity
|
||||
{
|
||||
public const int PacketLimitMin = 1200,
|
||||
PacketLimitWarning = 2400,
|
||||
PacketLimitDefault = 2400,
|
||||
PacketLimitMax = 10000;
|
||||
|
||||
public const string SettingsFile = "serversettings.xml";
|
||||
|
||||
[Flags]
|
||||
@@ -111,27 +116,24 @@ namespace Barotrauma.Networking
|
||||
switch (typeString)
|
||||
{
|
||||
case "float":
|
||||
if (!(a is float?)) return false;
|
||||
if (!(b is float?)) return false;
|
||||
return MathUtils.NearlyEqual((float)a, (float)b);
|
||||
if (a is not float fa) { return false; }
|
||||
if (b is not float fb) { return false; }
|
||||
return MathUtils.NearlyEqual(fa, fb);
|
||||
case "int":
|
||||
if (!(a is int?)) return false;
|
||||
if (!(b is int?)) return false;
|
||||
return (int)a == (int)b;
|
||||
if (a is not int ia) { return false; }
|
||||
if (b is not int ib) { return false; }
|
||||
return ia == ib;
|
||||
case "bool":
|
||||
if (!(a is bool?)) return false;
|
||||
if (!(b is bool?)) return false;
|
||||
return (bool)a == (bool)b;
|
||||
if (a is not bool ba) { return false; }
|
||||
if (b is not bool bb) { return false; }
|
||||
return ba == bb;
|
||||
case "Enum":
|
||||
if (!(a is Enum)) return false;
|
||||
if (!(b is Enum)) return false;
|
||||
return ((Enum)a).Equals((Enum)b);
|
||||
if (a is not Enum ea) { return false; }
|
||||
if (b is not Enum eb) { return false; }
|
||||
return ea.Equals(eb);
|
||||
default:
|
||||
if (a == null || b == null)
|
||||
{
|
||||
return (a == null) == (b == null);
|
||||
}
|
||||
return a.ToString().Equals(b.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||
return ReferenceEquals(a,b)
|
||||
|| string.Equals(a?.ToString(), b?.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +206,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
public void Write(IWriteMessage msg, object overrideValue = null)
|
||||
{
|
||||
if (overrideValue == null) { overrideValue = Value; }
|
||||
overrideValue ??= Value;
|
||||
switch (typeString)
|
||||
{
|
||||
case "float":
|
||||
@@ -293,10 +295,7 @@ namespace Barotrauma.Networking
|
||||
var saveProperties = SerializableProperty.GetProperties<Serialize>(this);
|
||||
foreach (var property in saveProperties)
|
||||
{
|
||||
object value = property.GetValue(this);
|
||||
if (value == null) { continue; }
|
||||
|
||||
string typeName = SerializableProperty.GetSupportedTypeName(value.GetType());
|
||||
string typeName = SerializableProperty.GetSupportedTypeName(property.PropertyType);
|
||||
if (typeName != null || property.PropertyType.IsEnum)
|
||||
{
|
||||
NetPropertyData netPropertyData = new NetPropertyData(this, property, typeName);
|
||||
@@ -523,7 +522,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize(LosMode.Opaque, IsPropertySaveable.Yes)]
|
||||
[Serialize(LosMode.Transparent, IsPropertySaveable.Yes)]
|
||||
public LosMode LosMode
|
||||
{
|
||||
get;
|
||||
@@ -694,6 +693,20 @@ namespace Barotrauma.Networking
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(true, IsPropertySaveable.Yes)]
|
||||
public bool EnableDoSProtection
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(PacketLimitDefault, IsPropertySaveable.Yes)]
|
||||
public int MaxPacketAmount
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
public string SelectedSubmarine
|
||||
{
|
||||
@@ -754,6 +767,9 @@ namespace Barotrauma.Networking
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(defaultValue: "", IsPropertySaveable.Yes)]
|
||||
public LanguageIdentifier Language { get; set; }
|
||||
|
||||
private SelectionMode subSelectionMode;
|
||||
[Serialize(SelectionMode.Manual, IsPropertySaveable.Yes)]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Barotrauma.Networking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
|
||||
Reference in New Issue
Block a user