From 6694ad8dc86f496a552ee9450c59611219374580 Mon Sep 17 00:00:00 2001 From: sleepyyapril Date: Mon, 11 Nov 2024 22:00:54 -0400 Subject: [PATCH 1/4] Auto voting system for first-time player join as well as return to lobby. --- Content.Server/AutoVote/AutoVoteSystem.cs | 57 +++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Content.Server/AutoVote/AutoVoteSystem.cs diff --git a/Content.Server/AutoVote/AutoVoteSystem.cs b/Content.Server/AutoVote/AutoVoteSystem.cs new file mode 100644 index 0000000000..77ba406a30 --- /dev/null +++ b/Content.Server/AutoVote/AutoVoteSystem.cs @@ -0,0 +1,57 @@ +using Robust.Shared.Configuration; +using Content.Server.Voting.Managers; +using Content.Shared.GameTicking; +using Content.Shared.Voting; +using Content.Shared.CCVar; +using Robust.Server.Player; +using Content.Server.GameTicking; + +namespace Content.Server.AutoVote; + +public sealed class AutoVoteSystem : EntitySystem +{ + [Dependency] private readonly IConfigurationManager _cfg = default!; + [Dependency] public readonly IVoteManager _voteManager = default!; + [Dependency] public readonly IPlayerManager _playerManager = default!; + + public bool _shouldVoteNextJoin = false; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnReturnedToLobby); + SubscribeLocalEvent(OnPlayerJoinedLobby); + } + + public void OnReturnedToLobby(RoundRestartCleanupEvent ev) + { + CallAutovote(); + } + + public void OnPlayerJoinedLobby(PlayerJoinedLobbyEvent ev) + { + if (_shouldVoteNextJoin) + { + CallAutovote(); + _shouldVoteNextJoin = false; + } + } + + private void CallAutovote() + { + if (!_cfg.GetCVar(CCVars.AutoVoteEnabled)) + return; + + if (_playerManager.PlayerCount == 0) + { + _shouldVoteNextJoin = true; + return; + } + + if (_cfg.GetCVar(CCVars.MapAutoVoteEnabled)) + _voteManager.CreateStandardVote(null, StandardVoteType.Preset); + if (_cfg.GetCVar(CCVars.PresetAutoVoteEnabled)) + _voteManager.CreateStandardVote(null, StandardVoteType.Map); + } +} From eb800c6a12bcec07e56cb32da0059dd9f456a279 Mon Sep 17 00:00:00 2001 From: sleepyyapril Date: Tue, 12 Nov 2024 03:15:47 +0100 Subject: [PATCH 2/4] CVars --- Content.Shared/CCVar/CCVars.cs | 36 ++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 93a1ffc7d1..7ef691f336 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -2005,7 +2005,7 @@ public static readonly CVarDef /// Allow Ethereal Ent to PassThrough Walls/Objects while in Ethereal. /// public static readonly CVarDef EtherealPassThrough = - CVarDef.Create("ic.EtherealPassThrough", true, CVar.SERVER); + CVarDef.Create("ic.EtherealPassThrough", false, CVar.SERVER); /* * Salvage @@ -2062,13 +2062,13 @@ public static readonly CVarDef */ /// - /// Time that players have to wait before rules can be accepted. + /// Time that players have to wait before rules can be accepted. /// public static readonly CVarDef RulesWaitTime = - CVarDef.Create("rules.time", 60f, CVar.SERVER | CVar.REPLICATED); + CVarDef.Create("rules.time", 10f, CVar.SERVER | CVar.REPLICATED); /// - /// Don't show rules to localhost/loopback interface. + /// Don't show rules to localhost/loopback interface. /// public static readonly CVarDef RulesExemptLocal = CVarDef.Create("rules.exempt_local", true, CVar.SERVERONLY); @@ -2640,5 +2640,33 @@ public static readonly CVarDef CVarDef.Create("ghost.allow_same_character", false, CVar.SERVERONLY); #endregion + + /// + /// Set to true to disable parallel processing in the pow3r solver. + /// + public static readonly CVarDef DebugPow3rDisableParallel = + CVarDef.Create("debug.pow3r_disable_parallel", true, CVar.SERVERONLY); + + /* + * AUTOVOTE SYSTEM + */ + + /// + /// Enables the automatic voting system. + /// + public static readonly CVarDef AutoVoteEnabled = + CVarDef.Create("vote.autovote_enabled", false, CVar.SERVERONLY); + + /// + /// Automatically make map votes on return to lobby? Requires auto voting to be enabled. + /// + public static readonly CVarDef MapAutoVoteEnabled = + CVarDef.Create("vote.map_autovote_enabled", true, CVar.SERVERONLY); + + /// + /// Automatically make preset votes on return to lobby? Requires auto voting to be enabled. + /// + public static readonly CVarDef PresetAutoVoteEnabled = + CVarDef.Create("vote.preset_autovote_enabled", true, CVar.SERVERONLY); } } From e889d49f94e4683fea43195d0c0781abae04ac80 Mon Sep 17 00:00:00 2001 From: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Date: Tue, 12 Nov 2024 22:46:45 -0400 Subject: [PATCH 3/4] remove unused cvars --- Content.Shared/CCVar/CCVars.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 7ef691f336..657726cea4 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -2005,7 +2005,7 @@ public static readonly CVarDef /// Allow Ethereal Ent to PassThrough Walls/Objects while in Ethereal. /// public static readonly CVarDef EtherealPassThrough = - CVarDef.Create("ic.EtherealPassThrough", false, CVar.SERVER); + CVarDef.Create("ic.EtherealPassThrough", true, CVar.SERVER); /* * Salvage @@ -2065,7 +2065,7 @@ public static readonly CVarDef /// Time that players have to wait before rules can be accepted. /// public static readonly CVarDef RulesWaitTime = - CVarDef.Create("rules.time", 10f, CVar.SERVER | CVar.REPLICATED); + CVarDef.Create("rules.time", 60f, CVar.SERVER | CVar.REPLICATED); /// /// Don't show rules to localhost/loopback interface. @@ -2641,12 +2641,6 @@ public static readonly CVarDef #endregion - /// - /// Set to true to disable parallel processing in the pow3r solver. - /// - public static readonly CVarDef DebugPow3rDisableParallel = - CVarDef.Create("debug.pow3r_disable_parallel", true, CVar.SERVERONLY); - /* * AUTOVOTE SYSTEM */ From 3cd7160f4d8db00db47598f4345e8e80f9832289 Mon Sep 17 00:00:00 2001 From: Fansana Date: Thu, 14 Nov 2024 00:30:14 +0100 Subject: [PATCH 4/4] cvar enabled by default --- Content.Shared/CCVar/CCVars.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 657726cea4..4228762bf5 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -2649,7 +2649,7 @@ public static readonly CVarDef /// Enables the automatic voting system. /// public static readonly CVarDef AutoVoteEnabled = - CVarDef.Create("vote.autovote_enabled", false, CVar.SERVERONLY); + CVarDef.Create("vote.autovote_enabled", true, CVar.SERVERONLY); // Floof enabled by default /// /// Automatically make map votes on return to lobby? Requires auto voting to be enabled.