mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-11-29 20:47:04 +01:00
Merge 478228faf1 into 03a454b1b5
This commit is contained in:
commit
c88c71448b
5 changed files with 11 additions and 7 deletions
|
|
@ -5,7 +5,8 @@ namespace CS2_SimpleAdmin.Database;
|
|||
|
||||
public class SqliteDatabaseProvider(string filePath) : IDatabaseProvider
|
||||
{
|
||||
private readonly string _connectionString = $"Data Source={filePath}";
|
||||
// Dates are stored as UTC; without DateTimeKind=Utc they are read back shifted by the machine's UTC offset
|
||||
private readonly string _connectionString = $"Data Source={filePath};DateTimeKind=Utc";
|
||||
|
||||
public async Task<DbConnection> CreateConnectionAsync()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ public async Task UnbanPlayer(string playerPattern, string adminSteamId, string
|
|||
|
||||
foreach (var ban in bansList)
|
||||
{
|
||||
int banId = ban.id;
|
||||
int banId = (int)ban.id; // SQLite returns long
|
||||
|
||||
var sqlInsertUnban = databaseProvider.GetInsertUnbanQuery(reason != null);
|
||||
var unbanId = await connection.ExecuteScalarAsync<int>(sqlInsertUnban, new { banId, adminId, reason });
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ internal class CacheManager: IDisposable
|
|||
IEnumerable<BanRecord> updatedBans;
|
||||
|
||||
// Get current time from database in local timezone (CURRENT_TIMESTAMP uses session timezone, not UTC)
|
||||
// Overlap refreshes by a second: SQLite compares dates as text, and "10:00:05" sorts before "10:00:05Z"
|
||||
var currentDatabaseTime = await connection.QueryFirstAsync<DateTime>("SELECT CURRENT_TIMESTAMP");
|
||||
|
||||
// Optimization: Only get IDs for comparison if we need to check for deletions
|
||||
|
|
@ -208,7 +209,7 @@ internal class CacheManager: IDisposable
|
|||
updatedBans = updatedList;
|
||||
|
||||
// Update last check time to current database time
|
||||
_lastDatabaseTime = currentDatabaseTime;
|
||||
_lastDatabaseTime = currentDatabaseTime.AddSeconds(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -254,7 +255,7 @@ internal class CacheManager: IDisposable
|
|||
updatedBans = updatedList;
|
||||
|
||||
// Update last check time to current database time
|
||||
_lastDatabaseTime = currentDatabaseTime;
|
||||
_lastDatabaseTime = currentDatabaseTime.AddSeconds(-1);
|
||||
}
|
||||
|
||||
// Optimization: Only process deletions if we have the full ID list
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ internal class MuteManager(IDatabaseProvider? databaseProvider)
|
|||
|
||||
foreach (var mute in mutesList)
|
||||
{
|
||||
int muteId = mute.id;
|
||||
int muteId = (int)mute.id; // SQLite returns long
|
||||
|
||||
int? unmuteId =
|
||||
await connection.ExecuteScalarAsync<int>(sqlInsertUnmute, new { muteId, adminId, reason });
|
||||
|
|
|
|||
|
|
@ -85,7 +85,9 @@ internal class PlayerManager
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CS2_SimpleAdmin.PlayersInfo.ContainsKey(steamId))
|
||||
// Must run on every full connect: OnMapStart wipes all penalties (and CSS resets voice flags), while
|
||||
// PlayersInfo can survive a map change, so gating on it would silently drop active mutes.
|
||||
if (fullConnect)
|
||||
{
|
||||
var playerInfo = new PlayerInfo(userId, slot, new SteamID(steamId), playerName, ipAddress);
|
||||
CS2_SimpleAdmin.PlayersInfo[steamId] = playerInfo;
|
||||
|
|
@ -130,7 +132,7 @@ internal class PlayerManager
|
|||
{
|
||||
string muteType = mute.type;
|
||||
DateTime ends = mute.ends;
|
||||
int duration = mute.duration;
|
||||
int duration = (int)mute.duration; // SQLite returns long
|
||||
switch (muteType)
|
||||
{
|
||||
// Apply mute penalty based on mute type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue