Revert "Load Maps on Round Start, not Round Restart. Shut down server if Round fails to Start 5 times. (#6977)" (#6980)

This reverts commit 4098f7fd9b.
This commit is contained in:
Moony
2022-03-03 13:34:16 -06:00
committed by GitHub
parent 4098f7fd9b
commit 255865b7b7
5 changed files with 17 additions and 51 deletions

View File

@@ -234,6 +234,8 @@ public sealed class AddTests : ContentIntegrationTest
await server.WaitIdleAsync();
var sDatabase = server.ResolveDependency<IServerDbManager>();
var sEntities = server.ResolveDependency<IEntityManager>();
var sMaps = server.ResolveDependency<IMapManager>();
var sSystems = server.ResolveDependency<IEntitySystemManager>();
var sAdminLogSystem = sSystems.GetEntitySystem<AdminLogSystem>();
@@ -243,7 +245,10 @@ public sealed class AddTests : ContentIntegrationTest
await server.WaitPost(() =>
{
sAdminLogSystem.Add(LogType.Unknown, $"test log: {guid}");
var coordinates = GetMainEntityCoordinates(sMaps);
var entity = sEntities.SpawnEntity(null, coordinates);
sAdminLogSystem.Add(LogType.Unknown, $"{entity} test log: {guid}");
});
await server.WaitPost(() =>
@@ -279,7 +284,8 @@ public sealed class AddTests : ContentIntegrationTest
await foreach (var json in sDatabase.GetAdminLogsJson(filter))
{
var root = json.RootElement;
Assert.That(root.TryGetProperty("entity", out _), Is.True);
Assert.That(root.TryGetProperty("guid", out _), Is.True);
json.Dispose();

View File

@@ -27,11 +27,6 @@ namespace Content.Server.GameTicking
[ViewVariables]
public float MaxStationOffset { get; private set; } = 0f;
#if EXCEPTION_TOLERANCE
[ViewVariables]
public int RoundStartFailShutdownCount { get; private set; } = 0;
#endif
private void InitializeCVars()
{
_configurationManager.OnValueChanged(CCVars.GameLobbyEnabled, value => LobbyEnabled = value, true);
@@ -42,9 +37,6 @@ namespace Content.Server.GameTicking
_configurationManager.OnValueChanged(CCVars.StationOffset, value => StationOffset = value, true);
_configurationManager.OnValueChanged(CCVars.StationRotation, value => StationRotation = value, true);
_configurationManager.OnValueChanged(CCVars.MaxStationOffset, value => MaxStationOffset = value, true);
#if EXCEPTION_TOLERANCE
_configurationManager.OnValueChanged(CCVars.RoundStartFailShutdownCount, value => RoundStartFailShutdownCount = value, true);
#endif
}
}
}

View File

@@ -14,7 +14,6 @@ using Content.Shared.GameTicking;
using Content.Shared.Preferences;
using Content.Shared.Station;
using Prometheus;
using Robust.Server;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -40,10 +39,7 @@ namespace Content.Server.GameTicking
"ss14_round_length",
"Round length in seconds.");
#if EXCEPTION_TOLERANCE
[ViewVariables]
private int _roundStartFailCount = 0;
#endif
[Dependency] private readonly IServerDbManager _db = default!;
[ViewVariables]
private TimeSpan _roundStartTimeSpan;
@@ -194,8 +190,6 @@ namespace Content.Server.GameTicking
SendServerMessage(Loc.GetString("game-ticker-start-round"));
LoadMaps();
StartGamePresetRules();
RoundLengthMetric.Set(0);
@@ -264,24 +258,11 @@ namespace Content.Server.GameTicking
}
catch(Exception e)
{
_roundStartFailCount++;
if (RoundStartFailShutdownCount > 0 && _roundStartFailCount >= RoundStartFailShutdownCount)
{
Logger.FatalS("ticker", $"Failed to start a round {_roundStartFailCount} time(s) in a row... Shutting down!");
_runtimeLog.LogException(e, nameof(GameTicker));
_baseServer.Shutdown("Restarting server");
return;
}
Logger.WarningS("ticker", $"Exception caught while trying to start the round! Restarting round...");
Logger.WarningS("ticker", $"Exception caught while trying to start the round! Restarting...");
_runtimeLog.LogException(e, nameof(GameTicker));
RestartRound();
return;
}
// Round started successfully! Reset counter...
_roundStartFailCount = 0;
#endif
}
@@ -392,6 +373,7 @@ namespace Content.Server.GameTicking
RunLevel = GameRunLevel.PreRoundLobby;
LobbySong = _robustRandom.Pick(_lobbyMusicCollection.PickFiles).ToString();
ResettingCleanup();
LoadMaps();
if (!LobbyEnabled)
{
@@ -429,18 +411,18 @@ namespace Content.Server.GameTicking
unCastData.ContentData()?.WipeMind();
}
_startingRound = false;
_mapManager.Restart();
// Delete all remaining entities.
foreach (var entity in EntityManager.GetEntities().ToArray())
// Delete all entities.
foreach (var entity in EntityManager.GetEntities().ToList())
{
// TODO: Maybe something less naive here?
// FIXME: Actually, definitely.
EntityManager.DeleteEntity(entity);
}
_startingRound = false;
_mapManager.Restart();
_roleBanManager.Restart();
// Clear up any game rules.

View File

@@ -2,7 +2,6 @@ using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers;
using Content.Server.CharacterAppearance.Systems;
using Content.Server.Chat.Managers;
using Content.Server.Database;
using Content.Server.Ghost;
using Content.Server.Maps;
using Content.Server.PDA;
@@ -90,7 +89,6 @@ namespace Content.Server.GameTicking
[Dependency] private readonly IBaseServer _baseServer = default!;
[Dependency] private readonly IWatchdogApi _watchdogApi = default!;
[Dependency] private readonly IGameMapManager _gameMapManager = default!;
[Dependency] private readonly IServerDbManager _db = default!;
#if EXCEPTION_TOLERANCE
[Dependency] private readonly IRuntimeLog _runtimeLog = default!;
#endif

View File

@@ -60,9 +60,6 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<bool>
EventsEnabled = CVarDef.Create("events.enabled", true, CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// Disables most functionality in the GameTicker.
/// </summary>
public static readonly CVarDef<bool>
GameDummyTicker = CVarDef.Create("game.dummyticker", false, CVar.ARCHIVE | CVar.SERVERONLY);
@@ -157,15 +154,6 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<int> SoftMaxPlayers =
CVarDef.Create("game.soft_max_players", 30, CVar.SERVERONLY | CVar.ARCHIVE);
#if EXCEPTION_TOLERANCE
/// <summary>
/// Amount of times round start must fail before the server is shut down.
/// Set to 0 or a negative number to disable.
/// </summary>
public static readonly CVarDef<int> RoundStartFailShutdownCount =
CVarDef.Create("game.round_start_fail_shutdown_count", 5, CVar.SERVERONLY | CVar.SERVER);
#endif
/*
* Discord
*/