Build 0.21.6.0 (1.0 pre-patch)
This commit is contained in:
@@ -14,6 +14,13 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public bool Discarded;
|
||||
|
||||
public void ApplyDeathEffects()
|
||||
{
|
||||
RespawnManager.ReduceCharacterSkills(this);
|
||||
RemoveSavedStatValuesOnDeath();
|
||||
CauseOfDeath = null;
|
||||
}
|
||||
|
||||
partial void OnSkillChanged(Identifier skillIdentifier, float prevLevel, float newLevel)
|
||||
{
|
||||
if (Character == null || Character.Removed) { return; }
|
||||
|
||||
@@ -8,8 +8,9 @@ namespace Barotrauma
|
||||
{
|
||||
partial class Character
|
||||
{
|
||||
public Address OwnerClientAddress;
|
||||
public string OwnerClientName;
|
||||
private Address ownerClientAddress;
|
||||
private Option<AccountId> ownerClientAccountId;
|
||||
|
||||
public bool ClientDisconnected;
|
||||
public float KillDisconnectedTimer;
|
||||
|
||||
@@ -19,6 +20,35 @@ namespace Barotrauma
|
||||
|
||||
public bool HealthUpdatePending;
|
||||
|
||||
public void SetOwnerClient(Client client)
|
||||
{
|
||||
if (client == null)
|
||||
{
|
||||
ownerClientAddress = null;
|
||||
ownerClientAccountId = Option<AccountId>.None();
|
||||
IsRemotePlayer = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ownerClientAddress = client.Connection.Endpoint.Address;
|
||||
ownerClientAccountId = client.AccountId;
|
||||
IsRemotePlayer = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsClientOwner(Client client)
|
||||
{
|
||||
if (ownerClientAccountId.TryUnwrap(out var accountId)
|
||||
&& client.AccountId.TryUnwrap(out var clientId))
|
||||
{
|
||||
return accountId == clientId;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ownerClientAddress == client.Connection.Endpoint.Address;
|
||||
}
|
||||
}
|
||||
|
||||
public float GetPositionUpdateInterval(Client recipient)
|
||||
{
|
||||
if (!Enabled) { return 1000.0f; }
|
||||
@@ -302,12 +332,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void ServerWritePosition(IWriteMessage msg, Client c)
|
||||
public void ServerWritePosition(ReadWriteMessage tempBuffer, Client c)
|
||||
{
|
||||
msg.WriteUInt16(ID);
|
||||
|
||||
IWriteMessage tempBuffer = new WriteOnlyMessage();
|
||||
|
||||
if (this == c.Character)
|
||||
{
|
||||
tempBuffer.WriteBoolean(true);
|
||||
@@ -405,11 +431,6 @@ namespace Barotrauma
|
||||
AIController?.ServerWrite(tempBuffer);
|
||||
HealthUpdatePending = false;
|
||||
}
|
||||
|
||||
tempBuffer.WritePadBits();
|
||||
|
||||
msg.WriteVariableUInt32((uint)tempBuffer.LengthBytes);
|
||||
msg.WriteBytes(tempBuffer.Buffer, 0, tempBuffer.LengthBytes);
|
||||
}
|
||||
|
||||
public virtual void ServerEventWrite(IWriteMessage msg, Client c, NetEntityEvent.IData extraData = null)
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
internal static class HealingCooldown
|
||||
{
|
||||
private static readonly Dictionary<Client, DateTimeOffset> HealingCooldowns = new();
|
||||
|
||||
// Little bit less than client's 0.5 second cooldown to account for latency
|
||||
private const float CooldownDuration = 0.4f;
|
||||
|
||||
public static bool IsOnCooldown(Client client)
|
||||
{
|
||||
RemoveExpiredCooldowns();
|
||||
return HealingCooldowns.ContainsKey(client);
|
||||
}
|
||||
|
||||
public static void SetCooldown(Client client)
|
||||
{
|
||||
RemoveExpiredCooldowns();
|
||||
DateTimeOffset newCooldown = DateTimeOffset.UtcNow.AddSeconds(CooldownDuration);
|
||||
HealingCooldowns[client] = newCooldown;
|
||||
}
|
||||
|
||||
private static void RemoveExpiredCooldowns()
|
||||
{
|
||||
HashSet<Client>? expiredCooldowns = null;
|
||||
|
||||
DateTimeOffset now = DateTimeOffset.UtcNow;
|
||||
|
||||
foreach (var (client, cooldown) in HealingCooldowns)
|
||||
{
|
||||
if (now < cooldown) { continue; }
|
||||
|
||||
expiredCooldowns ??= new HashSet<Client>();
|
||||
expiredCooldowns.Add(client);
|
||||
}
|
||||
|
||||
if (expiredCooldowns is null) { return; }
|
||||
|
||||
foreach (Client expiredCooldown in expiredCooldowns)
|
||||
{
|
||||
HealingCooldowns.Remove(expiredCooldown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user