From c7395e506170c3cfe57e3bc3d8ad88cdb1845507 Mon Sep 17 00:00:00 2001 From: Ravid-A Date: Fri, 16 Oct 2026 12:47:38 +0300 Subject: [PATCH] Fix connect penalty counts always showing 0 (1.9.1) The admin notification on player connect always reported 0 bans, gags, mutes and silences. - MuteManager.GetPlayerMutes ran GetRetrieveMutesQuery (the unmute id lookup, which needs @pattern/@muteType) instead of GetMuteStatsQuery. The query threw, the catch returned (0,0,0), so mute counts were always 0. - CacheManager.GetPlayerBansBySteamId read _steamIdIndex, which only holds ACTIVE bans. Anyone with an active ban is kicked before the message is sent, so the count was always 0. It now counts all of the player's bans in _banCache (expired/unbanned included). The connect message is its only caller; the ban check still uses the active index. --- CS2-SimpleAdmin/CS2-SimpleAdmin.cs | 2 +- CS2-SimpleAdmin/Managers/CacheManager.cs | 5 ++++- CS2-SimpleAdmin/Managers/MuteManager.cs | 2 +- CS2-SimpleAdmin/VERSION | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CS2-SimpleAdmin/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin/CS2-SimpleAdmin.cs index 7c93924..d4e25d1 100644 --- a/CS2-SimpleAdmin/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin/CS2-SimpleAdmin.cs @@ -22,7 +22,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig "CS2-SimpleAdmin" + (Helper.IsDebugBuild ? " (DEBUG)" : " (RELEASE)"); public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)"; public override string ModuleAuthor => "daffyy"; - public override string ModuleVersion => "1.9.0"; + public override string ModuleVersion => "1.9.1"; public override void Load(bool hotReload) { diff --git a/CS2-SimpleAdmin/Managers/CacheManager.cs b/CS2-SimpleAdmin/Managers/CacheManager.cs index 56daa8d..2e515fa 100644 --- a/CS2-SimpleAdmin/Managers/CacheManager.cs +++ b/CS2-SimpleAdmin/Managers/CacheManager.cs @@ -442,7 +442,10 @@ internal class CacheManager: IDisposable /// /// 64-bit Steam ID of the player. /// List of objects associated with the Steam ID. - public List GetPlayerBansBySteamId(ulong steamId) => _steamIdIndex.TryGetValue(steamId, out var bans) ? bans : []; + // _steamIdIndex holds only ACTIVE bans, so scan the full cache for history (expired/unbanned included). + // ponytail: O(n) over all cached bans per call; add an all-status index if this gets hot. + public List GetPlayerBansBySteamId(ulong steamId) => + _banCache.Values.Where(b => b.PlayerSteamId == steamId).ToList(); /// /// Gets all known Steam accounts that have used the specified IP address. diff --git a/CS2-SimpleAdmin/Managers/MuteManager.cs b/CS2-SimpleAdmin/Managers/MuteManager.cs index 01d83df..7ae2376 100644 --- a/CS2-SimpleAdmin/Managers/MuteManager.cs +++ b/CS2-SimpleAdmin/Managers/MuteManager.cs @@ -159,7 +159,7 @@ internal class MuteManager(IDatabaseProvider? databaseProvider) { await using var connection = await databaseProvider.CreateConnectionAsync(); - var sql = databaseProvider.GetRetrieveMutesQuery(CS2_SimpleAdmin.Instance.Config.MultiServerMode); + var sql = databaseProvider.GetMuteStatsQuery(CS2_SimpleAdmin.Instance.Config.MultiServerMode); var result = await connection.QuerySingleAsync<(int TotalMutes, int TotalGags, int TotalSilences)>(sql, new { PlayerSteamID = playerInfo.SteamId.SteamId64, diff --git a/CS2-SimpleAdmin/VERSION b/CS2-SimpleAdmin/VERSION index abb1658..ee672d8 100644 --- a/CS2-SimpleAdmin/VERSION +++ b/CS2-SimpleAdmin/VERSION @@ -1 +1 @@ -1.9.0 \ No newline at end of file +1.9.1 \ No newline at end of file