From d179384053d199e7f93b7cdeed46c2a43aec91f9 Mon Sep 17 00:00:00 2001 From: Atakku Date: Fri, 12 Sep 2025 00:38:35 +0200 Subject: [PATCH 1/4] Initial EORG vote commit --- .../Systems/EmergencyShuttleSystem.Console.cs | 40 +++++++++++++++++++ .../Systems/EmergencyShuttleSystem.cs | 6 +++ Content.Server/Voting/Managers/VoteManager.cs | 7 ++++ .../voting/managers/vote-manager.ftl | 6 +++ 4 files changed, 59 insertions(+) create mode 100644 Resources/Locale/en-US/_Ronstation/voting/managers/vote-manager.ftl diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs index e07b522c5ae91..9d92efdc71a9b 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs @@ -1,7 +1,10 @@ +// Modified by Ronstation contributor(s), therefore this file is licensed as MIT sublicensed with AGPL-v3.0. using System.Threading; using Content.Server.Screens.Components; using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Events; +using Content.Server.Voting; // Ronstation - modification. +using Content.Server.Voting.Managers; // Ronstation - modification. using Content.Shared.Access; using Content.Shared.CCVar; using Content.Shared.Database; @@ -220,6 +223,43 @@ private void UpdateEmergencyConsole(float frameTime) ShuttlesLeft = true; _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-left", ("transitTime", $"{TransitTime:0}"))); + // Ronstation - start of modifications. + var options = new VoteOptions + { + Title = Loc.GetString("ui-vote-eorg-title"), + Duration = TimeSpan.FromSeconds(TransitTime), + VoterEligibility = VoteManager.VoterEligibility.NotGhost, + Options = + { + (Loc.GetString("ui-vote-eorg-yes"), "yes"), + (Loc.GetString("ui-vote-eorg-no"), "no"), + (Loc.GetString("ui-vote-eorg-abstain"), "abstain") + } + }; + var vote = _voteManager.CreateVote(options); + + + vote.OnFinished += (_, _) => + { + var votesYes = vote.VotesPerOption["yes"]; + var votesNo = vote.VotesPerOption["no"]; + var total = votesYes + votesNo; + + var ratioRequired = _configManager.GetCVar(CCVars.VoteRestartRequiredRatio); + if (total > 0 && votesYes / (float) total >= ratioRequired) + { + _logger.Add(LogType.Vote, LogImpact.Medium, $"EORG vote succeeded: {votesYes}/{votesNo}"); + _chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-eorg-succeeded")); + } + else + { + _logger.Add(LogType.Vote, LogImpact.Medium, $"EORG vote failed: {votesYes}/{votesNo}"); + _chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-eorg-failed", ("ratio", ratioRequired))); + // TODO: Cancel EORG + } + }; + // Ronstation - end of modifications. + Timer.Spawn((int)(TransitTime * 1000) + _bufferTime.Milliseconds, () => _roundEnd.EndRound(), _roundEndCancelToken?.Token ?? default); } diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index e0bbc9d090ce3..41306e8bbdb53 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -1,9 +1,11 @@ +// Modified by Ronstation contributor(s), therefore this file is licensed as MIT sublicensed with AGPL-v3.0. using System.Linq; using System.Numerics; using System.Threading; using Content.Server.Access.Systems; using Content.Server.Administration.Logs; using Content.Server.Administration.Managers; +using Content.Server.Chat.Managers; // Ronstation - modification. using Content.Server.Chat.Systems; using Content.Server.Communications; using Content.Server.DeviceNetwork.Systems; @@ -17,6 +19,7 @@ using Content.Server.Shuttles.Events; using Content.Server.Station.Events; using Content.Server.Station.Systems; +using Content.Server.Voting.Managers; // Ronstation - modification. using Content.Shared.Access.Systems; using Content.Shared.CCVar; using Content.Shared.Database; @@ -70,6 +73,9 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly TransformSystem _transformSystem = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; + [Dependency] private readonly IVoteManager _voteManager = default!; + [Dependency] private readonly IChatManager _chatManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; private const float ShuttleSpawnBuffer = 1f; diff --git a/Content.Server/Voting/Managers/VoteManager.cs b/Content.Server/Voting/Managers/VoteManager.cs index 94e637638ee4b..ffdb3abbfda41 100644 --- a/Content.Server/Voting/Managers/VoteManager.cs +++ b/Content.Server/Voting/Managers/VoteManager.cs @@ -1,3 +1,4 @@ +// Modified by Ronstation contributor(s), therefore this file is licensed as MIT sublicensed with AGPL-v3.0. using System.Collections; using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; @@ -430,6 +431,11 @@ public bool CheckVoterEligibility(ICommonSession player, VoterEligibility eligib if (eligibility == VoterEligibility.All) return true; + // Ronstation - start of modifications. + if (eligibility == VoterEligibility.NotGhost) + return !_entityManager.TryGetComponent(player.AttachedEntity, out GhostComponent? ghostComp); + // Ronstation - end of modifications. + if (eligibility == VoterEligibility.Ghost || eligibility == VoterEligibility.GhostMinimumPlaytime) { if (!_entityManager.TryGetComponent(player.AttachedEntity, out GhostComponent? ghostComp)) @@ -548,6 +554,7 @@ public VoteEntry(object data, string text) public enum VoterEligibility { All, + NotGhost, // Player needs to be not a ghost // Ronstation - modification. Ghost, // Player needs to be a ghost GhostMinimumPlaytime, // Player needs to be a ghost, with a minimum playtime and deathtime as defined by votekick CCvars. MinimumPlaytime //Player needs to have a minimum playtime and deathtime as defined by votekick CCvars. diff --git a/Resources/Locale/en-US/_Ronstation/voting/managers/vote-manager.ftl b/Resources/Locale/en-US/_Ronstation/voting/managers/vote-manager.ftl new file mode 100644 index 0000000000000..d60a08d53562f --- /dev/null +++ b/Resources/Locale/en-US/_Ronstation/voting/managers/vote-manager.ftl @@ -0,0 +1,6 @@ +ui-vote-eorg-title = Allow EORG +ui-vote-eorg-succeeded = EORG vote succeeded. +ui-vote-eorg-failed = EORG vote failed (need { TOSTRING($ratio, "P0") }). +ui-vote-eorg-yes = Yes +ui-vote-eorg-no = No +ui-vote-eorg-abstain = Abstain \ No newline at end of file From 84b06ad47535163edf750ec1c29d9a19a676a68b Mon Sep 17 00:00:00 2001 From: Atakku Date: Sat, 13 Sep 2025 22:46:22 +0200 Subject: [PATCH 2/4] Improve the vote check --- .../Systems/EmergencyShuttleSystem.Console.cs | 2 +- Content.Server/Voting/Managers/VoteManager.cs | 36 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs index 9d92efdc71a9b..d2f29829842e9 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs @@ -228,7 +228,7 @@ private void UpdateEmergencyConsole(float frameTime) { Title = Loc.GetString("ui-vote-eorg-title"), Duration = TimeSpan.FromSeconds(TransitTime), - VoterEligibility = VoteManager.VoterEligibility.NotGhost, + VoterEligibility = VoteManager.VoterEligibility.OnEvac, Options = { (Loc.GetString("ui-vote-eorg-yes"), "yes"), diff --git a/Content.Server/Voting/Managers/VoteManager.cs b/Content.Server/Voting/Managers/VoteManager.cs index ffdb3abbfda41..27d360ef9c749 100644 --- a/Content.Server/Voting/Managers/VoteManager.cs +++ b/Content.Server/Voting/Managers/VoteManager.cs @@ -9,15 +9,20 @@ using Content.Server.Chat.Managers; using Content.Server.GameTicking; using Content.Server.Maps; +using Content.Server.Shuttles.Components; // Ronstation - modification. using Content.Shared.Administration; using Content.Shared.CCVar; using Content.Shared.Database; using Content.Shared.Ghost; +using Content.Shared.Mind; // Ronstation - modification. +using Content.Shared.Mobs; // Ronstation - modification. +using Content.Shared.Mobs.Components; // Ronstation - modification. using Content.Shared.Players.PlayTimeTracking; using Content.Shared.Voting; using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Enums; +using Robust.Shared.GameObjects; // Ronstation - modification. using Robust.Shared.Network; using Robust.Shared.Player; using Robust.Shared.Prototypes; @@ -432,8 +437,33 @@ public bool CheckVoterEligibility(ICommonSession player, VoterEligibility eligib return true; // Ronstation - start of modifications. - if (eligibility == VoterEligibility.NotGhost) - return !_entityManager.TryGetComponent(player.AttachedEntity, out GhostComponent? ghostComp); + if (eligibility == VoterEligibility.OnEvac) + { + // Get player's transform + if (!_entityManager.TryGetComponent(player.AttachedEntity, out TransformComponent? transform)) + return false; + + _adminLogger.Add(LogType.Action, LogImpact.Medium, $"miau3"); + if (transform == null) + return false; + + _adminLogger.Add(LogType.Action, LogImpact.Medium, $"miau4"); + // Check if player is on the shuttle + if (!_entityManager.HasComponent(transform.GridUid)) + return false; + + _adminLogger.Add(LogType.Action, LogImpact.Medium, $"miau5"); + if (!_entityManager.TryGetComponent(player.AttachedEntity, out MobStateComponent? mobState)) + return false; + + _adminLogger.Add(LogType.Action, LogImpact.Medium, $"miau6"); + // Player is gibbed + if (mobState == null) + return false; + + _adminLogger.Add(LogType.Action, LogImpact.Medium, $"miau7"); + return mobState.CurrentState != MobState.Invalid; + } // Ronstation - end of modifications. if (eligibility == VoterEligibility.Ghost || eligibility == VoterEligibility.GhostMinimumPlaytime) @@ -554,7 +584,7 @@ public VoteEntry(object data, string text) public enum VoterEligibility { All, - NotGhost, // Player needs to be not a ghost // Ronstation - modification. + OnEvac, // Player needs to be on evac // Ronstation - modification. Ghost, // Player needs to be a ghost GhostMinimumPlaytime, // Player needs to be a ghost, with a minimum playtime and deathtime as defined by votekick CCvars. MinimumPlaytime //Player needs to have a minimum playtime and deathtime as defined by votekick CCvars. From e4ee389912f2939c19a1a34dde80e4f5b9f7fadb Mon Sep 17 00:00:00 2001 From: Atakku Date: Sat, 13 Sep 2025 22:50:28 +0200 Subject: [PATCH 3/4] Leftover println moment --- Content.Server/Voting/Managers/VoteManager.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Content.Server/Voting/Managers/VoteManager.cs b/Content.Server/Voting/Managers/VoteManager.cs index 27d360ef9c749..532986e00082b 100644 --- a/Content.Server/Voting/Managers/VoteManager.cs +++ b/Content.Server/Voting/Managers/VoteManager.cs @@ -443,25 +443,20 @@ public bool CheckVoterEligibility(ICommonSession player, VoterEligibility eligib if (!_entityManager.TryGetComponent(player.AttachedEntity, out TransformComponent? transform)) return false; - _adminLogger.Add(LogType.Action, LogImpact.Medium, $"miau3"); if (transform == null) return false; - _adminLogger.Add(LogType.Action, LogImpact.Medium, $"miau4"); // Check if player is on the shuttle if (!_entityManager.HasComponent(transform.GridUid)) return false; - _adminLogger.Add(LogType.Action, LogImpact.Medium, $"miau5"); if (!_entityManager.TryGetComponent(player.AttachedEntity, out MobStateComponent? mobState)) return false; - _adminLogger.Add(LogType.Action, LogImpact.Medium, $"miau6"); // Player is gibbed if (mobState == null) return false; - _adminLogger.Add(LogType.Action, LogImpact.Medium, $"miau7"); return mobState.CurrentState != MobState.Invalid; } // Ronstation - end of modifications. From 01fff0e9e0661308eb7f5c001fbaee8c6a4f75b0 Mon Sep 17 00:00:00 2001 From: Atakku Date: Sat, 13 Sep 2025 23:52:40 +0200 Subject: [PATCH 4/4] Implemented pacification --- .../Systems/EmergencyShuttleSystem.Console.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs index d2f29829842e9..076bbf20981a6 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs @@ -7,9 +7,11 @@ using Content.Server.Voting.Managers; // Ronstation - modification. using Content.Shared.Access; using Content.Shared.CCVar; +using Content.Shared.CombatMode.Pacification; // Ronstation - modification. using Content.Shared.Database; using Content.Shared.DeviceNetwork; using Content.Shared.DeviceNetwork.Components; +using Content.Shared.Mind.Components; // Ronstation - modification. using Content.Shared.Popups; using Content.Shared.Shuttles.BUIStates; using Content.Shared.Shuttles.Events; @@ -255,7 +257,15 @@ private void UpdateEmergencyConsole(float frameTime) { _logger.Add(LogType.Vote, LogImpact.Medium, $"EORG vote failed: {votesYes}/{votesNo}"); _chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-eorg-failed", ("ratio", ratioRequired))); - // TODO: Cancel EORG + + var entities = AllEntityQuery(); + while (entities.MoveNext(out var mind)) + { + if (mind.Owner == null) + continue; + + EnsureComp(mind.Owner); + } } }; // Ronstation - end of modifications.