mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-20 01:46:11 +00:00
fixup! Spawn PlayerInfo's if host is not authoritive
This commit is contained in:
1 parent
5cac18723d
commit
94f30ef87d
2 files changed
+11
-2
No files matched your search
@@ -7,11 +7,14 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
internal partial class InnerGameData : IInnerGameData
|
||||
{
|
||||
private readonly ConcurrentDictionary<byte, InnerPlayerInfo> _allPlayers = new();
|
||||
private readonly ConcurrentDictionary<int, InnerPlayerInfo> _allPlayersByClientId = new();
|
||||
|
||||
public int PlayerCount => _allPlayers.Count;
|
||||
|
||||
public IReadOnlyDictionary<byte, InnerPlayerInfo> Players => _allPlayers;
|
||||
|
||||
internal IReadOnlyDictionary<int, InnerPlayerInfo> PlayersByClientId => _allPlayersByClientId;
|
||||
|
||||
public InnerPlayerInfo? GetPlayerById(byte id)
|
||||
{
|
||||
if (id == byte.MaxValue)
|
||||
@@ -25,11 +28,17 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
internal void AddPlayer(InnerPlayerInfo playerInfo)
|
||||
{
|
||||
_allPlayers.TryAdd(playerInfo.PlayerId, playerInfo);
|
||||
_allPlayersByClientId.TryAdd(playerInfo.ClientId, playerInfo);
|
||||
}
|
||||
|
||||
internal void RemovePlayer(byte playerId)
|
||||
{
|
||||
_allPlayers.TryRemove(playerId, out _);
|
||||
_allPlayers.TryRemove(playerId, out var player);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
_allPlayersByClientId.TryRemove(player.ClientId, out _);
|
||||
}
|
||||
}
|
||||
|
||||
internal byte GetNextAvailablePlayerId()
|
||||
|
||||
@@ -474,7 +474,7 @@ namespace Impostor.Server.Net.State
|
||||
}
|
||||
|
||||
// If the host doesn't disable server authority, spawn a player info for it
|
||||
if (!IsHostAuthoritive && sender.Character == null)
|
||||
if (!IsHostAuthoritive && !GameNet.GameData.PlayersByClientId.ContainsKey(sender.Client.Id))
|
||||
{
|
||||
var playerInfo = (InnerPlayerInfo)ActivatorUtilities.CreateInstance(_serviceProvider, typeof(InnerPlayerInfo), this);
|
||||
playerInfo.SpawnFlags = SpawnFlags.None;
|
||||
|
||||
Reference in new issue
Block a user