Files
crystall-punk-14/Content.Server/Entry/EntryPoint.cs

248 lines
9.9 KiB
C#
Raw Normal View History

using Content.Server.Acz;
using Content.Server.Administration;
using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers;
using Content.Server.Afk;
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
using Content.Server.BugReports;
2021-06-09 22:19:39 +02:00
using Content.Server.Chat.Managers;
using Content.Server.Connection;
using Content.Server.Database;
using Content.Server.Discord.DiscordLink;
2021-06-09 22:19:39 +02:00
using Content.Server.EUI;
using Content.Server.GameTicking;
using Content.Server.GhostKick;
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
using Content.Server.Github;
using Content.Server.GuideGenerator;
using Content.Server.Info;
2021-06-09 22:19:39 +02:00
using Content.Server.IoC;
using Content.Server.Maps;
2021-06-09 22:19:39 +02:00
using Content.Server.NodeContainer.NodeGroups;
using Content.Server.Players.JobWhitelist;
using Content.Server.Players.PlayTimeTracking;
using Content.Server.Players.RateLimiting;
2021-06-09 22:19:39 +02:00
using Content.Server.Preferences.Managers;
2022-12-03 02:23:43 +01:00
using Content.Server.ServerInfo;
using Content.Server.ServerUpdates;
2021-06-09 22:19:39 +02:00
using Content.Server.Voting.Managers;
using Content.Shared.CCVar;
using Content.Shared.Kitchen;
using Content.Shared.Localizations;
using Robust.Server;
using Robust.Server.ServerStatus;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
2022-05-04 17:55:21 +01:00
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Server.Entry
{
public sealed class EntryPoint : GameServer
{
internal const string ConfigPresetsDir = "/ConfigPresets/";
2022-12-16 23:26:24 +01:00
private const string ConfigPresetsDirBuild = $"{ConfigPresetsDir}Build/";
private EuiManager _euiManager = default!;
private IVoteManager _voteManager = default!;
private ServerUpdateManager _updateManager = default!;
private PlayTimeTrackingManager? _playTimeTracking;
2022-08-15 08:17:50 +12:00
private IEntitySystemManager? _sysMan;
private IServerDbManager? _dbManager;
private IWatchlistWebhookManager _watchlistWebhookManager = default!;
private IConnectionManager? _connectionManager;
/// <inheritdoc />
public override void Init()
{
base.Init();
2022-12-16 23:26:24 +01:00
var cfg = IoCManager.Resolve<IConfigurationManager>();
var res = IoCManager.Resolve<IResourceManager>();
var logManager = IoCManager.Resolve<ILogManager>();
LoadConfigPresets(cfg, res, logManager.GetSawmill("configpreset"));
var aczProvider = new ContentMagicAczProvider(IoCManager.Resolve<IDependencyCollection>());
IoCManager.Resolve<IStatusHost>().SetMagicAczProvider(aczProvider);
var factory = IoCManager.Resolve<IComponentFactory>();
2022-05-04 17:55:21 +01:00
var prototypes = IoCManager.Resolve<IPrototypeManager>();
2019-07-31 15:02:36 +02:00
factory.DoAutoRegistrations();
factory.IgnoreMissingComponents("Visuals");
factory.RegisterIgnore(IgnoredComponents.List);
2022-05-04 17:55:21 +01:00
prototypes.RegisterIgnore("parallax");
ServerContentIoC.Register();
foreach (var callback in TestingCallbacks)
2019-06-29 01:58:16 +02:00
{
var cast = (ServerModuleTestingCallbacks) callback;
2019-06-29 01:58:16 +02:00
cast.ServerBeforeIoC?.Invoke();
}
IoCManager.BuildGraph();
factory.GenerateNetIds();
var configManager = IoCManager.Resolve<IConfigurationManager>();
var dest = configManager.GetCVar(CCVars.DestinationFile);
IoCManager.Resolve<ContentLocalizationManager>().Initialize();
if (string.IsNullOrEmpty(dest)) //hacky but it keeps load times for the generator down.
{
_euiManager = IoCManager.Resolve<EuiManager>();
_voteManager = IoCManager.Resolve<IVoteManager>();
_updateManager = IoCManager.Resolve<ServerUpdateManager>();
_playTimeTracking = IoCManager.Resolve<PlayTimeTrackingManager>();
_connectionManager = IoCManager.Resolve<IConnectionManager>();
2022-08-15 08:17:50 +12:00
_sysMan = IoCManager.Resolve<IEntitySystemManager>();
_dbManager = IoCManager.Resolve<IServerDbManager>();
_watchlistWebhookManager = IoCManager.Resolve<IWatchlistWebhookManager>();
logManager.GetSawmill("Storage").Level = LogLevel.Info;
logManager.GetSawmill("db.ef").Level = LogLevel.Info;
IoCManager.Resolve<IAdminLogManager>().Initialize();
IoCManager.Resolve<IConnectionManager>().Initialize();
_dbManager.Init();
IoCManager.Resolve<IServerPreferencesManager>().Init();
IoCManager.Resolve<INodeGroupFactory>().Initialize();
IoCManager.Resolve<ContentNetworkResourceManager>().Initialize();
IoCManager.Resolve<GhostKickManager>().Initialize();
2022-12-03 02:23:43 +01:00
IoCManager.Resolve<ServerInfoManager>().Initialize();
IoCManager.Resolve<ServerApi>().Initialize();
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
IoCManager.Resolve<GithubClient>().Initialize();
IoCManager.Resolve<GithubApiManager>().Initialize();
IoCManager.Resolve<GithubBackgroundWorker>().Initialize();
IoCManager.Resolve<IBugReportManager>().Initialize();
_voteManager.Initialize();
_updateManager.Initialize();
_playTimeTracking.Initialize();
_watchlistWebhookManager.Initialize();
IoCManager.Resolve<JobWhitelistManager>().Initialize();
IoCManager.Resolve<PlayerRateLimitManager>().Initialize();
}
}
public override void PostInit()
{
base.PostInit();
2022-01-19 13:35:31 +11:00
IoCManager.Resolve<IChatSanitizationManager>().Initialize();
IoCManager.Resolve<IChatManager>().Initialize();
var configManager = IoCManager.Resolve<IConfigurationManager>();
var resourceManager = IoCManager.Resolve<IResourceManager>();
var dest = configManager.GetCVar(CCVars.DestinationFile);
if (!string.IsNullOrEmpty(dest))
{
var resPath = new ResPath(dest).ToRootedPath();
var file = resourceManager.UserData.OpenWriteText(resPath.WithName("chem_" + dest));
ChemistryJsonGenerator.PublishJson(file);
file.Flush();
file = resourceManager.UserData.OpenWriteText(resPath.WithName("react_" + dest));
ReactionJsonGenerator.PublishJson(file);
file.Flush();
IoCManager.Resolve<IBaseServer>().Shutdown("Data generation done");
}
else
{
IoCManager.Resolve<RecipeManager>().Initialize();
IoCManager.Resolve<IAdminManager>().Initialize();
IoCManager.Resolve<IAfkManager>().Initialize();
IoCManager.Resolve<RulesManager>().Initialize();
IoCManager.Resolve<DiscordLink>().Initialize();
IoCManager.Resolve<DiscordChatLink>().Initialize();
_euiManager.Initialize();
IoCManager.Resolve<IGameMapManager>().Initialize();
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<GameTicker>().PostInitialize();
IoCManager.Resolve<IBanManager>().Initialize();
IoCManager.Resolve<IConnectionManager>().PostInit();
IoCManager.Resolve<MultiServerKickManager>().Initialize();
IoCManager.Resolve<CVarControlManager>().Initialize();
}
}
2019-08-04 01:08:55 +02:00
public override void Update(ModUpdateLevel level, FrameEventArgs frameEventArgs)
{
2019-08-04 01:08:55 +02:00
base.Update(level, frameEventArgs);
switch (level)
{
2020-11-10 16:50:28 +01:00
case ModUpdateLevel.PostEngine:
{
_euiManager.SendUpdates();
_voteManager.Update();
break;
}
case ModUpdateLevel.FramePostEngine:
_updateManager.Update();
_playTimeTracking?.Update();
_watchlistWebhookManager.Update();
_connectionManager?.Update();
break;
}
}
protected override void Dispose(bool disposing)
{
_playTimeTracking?.Shutdown();
_dbManager?.Shutdown();
IoCManager.Resolve<ServerApi>().Shutdown();
IoCManager.Resolve<DiscordLink>().Shutdown();
IoCManager.Resolve<DiscordChatLink>().Shutdown();
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
IoCManager.Resolve<IBugReportManager>().Shutdown();
}
2022-12-16 23:26:24 +01:00
private static void LoadConfigPresets(IConfigurationManager cfg, IResourceManager res, ISawmill sawmill)
{
LoadBuildConfigPresets(cfg, res, sawmill);
var presets = cfg.GetCVar(CCVars.ConfigPresets);
if (presets == "")
return;
foreach (var preset in presets.Split(','))
{
var path = $"{ConfigPresetsDir}{preset}.toml";
if (!res.TryContentFileRead(path, out var file))
{
sawmill.Error("Unable to load config preset {Preset}!", path);
continue;
}
cfg.LoadDefaultsFromTomlStream(file);
sawmill.Info("Loaded config preset: {Preset}", path);
}
}
private static void LoadBuildConfigPresets(IConfigurationManager cfg, IResourceManager res, ISawmill sawmill)
{
#if TOOLS
2022-12-16 23:26:24 +01:00
Load(CCVars.ConfigPresetDevelopment, "development");
#endif
#if DEBUG
Load(CCVars.ConfigPresetDebug, "debug");
#endif
#pragma warning disable CS8321
2022-12-16 23:26:24 +01:00
void Load(CVarDef<bool> cVar, string name)
{
var path = $"{ConfigPresetsDirBuild}{name}.toml";
if (cfg.GetCVar(cVar) && res.TryContentFileRead(path, out var file))
{
cfg.LoadDefaultsFromTomlStream(file);
sawmill.Info("Loaded config preset: {Preset}", path);
}
}
#pragma warning restore CS8321
2022-12-16 23:26:24 +01:00
}
}
}