Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaServer/Source/Networking/Client.cs
T
Joonas Rikkonen 27917ee376 7b471b5...483f2ad
commit 483f2ad4fd9d91b9763d25df592a899cdf39ba67
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Sun Mar 24 19:19:01 2019 +0200

    Instead of making coilgun bolts continuously deteriorate to give them a lifetime of 5 seconds, simply create a delayed status effect that removes them after 5 seconds of being launched.

commit 00b8d48d4d1d933e76a6c0d7df5320c50dc0a07d
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Sun Mar 24 19:16:40 2019 +0200

    Wait at least 0.15 seconds before creating a new condition update event for an item. Some rapidly deteriorating items (e.g. coilgun bolt, faraday artifacts) would otherwise cause new events to be created at an excessively high rate.

commit 84e6948a4898dd040b2a84eb5f1ad97c20dfc69f
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Sun Mar 24 19:14:58 2019 +0200

    Server can send multiple network event packets per update if there's too many events to fit in one packet (up to 4 packets per update).

commit 40797e91d67f965ac6d292367fef5386214abbdb
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Sun Mar 24 17:34:49 2019 +0200

    NetEntityEvent changes:
    - Don't restrict the number of events per message, but instead write as many events as the packet can fit (up to a maximum of 1024 bytes to leave some space for other types of data (event IDs, chat messages and such)).
    - Decrease the delay after which events can be resent (RTT * 1.5 -> RTT).

commit bfefbb5d7da3ce6a5fe9cb7ff733ec5df37a8a15
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Sun Mar 24 14:31:03 2019 +0200

    Fixed FixDurationLowSkill & FixDurationHighSkill parameters in Repairable being case-sensitive, causing almost none of the xml values to be used. + Moved client-specific repairable methods to the client project, and server-specific to the server project.

commit 311f67c6c6b8d2cd9f4f4ca820e42316938c4f17
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Sun Mar 24 14:09:10 2019 +0200

    Fixed "trying to add a dead character to crewmanager" errors when attempting to revive a character killed by some other affliction than internal damage, bleeding or burns. Closes #1341
2019-03-24 19:21:41 +02:00

173 lines
5.6 KiB
C#

using Lidgren.Network;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma.Networking
{
partial class Client : IDisposable
{
public ulong SteamID;
public bool VoiceEnabled = true;
public UInt16 LastRecvClientListUpdate = 0;
public UInt16 LastRecvLobbyUpdate = 0;
public UInt16 LastSentChatMsgID = 0; //last msg this client said
public UInt16 LastRecvChatMsgID = 0; //last msg this client knows about
public UInt16 LastSentEntityEventID = 0;
public UInt16 LastRecvEntityEventID = 0;
public UInt16 LastRecvCampaignUpdate = 0;
public UInt16 LastRecvCampaignSave = 0;
public Pair<UInt16, float> LastCampaignSaveSendTime;
public readonly List<ChatMessage> ChatMsgQueue = new List<ChatMessage>();
public UInt16 LastChatMsgQueueID;
//latest chat messages sent by this client
public readonly List<string> LastSentChatMessages = new List<string>();
public float ChatSpamSpeed;
public float ChatSpamTimer;
public int ChatSpamCount;
public float KickAFKTimer;
public double MidRoundSyncTimeOut;
public bool NeedsMidRoundSync;
//how many unique events the client missed before joining the server
public UInt16 UnreceivedEntityEventCount;
public UInt16 FirstNewEventID;
//when was a specific entity event last sent to the client
// key = event id, value = NetTime.Now when sending
public readonly Dictionary<UInt16, double> EntityEventLastSent = new Dictionary<UInt16, double>();
//when was a position update for a given entity last sent to the client
// key = entity id, value = NetTime.Now when sending
public readonly Dictionary<UInt16, float> PositionUpdateLastSent = new Dictionary<UInt16, float>();
public readonly Queue<Entity> PendingPositionUpdates = new Queue<Entity>();
public bool ReadyToStart;
public List<JobPrefab> JobPreferences;
public JobPrefab AssignedJob;
public float DeleteDisconnectedTimer;
public CharacterInfo CharacterInfo;
public NetConnection Connection { get; set; }
public bool SpectateOnly;
private float karma = 1.0f;
public float Karma
{
get
{
if (GameMain.Server == null) return 1.0f;
if (!GameMain.Server.ServerSettings.KarmaEnabled) return 1.0f;
return karma;
}
set
{
if (GameMain.Server == null) return;
if (!GameMain.Server.ServerSettings.KarmaEnabled) return;
karma = Math.Min(Math.Max(value, 0.0f), 1.0f);
}
}
partial void InitProjSpecific()
{
JobPreferences = new List<JobPrefab>(JobPrefab.List.GetRange(0, Math.Min(JobPrefab.List.Count, 3)));
VoipQueue = new VoipQueue(ID, true, true);
GameMain.Server.VoipServer.RegisterQueue(VoipQueue);
}
partial void DisposeProjSpecific()
{
GameMain.Server.VoipServer.UnregisterQueue(VoipQueue);
VoipQueue.Dispose();
}
public void InitClientSync()
{
LastSentChatMsgID = 0;
LastRecvChatMsgID = ChatMessage.LastID;
LastRecvLobbyUpdate = 0;
LastRecvEntityEventID = 0;
UnreceivedEntityEventCount = 0;
NeedsMidRoundSync = false;
}
public static bool IsValidName(string name, GameServer server)
{
char[] disallowedChars = new char[] { ';', ',', '<', '>', '/', '\\', '[', ']', '"', '?' };
if (name.Any(c => disallowedChars.Contains(c))) return false;
foreach (char character in name)
{
if (!server.ServerSettings.AllowedClientNameChars.Any(charRange => (int)character >= charRange.First && (int)character <= charRange.Second)) return false;
}
return true;
}
public bool IPMatches(string ip)
{
if (Connection?.RemoteEndPoint == null) { return false; }
if (Connection.RemoteEndPoint.Address.IsIPv4MappedToIPv6 &&
Connection.RemoteEndPoint.Address.MapToIPv4().ToString() == ip)
{
return true;
}
return Connection.RemoteEndPoint.Address.ToString() == ip;
}
public void SetPermissions(ClientPermissions permissions, List<DebugConsole.Command> permittedConsoleCommands)
{
this.Permissions = permissions;
this.PermittedConsoleCommands = new List<DebugConsole.Command>(permittedConsoleCommands);
}
public void GivePermission(ClientPermissions permission)
{
if (!this.Permissions.HasFlag(permission)) this.Permissions |= permission;
}
public void RemovePermission(ClientPermissions permission)
{
if (this.Permissions.HasFlag(permission)) this.Permissions &= ~permission;
}
public bool HasPermission(ClientPermissions permission)
{
return this.Permissions.HasFlag(permission);
}
public static string SanitizeName(string name)
{
name = name.Trim();
if (name.Length > 20)
{
name = name.Substring(0, 20);
}
string rName = "";
for (int i = 0; i < name.Length; i++)
{
rName += name[i] < 32 ? '?' : name[i];
}
return rName;
}
}
}