remove ValidatePlayers

This commit is contained in:
Mister_Nebula 2022-08-24 08:20:43 +01:00
parent ca42319262
commit 0495e256b3
2 changed files with 0 additions and 66 deletions

View File

@ -126,68 +126,4 @@ public static class QSBPlayerManager
public static IEnumerable<(PlayerInfo Player, IQSBItem HeldItem)> GetPlayerCarryItems()
=> PlayerList.Select(x => (x, x.HeldItem));
private static Dictionary<int, PlayerInfo> _connectionIdToPlayer = new();
public static IEnumerator ValidatePlayers()
{
// BUG: this does not work. try using a ping (heartbeat) message to detect whether the player actually exists. if they dont, kick the player.
while (true)
{
if (QSBCore.IsInMultiplayer && QSBCore.IsHost)
{
_connectionIdToPlayer.Clear();
var playersToRemove = new List<PlayerInfo>();
foreach (var player in PlayerList)
{
var transformSync = player.TransformSync;
if (transformSync == null)
{
DebugLog.ToConsole($"Error - {player.PlayerId}'s TransformSync is null.", MessageType.Error);
playersToRemove.Add(player);
continue;
}
var networkIdentity = transformSync.netIdentity;
if (networkIdentity == null)
{
DebugLog.ToConsole($"Error - {player.PlayerId}'s TransformSync's NetworkIdentity is null.", MessageType.Error);
playersToRemove.Add(player);
continue;
}
var connectionToClient = networkIdentity.connectionToClient;
if (_connectionIdToPlayer.ContainsKey(connectionToClient.connectionId))
{
// oh god oh fuck
DebugLog.ToConsole($"Error - {player.PlayerId}'s connectionToClient.connectionId is already being used?!?", MessageType.Error);
playersToRemove.Add(player);
continue;
}
_connectionIdToPlayer.Add(connectionToClient.connectionId, player);
}
if (playersToRemove.Count != 0)
{
DebugLog.DebugWrite($"Removing {playersToRemove.Count} invalid players.", MessageType.Success);
foreach (var player in playersToRemove)
{
OnRemovePlayer?.Invoke(player);
player.HudMarker?.Remove();
PlayerList.Remove(player);
DebugLog.DebugWrite($"Remove Invalid Player : {player}", MessageType.Info);
}
}
}
yield return new WaitForSecondsRealtime(5);
}
}
}

View File

@ -188,8 +188,6 @@ public class QSBCore : ModBehaviour
QSBWorldSync.Managers = components.OfType<WorldObjectManager>().ToArray();
QSBPatchManager.OnPatchType += OnPatchType;
QSBPatchManager.OnUnpatchType += OnUnpatchType;
StartCoroutine(QSBPlayerManager.ValidatePlayers());
}
private static void OnPatchType(QSBPatchTypes type)