Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop

This commit is contained in:
EvilFactory
2023-01-31 13:17:15 -03:00
232 changed files with 4481 additions and 2283 deletions
@@ -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; }
@@ -306,12 +336,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);
@@ -409,11 +435,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)