Фикс голосования за исключение
This commit is contained in:
parent
968bee2fc3
commit
0a53ad13af
5 changed files with 80 additions and 16 deletions
|
|
@ -66,8 +66,22 @@ namespace Content.Client.Voting.UI
|
|||
|
||||
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
|
||||
CloseButton.OnPressed += _ => Close();
|
||||
VoteNotTrustedLabel.Text = Loc.GetString("ui-vote-trusted-users-notice", ("timeReq", _cfg.GetCVar(CCVars.VotekickEligibleVoterDeathtime)));
|
||||
|
||||
// Sunrise-Start
|
||||
var deathTimeReq = _cfg.GetCVar(CCVars.VotekickEligibleVoterDeathtime);
|
||||
if (_cfg.GetCVar(CCVars.VotekickInitiatorWhitelistedRequirement))
|
||||
{
|
||||
VoteNotTrustedLabel.Text = Loc.GetString("ui-vote-trusted-users-notice-whitelist", ("ghostTimeReq", deathTimeReq));
|
||||
}
|
||||
else if (_cfg.GetCVar(CCVars.VotekickInitiatorTimeRequirement))
|
||||
{
|
||||
var timeReq = _cfg.GetCVar(CCVars.VotekickEligibleVoterPlaytime);
|
||||
VoteNotTrustedLabel.Text = Loc.GetString("ui-vote-trusted-users-notice-time-req", ("timeReq", timeReq), ("ghostTimeReq", deathTimeReq));
|
||||
}
|
||||
else
|
||||
{
|
||||
VoteNotTrustedLabel.Text = Loc.GetString("ui-vote-trusted-users-notice", ("ghostTimeReq", deathTimeReq));
|
||||
}
|
||||
// Sunrise-End
|
||||
foreach (StandardVoteType voteType in Enum.GetValues<StandardVoteType>())
|
||||
{
|
||||
var option = AvailableVoteOptions[voteType];
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
// We must block server shutdown on these to avoid losing data.
|
||||
private readonly List<Task> _pendingSaveTasks = new();
|
||||
|
||||
private readonly Dictionary<ICommonSession, PlayTimeData> _playTimeData = new();
|
||||
private readonly Dictionary<NetUserId, PlayTimeData> _playTimeData = new(); // Sunrise-Edit
|
||||
|
||||
public event CalcPlayTimeTrackersCallback? CalcTrackers;
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
|
||||
foreach (var player in _playersDirty)
|
||||
{
|
||||
if (!_playTimeData.TryGetValue(player, out var data))
|
||||
if (!_playTimeData.TryGetValue(player.UserId, out var data) || data.Disconected) // Sunrise-Edit
|
||||
continue;
|
||||
|
||||
DebugTools.Assert(data.IsDirty);
|
||||
|
|
@ -175,6 +175,11 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
|
||||
foreach (var data in _playTimeData.Values)
|
||||
{
|
||||
// Sunrise-Start
|
||||
if (data.Disconected)
|
||||
continue;
|
||||
// Sunrise-End
|
||||
|
||||
FlushSingleTracker(data, time);
|
||||
}
|
||||
}
|
||||
|
|
@ -187,7 +192,7 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
public void FlushTracker(ICommonSession player)
|
||||
{
|
||||
var time = _timing.RealTime;
|
||||
var data = _playTimeData[player];
|
||||
var data = _playTimeData[player.UserId]; // Sunrise-Edit
|
||||
|
||||
FlushSingleTracker(data, time);
|
||||
}
|
||||
|
|
@ -268,9 +273,13 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
|
||||
foreach (var (player, data) in _playTimeData)
|
||||
{
|
||||
// Sunrise-Start
|
||||
if (data.Disconected)
|
||||
continue;
|
||||
// Sunrise-End
|
||||
foreach (var tracker in data.DbTrackersDirty)
|
||||
{
|
||||
log.Add(new PlayTimeUpdate(player.UserId, tracker, data.TrackerTimes[tracker]));
|
||||
log.Add(new PlayTimeUpdate(player, tracker, data.TrackerTimes[tracker])); // Sunrise-Edit
|
||||
}
|
||||
|
||||
data.DbTrackersDirty.Clear();
|
||||
|
|
@ -291,7 +300,7 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
{
|
||||
var log = new List<PlayTimeUpdate>();
|
||||
|
||||
var data = _playTimeData[session];
|
||||
var data = _playTimeData[session.UserId]; // Sunrise-Edit
|
||||
|
||||
foreach (var tracker in data.DbTrackersDirty)
|
||||
{
|
||||
|
|
@ -311,7 +320,7 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
public async Task LoadData(ICommonSession session, CancellationToken cancel)
|
||||
{
|
||||
var data = new PlayTimeData();
|
||||
_playTimeData.Add(session, data);
|
||||
_playTimeData[session.UserId] = data; // Sunrise-Edit
|
||||
|
||||
var playTimes = await _db.GetPlayTimes(session.UserId, cancel);
|
||||
cancel.ThrowIfCancellationRequested();
|
||||
|
|
@ -331,12 +340,16 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
{
|
||||
SaveSession(session);
|
||||
|
||||
_playTimeData.Remove(session);
|
||||
// Sunrise-Start
|
||||
//_playTimeData.Remove(session);
|
||||
if (_playTimeData.TryGetValue(session.UserId, out var data))
|
||||
data.Disconected = true;
|
||||
// Sunrise-End
|
||||
}
|
||||
|
||||
public void AddTimeToTracker(ICommonSession id, string tracker, TimeSpan time)
|
||||
{
|
||||
if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized)
|
||||
if (!_playTimeData.TryGetValue(id.UserId, out var data) || !data.Initialized) // Sunrise-Edit
|
||||
throw new InvalidOperationException("Play time info is not yet loaded for this player!");
|
||||
|
||||
AddTimeToTracker(data, tracker, time);
|
||||
|
|
@ -364,7 +377,7 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
{
|
||||
time = null;
|
||||
|
||||
if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized)
|
||||
if (!_playTimeData.TryGetValue(id.UserId, out var data) || !data.Initialized) // Sunrise-Edit
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -388,7 +401,7 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
|
||||
public Dictionary<string, TimeSpan> GetTrackerTimes(ICommonSession id)
|
||||
{
|
||||
if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized)
|
||||
if (!_playTimeData.TryGetValue(id.UserId, out var data) || !data.Initialized)
|
||||
throw new InvalidOperationException("Play time info is not yet loaded for this player!");
|
||||
|
||||
return data.TrackerTimes;
|
||||
|
|
@ -396,7 +409,7 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
|
||||
public TimeSpan GetPlayTimeForTracker(ICommonSession id, string tracker)
|
||||
{
|
||||
if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized)
|
||||
if (!_playTimeData.TryGetValue(id.UserId, out var data) || !data.Initialized) // Sunrise-Edit
|
||||
throw new InvalidOperationException("Play time info is not yet loaded for this player!");
|
||||
|
||||
return data.TrackerTimes.GetValueOrDefault(tracker);
|
||||
|
|
@ -422,7 +435,7 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
|
||||
private PlayTimeData? DirtyPlayer(ICommonSession player)
|
||||
{
|
||||
if (!_playTimeData.TryGetValue(player, out var data) || !data.Initialized)
|
||||
if (!_playTimeData.TryGetValue(player.UserId, out var data) || !data.Initialized) // Sunrise-Edit
|
||||
return null;
|
||||
|
||||
if (!data.IsDirty)
|
||||
|
|
@ -461,6 +474,8 @@ public sealed class PlayTimeTrackingManager : ISharedPlaytimeManager, IPostInjec
|
|||
/// Set of trackers which are different from their DB values and need to be saved to DB.
|
||||
/// </summary>
|
||||
public readonly HashSet<string> DbTrackersDirty = new();
|
||||
|
||||
public bool Disconected;
|
||||
}
|
||||
|
||||
void IPostInjectInit.PostInject()
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public sealed partial class CCVars
|
|||
/// Config for how many hours playtime a player must have to be able to vote on a votekick.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> VotekickEligibleVoterPlaytime =
|
||||
CVarDef.Create("votekick.voter_playtime", 500, CVar.SERVERONLY); // Sunrise-Edit
|
||||
CVarDef.Create("votekick.voter_playtime", 300, CVar.SERVERONLY); // Sunrise-Edit
|
||||
|
||||
/// <summary>
|
||||
/// Config for how many seconds a player must have been dead to initiate a votekick / be able to vote on a votekick.
|
||||
|
|
|
|||
|
|
@ -10393,3 +10393,33 @@
|
|||
id: 717
|
||||
time: '2025-01-10T19:16:49.0000000+00:00'
|
||||
url: https://github.com/space-sunrise/space-station-14/pull/1078
|
||||
- author: VigersRay
|
||||
changes:
|
||||
- message: "\u0418\u0441\u043F\u0440\u0430\u0432\u043B\u0435\u043D \u043A\u0440\u0430\
|
||||
\u0448 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0435\u0441\u043B\u0438 \u0438\
|
||||
\u0433\u0440\u043E\u043A \u043A\u043E\u0442\u043E\u0440\u044B\u0439 \u043F\u0440\
|
||||
\u043E\u0433\u043E\u043B\u043E\u0441\u043E\u0432\u0430\u043B \u0432 \u0433\u043E\
|
||||
\u043B\u043E\u0441\u043E\u0432\u0430\u043D\u0438\u0438 \u0437\u0430 \u0438\u0441\
|
||||
\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435 \u0432\u044B\u0439\u0434\u0435\
|
||||
\u0442 \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u0430."
|
||||
type: Fix
|
||||
- message: "\u0418\u0441\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u043E \u043E\u043F\
|
||||
\u0438\u0441\u0430\u043D\u0438\u0435 \u0442\u0440\u0435\u0431\u043E\u0432\u0430\
|
||||
\u043D\u0438\u044F \u0433\u043E\u043B\u043E\u0441\u043E\u0432\u0430\u043D\u0438\
|
||||
\u044F \u043D\u0430 \u0438\u0441\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435\
|
||||
. \u0422\u0435\u043F\u0435\u0440\u044C \u0435\u0441\u043B\u0438 \u043E\u043D\
|
||||
\u043E \u0432\u044B\u0434\u0430\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\
|
||||
\ \u043F\u043E \u0432\u0440\u0435\u043C\u0435\u043D\u0438 \u0442\u0430\u043C\
|
||||
\ \u0431\u0443\u0434\u0435\u0442 \u043D\u0430\u043F\u0438\u0441\u0430\u043D\u043E\
|
||||
\ \u0441\u043A\u043E\u043B\u044C\u043A\u043E \u043D\u0443\u0436\u043D\u043E\
|
||||
\ \u0447\u0430\u0441\u043E\u0432 \u0430 \u043D\u0435 \u043F\u0438\u0441\u0430\
|
||||
\u0442\u044C \u043F\u0440\u043E \u0432\u0430\u0439\u0442\u043B\u0438\u0441\u0442\
|
||||
."
|
||||
type: Fix
|
||||
- message: "\u0414\u043E\u0441\u0442\u0443\u043F \u043A \u0433\u043E\u043B\u043E\
|
||||
\u0441\u043E\u0432\u0430\u043D\u0438\u0438 \u0437\u0430 \u0438\u0441\u043A\u043B\
|
||||
\u044E\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043D\u0438\u0436\u0435\u043D\
|
||||
\u043E \u0441 500 \u0434\u043E 300 \u0447\u0430\u0441\u043E\u0432."
|
||||
type: Tweak
|
||||
id: 718
|
||||
time: '2025-01-10T21:24:23.039159+00:00'
|
||||
|
|
|
|||
|
|
@ -17,9 +17,14 @@ ui-vote-type-timeout = Это голосование было недавно з
|
|||
# Unavailable text if a vote type has been disabled manually.
|
||||
ui-vote-type-not-available = Этот тип голосования был отключён
|
||||
# Vote option only available for specific users.
|
||||
ui-vote-trusted-users-notice =
|
||||
ui-vote-trusted-users-notice-whitelist =
|
||||
Этот вариант голосования доступен только для вайтлист игроков.
|
||||
Кроме того, вы должны быть призраком в течение { $timeReq } минут.
|
||||
ui-vote-trusted-users-notice-time-req =
|
||||
Этот вариант голосования доступен только игрокам которые наиграли более { $timeReq } часов.
|
||||
Кроме того, вы должны быть призраком в течение { $ghostTimeReq } минут.
|
||||
ui-vote-trusted-users-notice =
|
||||
Вы должны быть призраком в течение { $ghostTimeReq } минут.
|
||||
# Warning to not abuse a specific vote option.
|
||||
ui-vote-abuse-warning =
|
||||
Внимание!
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue