From 47b58a0282686d14ec40bf2f731fc0c7cb0bd9b6 Mon Sep 17 00:00:00 2001 From: Morb0 <14136326+Morb0@users.noreply.github.com> Date: Fri, 4 Oct 2024 20:05:59 +0300 Subject: [PATCH] Fix upstream --- .../Connection/ConnectionManager.cs | 2 +- .../Corvax/TTS/TTSSystem.RateLimit.cs | 12 ++++---- Content.Server/Corvax/TTS/TTSSystem.cs | 1 + .../Corvax/TTS/VoiceMaskSystem.TTS.cs | 29 ++++++------------- Content.Shared/Corvax/CCCVars/CCCVars.cs | 4 +-- .../Corvax/TTS/SharedVoiceMaskSystem.cs | 2 +- 6 files changed, 20 insertions(+), 30 deletions(-) diff --git a/Content.Server/Connection/ConnectionManager.cs b/Content.Server/Connection/ConnectionManager.cs index 426484706d..e90bf39ffe 100644 --- a/Content.Server/Connection/ConnectionManager.cs +++ b/Content.Server/Connection/ConnectionManager.cs @@ -425,7 +425,7 @@ namespace Content.Server.Connection // Corvax-Queue-Start: Make these conditions in one place, for checks in the connection and in the queue public async Task HavePrivilegedJoin(NetUserId userId) { - var adminBypass = _cfg.GetCVar(CCVars.AdminBypassMaxPlayers) && await _dbManager.GetAdminDataForAsync(userId) != null; + var adminBypass = _cfg.GetCVar(CCVars.AdminBypassMaxPlayers) && await _db.GetAdminDataForAsync(userId) != null; var havePriorityJoin = _sponsorsMgr != null && _sponsorsMgr.HaveServerPriorityJoin(userId); // Corvax-Sponsors var wasInGame = EntitySystem.TryGet(out var ticker) && ticker.PlayerGameStatuses.TryGetValue(userId, out var status) && diff --git a/Content.Server/Corvax/TTS/TTSSystem.RateLimit.cs b/Content.Server/Corvax/TTS/TTSSystem.RateLimit.cs index 261270dde0..0f06f0d243 100644 --- a/Content.Server/Corvax/TTS/TTSSystem.RateLimit.cs +++ b/Content.Server/Corvax/TTS/TTSSystem.RateLimit.cs @@ -1,6 +1,7 @@ using Content.Server.Chat.Managers; using Content.Server.Players.RateLimiting; using Content.Shared.Corvax.CCCVars; +using Content.Shared.Players.RateLimiting; using Robust.Shared.Player; namespace Content.Server.Corvax.TTS; @@ -15,12 +16,11 @@ public sealed partial class TTSSystem private void RegisterRateLimits() { _rateLimitManager.Register(RateLimitKey, - new RateLimitRegistration - { - CVarLimitPeriodLength = CCCVars.TTSRateLimitPeriod, - CVarLimitCount = CCCVars.TTSRateLimitCount, - PlayerLimitedAction = RateLimitPlayerLimited, - }); + new RateLimitRegistration( + CCCVars.TTSRateLimitPeriod, + CCCVars.TTSRateLimitCount, + RateLimitPlayerLimited) + ); } private void RateLimitPlayerLimited(ICommonSession player) diff --git a/Content.Server/Corvax/TTS/TTSSystem.cs b/Content.Server/Corvax/TTS/TTSSystem.cs index 00390fd2fc..c0ffe28cb5 100644 --- a/Content.Server/Corvax/TTS/TTSSystem.cs +++ b/Content.Server/Corvax/TTS/TTSSystem.cs @@ -4,6 +4,7 @@ using Content.Server.Players.RateLimiting; using Content.Shared.Corvax.CCCVars; using Content.Shared.Corvax.TTS; using Content.Shared.GameTicking; +using Content.Shared.Players.RateLimiting; using Robust.Shared.Configuration; using Robust.Shared.Player; using Robust.Shared.Prototypes; diff --git a/Content.Server/Corvax/TTS/VoiceMaskSystem.TTS.cs b/Content.Server/Corvax/TTS/VoiceMaskSystem.TTS.cs index 0f33893fef..48b7ed4e1f 100644 --- a/Content.Server/Corvax/TTS/VoiceMaskSystem.TTS.cs +++ b/Content.Server/Corvax/TTS/VoiceMaskSystem.TTS.cs @@ -1,4 +1,5 @@ using Content.Server.Corvax.TTS; +using Content.Shared.Corvax.TTS; using Content.Shared.VoiceMask; namespace Content.Server.VoiceMask; @@ -13,30 +14,18 @@ public partial class VoiceMaskSystem private void OnSpeakerVoiceTransform(EntityUid uid, VoiceMaskComponent component, TransformSpeakerVoiceEvent args) { - if (component.Enabled) - args.VoiceId = component.VoiceId; + args.VoiceId = component.VoiceId; } - private void OnChangeVoice(EntityUid uid, VoiceMaskComponent component, VoiceMaskChangeVoiceMessage message) + private void OnChangeVoice(Entity entity, ref VoiceMaskChangeVoiceMessage msg) { - component.VoiceId = message.Voice; - - _popupSystem.PopupEntity(Loc.GetString("voice-mask-voice-popup-success"), uid); - - TrySetLastKnownVoice(uid, message.Voice); - - UpdateUI(uid, component); - } - - private void TrySetLastKnownVoice(EntityUid maskWearer, string? voiceId) - { - if (!HasComp(maskWearer) - || !_inventory.TryGetSlotEntity(maskWearer, MaskSlot, out var maskEntity) - || !TryComp(maskEntity, out var maskComp)) - { + if (msg.Voice is { } id && !_proto.HasIndex(id)) return; - } - maskComp.LastSetVoice = voiceId; + entity.Comp.VoiceId = msg.Voice; + + _popupSystem.PopupEntity(Loc.GetString("voice-mask-voice-popup-success"), entity); + + UpdateUI(entity); } } diff --git a/Content.Shared/Corvax/CCCVars/CCCVars.cs b/Content.Shared/Corvax/CCCVars/CCCVars.cs index f0108051b9..2808da945a 100644 --- a/Content.Shared/Corvax/CCCVars/CCCVars.cs +++ b/Content.Shared/Corvax/CCCVars/CCCVars.cs @@ -59,8 +59,8 @@ public sealed class CCCVars /// Tts rate limit values are accounted in periods of this size (seconds). /// After the period has passed, the count resets. /// - public static readonly CVarDef TTSRateLimitPeriod = - CVarDef.Create("tts.rate_limit_period", 2, CVar.SERVERONLY); + public static readonly CVarDef TTSRateLimitPeriod = + CVarDef.Create("tts.rate_limit_period", 2f, CVar.SERVERONLY); /// /// How many tts preview messages are allowed in a single rate limit period. diff --git a/Content.Shared/Corvax/TTS/SharedVoiceMaskSystem.cs b/Content.Shared/Corvax/TTS/SharedVoiceMaskSystem.cs index 31f0e6e328..f3a81915b6 100644 --- a/Content.Shared/Corvax/TTS/SharedVoiceMaskSystem.cs +++ b/Content.Shared/Corvax/TTS/SharedVoiceMaskSystem.cs @@ -5,7 +5,7 @@ namespace Content.Shared.VoiceMask; [Serializable, NetSerializable] public sealed class VoiceMaskChangeVoiceMessage : BoundUserInterfaceMessage { - public string Voice { get; } + public string Voice; public VoiceMaskChangeVoiceMessage(string voice) {