mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
Use shared sponsors manager
This commit is contained in:
parent
dc6f667e18
commit
80c6ccf4d2
13 changed files with 42 additions and 57 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using Content.Corvax.Interfaces.Client;
|
||||
using Content.Corvax.Interfaces.Shared;
|
||||
using Content.Shared.Administration.Events;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
|
|
@ -30,7 +30,7 @@ public sealed partial class PanicBunkerTab : Control
|
|||
MinOverallHours.OnFocusExit += args => SendMinOverallHours(args.Text);
|
||||
_minOverallHours = MinOverallHours.Text;
|
||||
// Corvax-VPNGuard-Start
|
||||
var haveSecrets = IoCManager.Instance!.TryResolveType<IClientSponsorsManager>(out _); // TODO: Probably need better way to detect Secrets module
|
||||
var haveSecrets = IoCManager.Instance!.TryResolveType<ISharedSponsorsManager>(out _); // TODO: Probably need better way to detect Secrets module
|
||||
if (haveSecrets)
|
||||
{
|
||||
VPNContainer.Visible = true;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
using System.Linq;
|
||||
using Content.Client.Corvax.TTS;
|
||||
using Content.Client.Lobby;
|
||||
using Content.Corvax.Interfaces.Shared;
|
||||
using Content.Shared.Corvax.TTS;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Corvax.Interfaces.Client;
|
||||
|
||||
namespace Content.Client.Preferences.UI;
|
||||
|
||||
public sealed partial class HumanoidProfileEditor
|
||||
{
|
||||
private IClientSponsorsManager? _sponsorsMgr;
|
||||
private ISharedSponsorsManager? _sponsorsMgr;
|
||||
private List<TTSVoicePrototype> _voiceList = default!;
|
||||
|
||||
private void InitializeVoice()
|
||||
|
|
@ -53,7 +52,7 @@ public sealed partial class HumanoidProfileEditor
|
|||
if (_sponsorsMgr is null)
|
||||
continue;
|
||||
if (voice.SponsorOnly && _sponsorsMgr != null &&
|
||||
!_sponsorsMgr.Prototypes.Contains(voice.ID))
|
||||
!_sponsorsMgr.GetClientPrototypes().Contains(voice.ID))
|
||||
{
|
||||
_voiceButton.SetItemDisabled(_voiceButton.GetIdx(i), true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using System.Linq;
|
||||
using Content.Corvax.Interfaces.Client;
|
||||
using Content.Corvax.Interfaces.Shared;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Humanoid.Markings;
|
||||
using Content.Shared.Humanoid.Prototypes;
|
||||
|
|
@ -19,7 +19,7 @@ public sealed partial class MarkingPicker : Control
|
|||
{
|
||||
[Dependency] private readonly MarkingManager _markingManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
private IClientSponsorsManager? _sponsorsManager; // Corvax-Sponsors
|
||||
private ISharedSponsorsManager? _sponsorsManager; // Corvax-Sponsors
|
||||
|
||||
public Action<MarkingSet>? OnMarkingAdded;
|
||||
public Action<MarkingSet>? OnMarkingRemoved;
|
||||
|
|
@ -229,7 +229,7 @@ public sealed partial class MarkingPicker : Control
|
|||
item.Metadata = marking;
|
||||
// Corvax-Sponsors-Start
|
||||
if (marking.SponsorOnly && _sponsorsManager != null)
|
||||
item.Disabled = !_sponsorsManager.Prototypes.Contains(marking.ID);
|
||||
item.Disabled = !_sponsorsManager.GetClientPrototypes().Contains(marking.ID);
|
||||
// Corvax-Sponsors-End
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using System.Linq;
|
||||
using Content.Corvax.Interfaces.Client;
|
||||
using Content.Corvax.Interfaces.Shared;
|
||||
using Content.Shared.Humanoid.Markings;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
|
@ -12,7 +12,7 @@ namespace Content.Client.Humanoid;
|
|||
public sealed partial class SingleMarkingPicker : BoxContainer
|
||||
{
|
||||
[Dependency] private readonly MarkingManager _markingManager = default!;
|
||||
private IClientSponsorsManager? _sponsorsManager; // Corvax-Sponsors
|
||||
private ISharedSponsorsManager? _sponsorsManager; // Corvax-Sponsors
|
||||
|
||||
/// <summary>
|
||||
/// What happens if a marking is selected.
|
||||
|
|
@ -195,7 +195,7 @@ public sealed partial class SingleMarkingPicker : BoxContainer
|
|||
item.Metadata = marking.ID;
|
||||
// Corvax-Sponsors-Start
|
||||
if (marking.SponsorOnly && _sponsorsManager != null)
|
||||
item.Disabled = !_sponsorsManager.Prototypes.Contains(marking.ID);
|
||||
item.Disabled = !_sponsorsManager.GetClientPrototypes().Contains(marking.ID);
|
||||
// Corvax-Sponsors-End
|
||||
|
||||
if (_markings[Slot].MarkingId == id)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
using System.Linq;
|
||||
using Content.Corvax.Interfaces.Client;
|
||||
using Content.Corvax.Interfaces.Shared;
|
||||
using Content.Shared.Preferences;
|
||||
using Robust.Client;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Preferences
|
||||
|
|
@ -20,7 +18,7 @@ namespace Content.Client.Preferences
|
|||
[Dependency] private readonly IClientNetManager _netManager = default!;
|
||||
[Dependency] private readonly IBaseClient _baseClient = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
private IClientSponsorsManager? _sponsorsManager; // Corvax-Sponsors
|
||||
private ISharedSponsorsManager? _sponsorsManager; // Corvax-Sponsors
|
||||
|
||||
public event Action? OnServerDataLoaded;
|
||||
|
||||
|
|
@ -66,7 +64,7 @@ namespace Content.Client.Preferences
|
|||
{
|
||||
var collection = IoCManager.Instance!;
|
||||
// Corvax-Sponsors-Start
|
||||
var sponsorPrototypes = _sponsorsManager?.Prototypes.ToArray() ?? [];
|
||||
var sponsorPrototypes = _sponsorsManager?.GetClientPrototypes().ToArray() ?? [];
|
||||
profile.EnsureValid(_playerManager.LocalSession!, collection, sponsorPrototypes);
|
||||
// Corvax-Sponsors-End
|
||||
var characters = new Dictionary<int, ICharacterProfile>(Preferences.Characters) {[slot] = profile};
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ namespace Content.Client.Preferences.UI
|
|||
_speciesList = prototypeManager.EnumeratePrototypes<SpeciesPrototype>().Where(o => o.RoundStart).ToList();
|
||||
// Corvax-Sponsors-Start
|
||||
if (_sponsorsMgr != null)
|
||||
_speciesList = _speciesList.Where(p => !p.SponsorOnly || _sponsorsMgr.Prototypes.Contains(p.ID)).ToList();
|
||||
_speciesList = _speciesList.Where(p => !p.SponsorOnly || _sponsorsMgr.GetClientPrototypes().Contains(p.ID)).ToList();
|
||||
// Corvax-Sponsors-End
|
||||
for (var i = 0; i < _speciesList.Count; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Content.Corvax.Interfaces.Server;
|
||||
using Content.Corvax.Interfaces.Shared;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Administration.Systems;
|
||||
|
|
@ -46,7 +46,7 @@ namespace Content.Server.Chat.Managers
|
|||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
private IServerSponsorsManager? _sponsorsManager; // Corvax-Sponsors
|
||||
private ISharedSponsorsManager? _sponsorsManager; // Corvax-Sponsors
|
||||
|
||||
/// <summary>
|
||||
/// The maximum length a player-sent message can be sent
|
||||
|
|
@ -253,7 +253,7 @@ namespace Content.Server.Chat.Managers
|
|||
}
|
||||
|
||||
// Corvax-Sponsors-Start
|
||||
if (_sponsorsManager != null && _sponsorsManager.TryGetOocColor(player.UserId, out var oocColor))
|
||||
if (_sponsorsManager != null && _sponsorsManager.TryGetServerOocColor(player.UserId, out var oocColor))
|
||||
{
|
||||
wrappedMessage = Loc.GetString("chat-manager-send-ooc-patron-wrap-message", ("patronColor", oocColor),("playerName", player.Name), ("message", FormattedMessage.EscapeText(message)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
using System.Collections.Immutable;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Corvax.Interfaces.Server;
|
||||
using Content.Corvax.Interfaces.Shared;
|
||||
using Content.Server.Database;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Preferences.Managers;
|
||||
|
|
@ -50,7 +50,7 @@ namespace Content.Server.Connection
|
|||
[Dependency] private readonly ServerDbEntryManager _serverDbEntry = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
private IServerSponsorsManager? _sponsorsMgr; // Corvax-Sponsors
|
||||
private ISharedSponsorsManager? _sponsorsMgr; // Corvax-Sponsors
|
||||
private IServerVPNGuardManager? _vpnGuardMgr; // Corvax-VPNGuard
|
||||
|
||||
private readonly Dictionary<NetUserId, TimeSpan> _temporaryBypasses = [];
|
||||
|
|
@ -283,7 +283,7 @@ namespace Content.Server.Connection
|
|||
public async Task<bool> HavePrivilegedJoin(NetUserId userId)
|
||||
{
|
||||
var adminBypass = _cfg.GetCVar(CCVars.AdminBypassMaxPlayers) && await _dbManager.GetAdminDataForAsync(userId) != null;
|
||||
var havePriorityJoin = _sponsorsMgr != null && _sponsorsMgr.HavePriorityJoin(userId); // Corvax-Sponsors
|
||||
var havePriorityJoin = _sponsorsMgr != null && _sponsorsMgr.HaveServerPriorityJoin(userId); // Corvax-Sponsors
|
||||
var wasInGame = EntitySystem.TryGet<GameTicker>(out var ticker) &&
|
||||
ticker.PlayerGameStatuses.TryGetValue(userId, out var status) &&
|
||||
status == PlayerGameStatus.JoinedGame;
|
||||
|
|
|
|||
|
|
@ -2,13 +2,10 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Corvax.Interfaces.Server;
|
||||
using Content.Corvax.Interfaces.Shared;
|
||||
using Content.Server.Database;
|
||||
using Content.Server.Humanoid;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Humanoid.Prototypes;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Network;
|
||||
|
|
@ -31,7 +28,7 @@ namespace Content.Server.Preferences.Managers
|
|||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IDependencyCollection _dependencies = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protos = default!;
|
||||
private IServerSponsorsManager? _sponsors;
|
||||
private ISharedSponsorsManager? _sponsors;
|
||||
|
||||
// Cache player prefs on the server so we don't need as much async hell related to them.
|
||||
private readonly Dictionary<NetUserId, PlayerPrefData> _cachedPlayerPrefs =
|
||||
|
|
@ -108,7 +105,7 @@ namespace Content.Server.Preferences.Managers
|
|||
var session = _playerManager.GetSessionById(userId);
|
||||
|
||||
// Corvax-Sponsors-Start
|
||||
var sponsorPrototypes = _sponsors != null && _sponsors.TryGetPrototypes(session.UserId, out var prototypes)
|
||||
var sponsorPrototypes = _sponsors != null && _sponsors.TryGetServerPrototypes(session.UserId, out var prototypes)
|
||||
? prototypes.ToArray()
|
||||
: [];
|
||||
profile.EnsureValid(session, _dependencies, sponsorPrototypes);
|
||||
|
|
@ -210,7 +207,7 @@ namespace Content.Server.Preferences.Managers
|
|||
var collection = IoCManager.Instance!;
|
||||
foreach (var (_, profile) in prefs.Characters)
|
||||
{
|
||||
var sponsorPrototypes = _sponsors != null && _sponsors.TryGetPrototypes(session.UserId, out var prototypes)
|
||||
var sponsorPrototypes = _sponsors != null && _sponsors.TryGetServerPrototypes(session.UserId, out var prototypes)
|
||||
? prototypes.ToArray()
|
||||
: [];
|
||||
profile.EnsureValid(session, collection, sponsorPrototypes);
|
||||
|
|
@ -255,7 +252,7 @@ namespace Content.Server.Preferences.Managers
|
|||
private int GetMaxUserCharacterSlots(NetUserId userId)
|
||||
{
|
||||
var maxSlots = _cfg.GetCVar(CCVars.GameMaxCharacterSlots);
|
||||
var extraSlots = _sponsors?.GetExtraCharSlots(userId) ?? 0;
|
||||
var extraSlots = _sponsors?.GetServerExtraCharSlots(userId) ?? 0;
|
||||
return maxSlots + extraSlots;
|
||||
}
|
||||
// Corvax-Sponsors-End
|
||||
|
|
@ -324,7 +321,7 @@ namespace Content.Server.Preferences.Managers
|
|||
// Clean up preferences in case of changes to the game,
|
||||
// such as removed jobs still being selected.
|
||||
|
||||
var sponsorPrototypes = _sponsors != null && _sponsors.TryGetPrototypes(session.UserId, out var prototypes) ? prototypes.ToArray() : []; // Corvax-Sponsors
|
||||
var sponsorPrototypes = _sponsors != null && _sponsors.TryGetServerPrototypes(session.UserId, out var prototypes) ? prototypes.ToArray() : []; // Corvax-Sponsors
|
||||
return new PlayerPreferences(prefs.Characters.Select(p =>
|
||||
{
|
||||
return new KeyValuePair<int, ICharacterProfile>(p.Key, p.Value.Validated(session, collection, sponsorPrototypes));
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
using Content.Corvax.Interfaces.Shared;
|
||||
|
||||
namespace Content.Corvax.Interfaces.Client;
|
||||
|
||||
public interface IClientSponsorsManager : ISharedSponsorsManager
|
||||
{
|
||||
public List<string> Prototypes { get; }
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Corvax.Interfaces.Shared;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Corvax.Interfaces.Server;
|
||||
|
||||
public interface IServerSponsorsManager : ISharedSponsorsManager
|
||||
{
|
||||
public bool TryGetPrototypes(NetUserId userId, [NotNullWhen(true)] out List<string>? prototypes);
|
||||
public bool TryGetOocColor(NetUserId userId, [NotNullWhen(true)] out Color? color);
|
||||
public int GetExtraCharSlots(NetUserId userId);
|
||||
public bool HavePriorityJoin(NetUserId userId);
|
||||
}
|
||||
|
|
@ -1,6 +1,19 @@
|
|||
namespace Content.Corvax.Interfaces.Shared;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Corvax.Interfaces.Shared;
|
||||
|
||||
public interface ISharedSponsorsManager
|
||||
{
|
||||
public void Initialize();
|
||||
|
||||
// Client
|
||||
public List<string> GetClientPrototypes();
|
||||
|
||||
// Server
|
||||
public bool TryGetServerPrototypes(NetUserId userId, [NotNullWhen(true)] out List<string>? prototypes);
|
||||
public bool TryGetServerOocColor(NetUserId userId, [NotNullWhen(true)] out Color? color);
|
||||
public int GetServerExtraCharSlots(NetUserId userId);
|
||||
public bool HaveServerPriorityJoin(NetUserId userId);
|
||||
}
|
||||
|
|
|
|||
2
Secrets
2
Secrets
|
|
@ -1 +1 @@
|
|||
Subproject commit c6695f3f8863932ddc479541a900bc88360fa8b9
|
||||
Subproject commit eca67902c227da4163d619ffb1a382b8a1815d51
|
||||
Loading…
Add table
Reference in a new issue