using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
+using Robust.Shared.Network;
using Robust.Shared.Timing;
namespace Content.Client.Voting.UI
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IVoteManager _voteManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
+ [Dependency] private readonly IClientNetManager _netManager = default!;
public static readonly (string name, StandardVoteType type, (string name, string id)[]? secondaries)[]
AvailableVoteTypes =
{
base.Opened();
+ _netManager.ClientSendMessage(new MsgVoteMenu());
+
_voteManager.CanCallVoteChanged += CanCallVoteChanged;
}
using Content.Server.Maps;
using Content.Server.RoundEnd;
using Content.Shared.CCVar;
+using Content.Shared.Database;
using Content.Shared.Voting;
using Robust.Server.Player;
using Robust.Shared.Configuration;
public void CreateStandardVote(IPlayerSession? initiator, StandardVoteType voteType)
{
+ if (initiator != null)
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{initiator} initiated a {voteType.ToString()} vote");
+ else
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Initiated a {voteType.ToString()} vote");
+
switch (voteType)
{
case StandardVoteType.Restart:
var ratioRequired = _cfg.GetCVar(CCVars.VoteRestartRequiredRatio);
if (total > 0 && votesYes / (float) total >= ratioRequired)
{
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Restart vote succeeded: {votesYes}/{votesNo}");
_chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-restart-succeeded"));
var roundEnd = _entityManager.EntitySysManager.GetEntitySystem<RoundEndSystem>();
roundEnd.EndRound();
}
else
{
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Restart vote failed: {votesYes}/{votesNo}");
_chatManager.DispatchServerAnnouncement(
Loc.GetString("ui-vote-restart-failed", ("ratio", ratioRequired)));
}
_chatManager.DispatchServerAnnouncement(
Loc.GetString("ui-vote-gamemode-win", ("winner", Loc.GetString(presets[picked]))));
}
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Preset vote finished: {picked}");
var ticker = _entityManager.EntitySysManager.GetEntitySystem<GameTicker>();
ticker.SetGamePreset(picked);
};
Loc.GetString("ui-vote-map-win", ("winner", maps[picked])));
}
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Map vote finished: {picked.MapName}");
var ticker = _entityManager.EntitySysManager.GetEntitySystem<GameTicker>();
if (ticker.RunLevel == GameRunLevel.PreRoundLobby)
{
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Administration;
+using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers;
using Content.Server.Afk;
using Content.Server.Chat.Managers;
using Content.Server.Maps;
using Content.Shared.Administration;
using Content.Shared.CCVar;
+using Content.Shared.Database;
using Content.Shared.Voting;
using Robust.Server.Player;
using Robust.Shared.Configuration;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IGameMapManager _gameMapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
+ [Dependency] private readonly IAdminLogManager _adminLogger = default!;
private int _nextVoteId = 1;
{
_netManager.RegisterNetMessage<MsgVoteData>();
_netManager.RegisterNetMessage<MsgVoteCanCall>();
+ _netManager.RegisterNetMessage<MsgVoteMenu>(ReceiveVoteMenu);
_playerManager.PlayerStatusChanged += PlayerManagerOnPlayerStatusChanged;
_adminMgr.OnPermsChanged += AdminPermsChanged;
}
}
+ private void ReceiveVoteMenu(MsgVoteMenu message)
+ {
+ var sender = message.MsgChannel;
+ var session = _playerManager.GetSessionByChannel(sender);
+
+ _adminLogger.Add(LogType.Vote, LogImpact.Low, $"{session} opened vote menu");
+ }
+
private void AdminPermsChanged(AdminPermsChangedEventArgs obj)
{
DirtyCanCallVote(obj.Player);
using System.Linq;
using Content.Server.Administration;
+using Content.Server.Administration.Logs;
using Content.Server.Chat.Managers;
using Content.Server.Voting.Managers;
using Content.Shared.Administration;
+using Content.Shared.Database;
using Content.Shared.Voting;
using Robust.Server.Player;
using Robust.Shared.Console;
[AnyCommand]
public sealed class CreateVoteCommand : IConsoleCommand
{
+ [Dependency] private readonly IAdminLogManager _adminLogger = default!;
+
public string Command => "createvote";
public string Description => Loc.GetString("cmd-createvote-desc");
public string Help => Loc.GetString("cmd-createvote-help");
if (shell.Player != null && !mgr.CanCallVote((IPlayerSession) shell.Player, type))
{
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{shell.Player} failed to start {type.ToString()} vote");
shell.WriteError(Loc.GetString("cmd-createvote-cannot-call-vote-now"));
return;
}
[AdminCommand(AdminFlags.Admin)]
public sealed class CreateCustomCommand : IConsoleCommand
{
+ [Dependency] private readonly IAdminLogManager _adminLogger = default!;
+
private const int MaxArgCount = 10;
public string Command => "customvote";
options.SetInitiatorOrServer((IPlayerSession?) shell.Player);
+ if (shell.Player != null)
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{shell.Player} initiated a custom vote: {options.Title} - {string.Join("; ", options.Options.Select(x => x.text))}");
+ else
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Initiated a custom vote: {options.Title} - {string.Join("; ", options.Options.Select(x => x.text))}");
+
var vote = mgr.CreateVote(options);
vote.OnFinished += (_, eventArgs) =>
if (eventArgs.Winner == null)
{
var ties = string.Join(", ", eventArgs.Winners.Select(c => args[(int) c]));
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Custom vote {options.Title} finished as tie: {ties}");
chatMgr.DispatchServerAnnouncement(Loc.GetString("cmd-customvote-on-finished-tie",("ties", ties)));
}
else
{
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Custom vote {options.Title} finished: {args[(int) eventArgs.Winner]}");
chatMgr.DispatchServerAnnouncement(Loc.GetString("cmd-customvote-on-finished-win",("winner", args[(int) eventArgs.Winner])));
}
};
[AdminCommand(AdminFlags.Admin)]
public sealed class CancelVoteCommand : IConsoleCommand
{
+ [Dependency] private readonly IAdminLogManager _adminLogger = default!;
+
public string Command => "cancelvote";
public string Description => Loc.GetString("cmd-cancelvote-desc");
public string Help => Loc.GetString("cmd-cancelvote-help");
return;
}
+ if (shell.Player != null)
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{shell.Player} canceled vote: {vote.Title}");
+ else
+ _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Canceled vote: {vote.Title}");
vote.Cancel();
}
WireHacking = 80,
Teleport = 81,
EntityDelete = 82,
+ Vote = 83,
}
--- /dev/null
+using Lidgren.Network;
+using Robust.Shared.Network;
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.Voting;
+
+public sealed class MsgVoteMenu : NetMessage
+{
+ public override MsgGroups MsgGroup => MsgGroups.Command;
+
+ public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
+ {
+ }
+
+ public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
+ {
+ }
+
+ public override NetDeliveryMethod DeliveryMethod => NetDeliveryMethod.ReliableUnordered;
+}