From a5a09aa664162e65c6d7e880aa1ee0cddd7fec20 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 6 Aug 2018 15:48:47 +0300 Subject: [PATCH] Fixed OwnerClientName & OwnerClientIP not being set on respawned characters. The characters of clients who aren't in-game 30 seconds after a round starts are treated as disconnected, making it possible for the client to gain control of the character if they do manage to connect. Closes #583, #584 --- Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs | 5 ++--- .../BarotraumaShared/Source/Networking/RespawnManager.cs | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs index d95c18533..3d8252623 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs @@ -872,11 +872,10 @@ namespace Barotrauma.Networking else { //if 30 seconds have passed since the round started and the client isn't ingame yet, - //kill the client's character + //consider the client's character disconnected (causing it to die if the client does not join soon) if (gameStarted && c.Character != null && (DateTime.Now - roundStartTime).Seconds > 30.0f) { - c.Character.Kill(CauseOfDeath.Disconnected); - c.Character = null; + c.Character.ClientDisconnected = true; } ClientWriteLobby(c); diff --git a/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs b/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs index f5a526544..227e86c83 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs @@ -519,6 +519,8 @@ namespace Barotrauma.Networking { #endif clients[i].Character = character; + character.OwnerClientIP = clients[i].Connection.RemoteEndPoint.Address.ToString(); + character.OwnerClientName = clients[i].Name; GameServer.Log(string.Format("Respawning {0} ({1}) as {2}", clients[i].Name, clients[i].Connection?.RemoteEndPoint?.Address, characterInfos[i].Job.Name), ServerLog.MessageType.Spawning); #if CLIENT