From bc0ec6c0501123fde2ff71a1498de5810cb13beb Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 5 Apr 2023 23:10:40 -0500 Subject: [PATCH] track private slots for webfront overview --- Application/IW4MServer.cs | 16 ++++++++++------ SharedLibraryCore/Dtos/ServerInfo.cs | 1 + SharedLibraryCore/Interfaces/IGameServer.cs | 5 +++++ SharedLibraryCore/Server.cs | 1 + WebfrontCore/Controllers/ServerController.cs | 1 + .../ViewComponents/ServerListViewComponent.cs | 1 + WebfrontCore/Views/Server/_Server.cshtml | 2 +- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index dc0a5c7ce..9f13a5a3a 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -1342,6 +1342,8 @@ namespace IW4MAdmin var logsync = await this.GetMappedDvarValueOrDefaultAsync("g_logsync", token: Manager.CancellationToken); var ip = await this.GetMappedDvarValueOrDefaultAsync("net_ip", token: Manager.CancellationToken); var gamePassword = await this.GetMappedDvarValueOrDefaultAsync("g_password", overrideDefault: "", token: Manager.CancellationToken); + var privateClients = await this.GetMappedDvarValueOrDefaultAsync("sv_privateClients", overrideDefault: 0, + token: Manager.CancellationToken); if (Manager.GetApplicationSettings().Configuration().EnableCustomSayName) { @@ -1383,12 +1385,14 @@ namespace IW4MAdmin } WorkingDirectory = basepath.Value; - this.Hostname = hostname; - this.MaxClients = maxplayers; - this.FSGame = game.Value; - this.Gametype = gametype; - this.IP = ip.Value is "localhost" or "0.0.0.0" ? ServerConfig.IPAddress : ip.Value ?? ServerConfig.IPAddress; - this.GamePassword = gamePassword.Value; + Hostname = hostname; + MaxClients = maxplayers; + FSGame = game.Value; + Gametype = gametype; + IP = ip.Value is "localhost" or "0.0.0.0" ? ServerConfig.IPAddress : ip.Value ?? ServerConfig.IPAddress; + GamePassword = gamePassword.Value; + PrivateClientSlots = privateClients.Value; + UpdateMap(mapname); if (RconParser.CanGenerateLogPath && string.IsNullOrEmpty(ServerConfig.ManualLogPath)) diff --git a/SharedLibraryCore/Dtos/ServerInfo.cs b/SharedLibraryCore/Dtos/ServerInfo.cs index e621bef5e..5b4c304c9 100644 --- a/SharedLibraryCore/Dtos/ServerInfo.cs +++ b/SharedLibraryCore/Dtos/ServerInfo.cs @@ -14,6 +14,7 @@ namespace SharedLibraryCore.Dtos public string GameType { get; set; } public int ClientCount { get; set; } public int MaxClients { get; set; } + public int PrivateClientSlots { get; set; } public List ChatHistory { get; set; } public List Players { get; set; } public List Reports { get; set; } diff --git a/SharedLibraryCore/Interfaces/IGameServer.cs b/SharedLibraryCore/Interfaces/IGameServer.cs index 907b68659..c7ee50fc0 100644 --- a/SharedLibraryCore/Interfaces/IGameServer.cs +++ b/SharedLibraryCore/Interfaces/IGameServer.cs @@ -73,6 +73,11 @@ namespace SharedLibraryCore.Interfaces /// string GamePassword { get; } + /// + /// Number of private client slots + /// + int PrivateClientSlots { get; } + /// /// Current map the game server is running /// diff --git a/SharedLibraryCore/Server.cs b/SharedLibraryCore/Server.cs index 07f5e2235..3acd4e968 100644 --- a/SharedLibraryCore/Server.cs +++ b/SharedLibraryCore/Server.cs @@ -123,6 +123,7 @@ namespace SharedLibraryCore ?.FirstOrDefault(gt => gt.Name == Gametype)?.Alias ?? Gametype; public string GamePassword { get; protected set; } + public int PrivateClientSlots { get; protected set; } public Map CurrentMap { get; set; } public Map Map => CurrentMap; diff --git a/WebfrontCore/Controllers/ServerController.cs b/WebfrontCore/Controllers/ServerController.cs index 5e76c03d5..7477ef770 100644 --- a/WebfrontCore/Controllers/ServerController.cs +++ b/WebfrontCore/Controllers/ServerController.cs @@ -38,6 +38,7 @@ namespace WebfrontCore.Controllers Game = (Reference.Game)matchingServer.GameName, ClientCount = matchingServer.ClientNum, MaxClients = matchingServer.MaxClients, + PrivateClientSlots = matchingServer.PrivateClientSlots, GameType = matchingServer.GametypeName, Players = matchingServer.GetClientsAsList() .Select(client => new PlayerInfo diff --git a/WebfrontCore/ViewComponents/ServerListViewComponent.cs b/WebfrontCore/ViewComponents/ServerListViewComponent.cs index e574dd1e7..8877c49da 100644 --- a/WebfrontCore/ViewComponents/ServerListViewComponent.cs +++ b/WebfrontCore/ViewComponents/ServerListViewComponent.cs @@ -74,6 +74,7 @@ namespace WebfrontCore.ViewComponents Game = (Reference.Game)server.GameName, ClientCount = server.ClientNum, MaxClients = server.MaxClients, + PrivateClientSlots = server.PrivateClientSlots, GameType = server.GametypeName, ClientHistory = new ClientHistoryInfo { diff --git a/WebfrontCore/Views/Server/_Server.cshtml b/WebfrontCore/Views/Server/_Server.cshtml index 962982f6f..77674ab25 100644 --- a/WebfrontCore/Views/Server/_Server.cshtml +++ b/WebfrontCore/Views/Server/_Server.cshtml @@ -65,7 +65,7 @@ }
- @Model.ClientCount/@Model.MaxClients + @Model.ClientCount/@(Model.MaxClients - Model.PrivateClientSlots)@(Model.PrivateClientSlots > 0 ? $" ({Model.MaxClients})": "")