fish-station/Content.Server/GameTicking/GameTicker.cs
beck-thompson a8d6dbc324
Added button and manager for in game bug reports (Part 1) (#35350)
* Added the button and manager

* Minor cleanup

* Reigstered to the wrong thing!

* Unload UI

* Address the review

* First commit :)

* Some cleanup

* Added some comments and now the placehoder text goes away once you start typing

* Some cleanup and better test command

* Basic rate limiter class (Not finished)

* Cleanup

* Removed forgotten comment xD

* Whitespace removal

* Minor cleanup, cvar hours -> minutes

* More minor tweaks

* Don't cache timer and add examples to fields

* Added CCvar for time between bug reports

* Minor crash when restarting rounds fixed

* It compiled on my computer!

* Fix comment indents

* Remove unecessary async, removed magic strings, simplfied sawmill to not use post inject

* Make struct private

* Simplfiy TryGetLongHeader

* Changed list to enumerable

* URI cleanup

* Got rid of the queue, used a much better way!

* Made the comments a little better and fix some issues with them

* Added header consts

* Maximum reports per round is now an error message

* Time between reports is now in seconds

* Change ordering

* Change hotkey to O

* only update window when its open

* Split up validation

* address review

* Address a few issues

* inheritance fix

* API now doesn't keep track of requests, just uses the rate limited response from github

* Rough idea of how channels would work

* refactor: reorganized code, placed rate limiter into http-client-handler AND manager (usually only manager-one should work)

* cleanup

* Add user agent so api doesn't get mad

* Better error logs

* Cleanup

* It now throws!

* refactor: renaming, moved some methods, xml-doc cleanups

* refactor: BugReportWindow formatted to convention, enforced 1 updates only 1 per sec

* Add very basic licence info

* Fixed the issues!

* Set ccvar default to false

* make the button better

* fix test fail silly me

* Adress the review!

* refactor: cleanup of entry point code, binding server-side code with client-facing manager

* Resolve the other issues and cleanup and stuff smile :)

* not entity

* fixes

* Cleanup

* Cleanup

* forgor region

* fixes

* Split up function and more stuff

* Better unsubs yaygit add -A

* I pray...

* Revert "I pray..."

This reverts commit 9629fb4f1289c9009a03e4e4facd9ae975e6303e.

* I think I have to add it in the pr

* Revert "I think I have to add it in the pr"

This reverts commit e185b42f570fe5f0f51e0e44761d7938e22e67f7.

* Tweaks

* Minor tweak to permissions

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-08-15 09:10:38 -07:00

139 lines
5.6 KiB
C#

using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers;
using Content.Server.BugReports;
using Content.Server.Chat.Managers;
using Content.Server.Chat.Systems;
using Content.Server.Database;
using Content.Server.Ghost;
using Content.Server.Maps;
using Content.Server.Players.PlayTimeTracking;
using Content.Server.Preferences.Managers;
using Content.Server.ServerUpdates;
using Content.Server.Station.Systems;
using Content.Shared.CCVar;
using Content.Shared.Chat;
using Content.Shared.GameTicking;
using Content.Shared.Mind;
using Content.Shared.Roles;
using Robust.Server;
using Robust.Server.GameObjects;
using Robust.Server.GameStates;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Console;
using Robust.Shared.EntitySerialization.Systems;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
#if EXCEPTION_TOLERANCE
using Robust.Shared.Exceptions;
#endif
namespace Content.Server.GameTicking
{
public sealed partial class GameTicker : SharedGameTicker
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IBanManager _banManager = default!;
[Dependency] private readonly IBaseServer _baseServer = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IConsoleHost _consoleHost = default!;
[Dependency] private readonly IGameMapManager _gameMapManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
#if EXCEPTION_TOLERANCE
[Dependency] private readonly IRuntimeLog _runtimeLog = default!;
#endif
[Dependency] private readonly IServerPreferencesManager _prefsManager = default!;
[Dependency] private readonly IServerDbManager _db = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly MapLoaderSystem _loader = default!;
[Dependency] private readonly SharedMapSystem _map = default!;
[Dependency] private readonly GhostSystem _ghost = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly PlayTimeTrackingSystem _playTimeTrackings = default!;
[Dependency] private readonly PvsOverrideSystem _pvsOverride = default!;
[Dependency] private readonly ServerUpdateManager _serverUpdates = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly StationJobsSystem _stationJobs = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly UserDbDataManager _userDb = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly SharedRoleSystem _roles = default!;
[Dependency] private readonly ServerDbEntryManager _dbEntryManager = default!;
[Dependency] private readonly IBugReportManager _bugManager = default!;
[ViewVariables] private bool _initialized;
[ViewVariables] private bool _postInitialized;
[ViewVariables] public MapId DefaultMap { get; private set; }
private ISawmill _sawmill = default!;
private bool _randomizeCharacters;
public override void Initialize()
{
base.Initialize();
DebugTools.Assert(!_initialized);
DebugTools.Assert(!_postInitialized);
_sawmill = _logManager.GetSawmill("ticker");
_sawmillReplays = _logManager.GetSawmill("ticker.replays");
Subs.CVar(_cfg, CCVars.ICRandomCharacters, e => _randomizeCharacters = e, true);
// Initialize the other parts of the game ticker.
InitializeStatusShell();
InitializeCVars();
InitializePlayer();
InitializeLobbyBackground();
InitializeGamePreset();
DebugTools.Assert(_prototypeManager.Index(FallbackOverflowJob).Name == FallbackOverflowJobName,
"Overflow role does not have the correct name!");
InitializeGameRules();
InitializeReplays();
_initialized = true;
}
public void PostInitialize()
{
DebugTools.Assert(_initialized);
DebugTools.Assert(!_postInitialized);
// We restart the round now that entities are initialized and prototypes have been loaded.
if (!DummyTicker)
RestartRound();
_postInitialized = true;
}
public override void Shutdown()
{
base.Shutdown();
ShutdownGameRules();
}
private void SendServerMessage(string message)
{
var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message));
_chatManager.ChatMessageToAll(ChatChannel.Server, message, wrappedMessage, default, false, true);
}
public override void Update(float frameTime)
{
if (DummyTicker)
return;
base.Update(frameTime);
UpdateRoundFlow(frameTime);
UpdateGameRules();
}
}
}