Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions Content.Client/Lobby/ClientPreferencesManager.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Linq;
using Content.Shared._Mono.Company;
using Content.Shared.CCVar;
using Content.Shared.Preferences;
using Robust.Client;
using Robust.Client.Player;
using Robust.Shared.Network;
using Robust.Shared.Utility;
using Robust.Shared.Prototypes;
using Robust.Shared.Configuration;

namespace Content.Client.Lobby
{
Expand All @@ -19,6 +21,8 @@ public sealed class ClientPreferencesManager : IClientPreferencesManager
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IBaseClient _baseClient = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!; // Forge-Change
[Dependency] private readonly Players.PlayTimeTracking.JobRequirementsManager _jobRequirements = default!; // Forge-Change

public event Action? OnServerDataLoaded;

Expand Down Expand Up @@ -66,13 +70,19 @@ public void UpdateCharacter(ICharacterProfile profile, int slot)
// Verify company exists if this is a humanoid profile
if (profile is HumanoidCharacterProfile humanoidProfile)
{
// Forge-Change-Start
var humanoid = humanoidProfile;

var protoManager = IoCManager.Resolve<IPrototypeManager>();
if (!string.IsNullOrEmpty(humanoidProfile.Company) &&
humanoidProfile.Company != "None" &&
!protoManager.HasIndex<CompanyPrototype>(humanoidProfile.Company))
if (!string.IsNullOrEmpty(humanoid.Company) &&
humanoid.Company != "None" &&
!protoManager.HasIndex<CompanyPrototype>(humanoid.Company))
{
profile = humanoidProfile.WithCompany("None");
humanoid = humanoid.WithCompany("None");
}

profile = humanoid;
// Forge-Change-End
}

profile.EnsureValid(_playerManager.LocalSession!, collection);
Expand All @@ -88,6 +98,16 @@ public void UpdateCharacter(ICharacterProfile profile, int slot)

public void CreateCharacter(ICharacterProfile profile)
{
// Forge-Change-Start: apply whitelisted starting balance for brand new characters so UI matches server
if (profile is HumanoidCharacterProfile humanoidProfile &&
_jobRequirements.IsWhitelisted() &&
humanoidProfile.BankBalance == HumanoidCharacterProfile.DefaultBalance)
{
var startingBalance = _cfg.GetCVar(CCVars.GameWhitelistedStartingBalance);
profile = humanoidProfile.WithBankBalance(startingBalance);
}
// Forge-Change-End

var characters = new Dictionary<int, ICharacterProfile>(Preferences.Characters);
var lowest = Enumerable.Range(0, Settings.MaxCharacterSlots)
.Except(characters.Keys)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public bool CheckRoleRequirements(HashSet<JobRequirement>? requirements, Humanoi
{
reason = null;

if (requirements == null || !_cfg.GetCVar(CCVars.GameRoleTimers))
if (requirements == null || !_cfg.GetCVar(CCVars.GameRoleTimers) || _whitelisted) // Forge-Change: bypass client-side role timers for globally whitelisted players
return true;

var reasons = new List<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ public bool IsAllowed(ICommonSession player, string role)
!_cfg.GetCVar(CCVars.GameRoleTimers))
return true;

var isWhitelisted = player.ContentData()?.Whitelisted ?? false; // Forge-Change: bypass role timers for globally whitelisted players
if (isWhitelisted)
return true; // Forge-Change

if (!_tracking.TryGetTrackerTimes(player, out var playTimes))
{
Log.Error($"Unable to check playtimes {Environment.StackTrace}");
Expand All @@ -210,6 +214,10 @@ public HashSet<ProtoId<JobPrototype>> GetDisallowedJobs(ICommonSession player)
if (!_cfg.GetCVar(CCVars.GameRoleTimers))
return roles;

var isWhitelisted = player.ContentData()?.Whitelisted ?? false; // Forge-Change: globally whitelisted players ignore disallowed-jobs timer checks
if (isWhitelisted)
return roles; // Forge-Change

if (!_tracking.TryGetTrackerTimes(player, out var playTimes))
{
Log.Error($"Unable to check playtimes {Environment.StackTrace}");
Expand Down Expand Up @@ -237,9 +245,11 @@ public void RemoveDisallowedJobs(NetUserId userId, List<ProtoId<JobPrototype>> j
Log.Error($"Playtimes weren't ready yet for {player} on roundstart!");
playTimes ??= new Dictionary<string, TimeSpan>();
}

var isWhitelisted = player.ContentData()?.Whitelisted ?? false; // DeltaV - Whitelist requirement

if (isWhitelisted)
return; // Forge-Change: do not filter jobs by playtime for globally whitelisted players

for (var i = 0; i < jobs.Count; i++)
{
if (_prototypes.TryIndex(jobs[i], out var job)
Expand Down
28 changes: 26 additions & 2 deletions Content.Server/Preferences/Managers/ServerPreferencesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,22 @@ public async Task SetProfile(NetUserId userId, int slot, ICharacterProfile profi

var curPrefs = prefsData.Prefs!;
var session = _playerManager.GetSessionById(userId);

profile.EnsureValid(session, _dependencies);

// Forge-Change-Start: set increased starting bank balance for new globally whitelisted characters
if (profile is HumanoidCharacterProfile humanoidProfile &&
!curPrefs.Characters.ContainsKey(slot) &&
humanoidProfile.BankBalance == HumanoidCharacterProfile.DefaultBalance)
{
var whitelisted = await _db.GetWhitelistStatusAsync(userId);
if (whitelisted)
{
var startingBalance = _cfg.GetCVar(CCVars.GameWhitelistedStartingBalance);
profile = humanoidProfile.WithBankBalance(startingBalance);
}
}
// Forge-Change-End

var profiles = new Dictionary<int, ICharacterProfile>(curPrefs.Characters)

{
Expand Down Expand Up @@ -288,7 +301,18 @@ private async Task<PlayerPreferences> GetOrCreatePreferencesAsync(NetUserId user
var prefs = await _db.GetPlayerPreferencesAsync(userId, cancel);
if (prefs is null)
{
return await _db.InitPrefsAsync(userId, HumanoidCharacterProfile.Random(), cancel);
var profile = HumanoidCharacterProfile.Random();

// Forge-Change-Start: give higher initial balance to first character of globally whitelisted players
var whitelisted = await _db.GetWhitelistStatusAsync(userId);
if (whitelisted)
{
var startingBalance = _cfg.GetCVar(CCVars.GameWhitelistedStartingBalance);
profile = profile.WithBankBalance(startingBalance);
}
// Forge-Change-End

return await _db.InitPrefsAsync(userId, profile, cancel);
}

return prefs;
Expand Down
8 changes: 7 additions & 1 deletion Content.Shared/CCVar/CCVars.Game.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Roles;
using Content.Shared.Roles;
using Robust.Shared.Configuration;

namespace Content.Shared.CCVar;
Expand Down Expand Up @@ -131,6 +131,12 @@ public static readonly CVarDef<string>
public static readonly CVarDef<bool>
GameRoleWhitelist = CVarDef.Create("game.role_whitelist", true, CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Forge-Change: starting bank balance for globally whitelisted players' new characters.
/// </summary>
public static readonly CVarDef<int>
GameWhitelistedStartingBalance = CVarDef.Create("game.whitelisted_starting_balance", 100_000, CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Whether or not disconnecting inside of a cryopod should remove the character or just store them until they reconnect.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Resources/ConfigPresets/Forge/corvax.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ debug_coordinates_admin_only = true
cryo_sleep_rejoining = true
role_timer_override = ""
role_whitelist = true
whitelisted_starting_balance = 100000

[shuttle]
auto_call_time = 360
Expand Down
Loading