Fix first round after a server restart being displayed as number 0 (#14194)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameTicking.Events;
|
||||
using Content.Server.GameTicking.Presets;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
using Content.Server.Ghost.Components;
|
||||
@@ -241,6 +243,27 @@ namespace Content.Server.GameTicking
|
||||
mind.TransferTo(ghost);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void IncrementRoundNumber()
|
||||
{
|
||||
var playerIds = _playerGameStatuses.Keys.Select(player => player.UserId).ToArray();
|
||||
var serverName = _configurationManager.GetCVar(CCVars.AdminLogsServerName);
|
||||
|
||||
// TODO FIXME AAAAAAAAAAAAAAAAAAAH THIS IS BROKEN
|
||||
// Task.Run as a terrible dirty workaround to avoid synchronization context deadlock from .Result here.
|
||||
// This whole setup logic should be made asynchronous so we can properly wait on the DB AAAAAAAAAAAAAH
|
||||
var task = Task.Run(async () =>
|
||||
{
|
||||
var server = await _db.AddOrGetServer(serverName);
|
||||
return await _db.AddNewRound(server, playerIds);
|
||||
});
|
||||
|
||||
_taskManager.BlockWaitOnTask(task);
|
||||
RoundId = task.GetAwaiter().GetResult();
|
||||
|
||||
var startingEvent = new RoundStartingEvent(RoundId);
|
||||
RaiseLocalEvent(startingEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class GhostAttemptHandleEvent : HandledEntityEventArgs
|
||||
|
||||
Reference in New Issue
Block a user