I recently noticed that my game cycle wasn't executing itself. If I reboot the server it can fix it, this is totally random and can take anywhere from 1 to 4 restarts to fix it. It seems to happen more when I git pull
before running the server, I have a feeling its connected to system time
I'm targeting DotNet core 3.1 on Ubuntu 18.06, and here is how I run my application.
dotnet build
dotnet run --project=Server
I've tested it on windows also, the same issue. I've also tested it on another Ubuntu machine and the same happens.
Here is the ccode
public class Game
{
private bool _cycleEnded;
private bool _cycleActive;
private Task _gameCycle;
private int _cycleSleepTime = 25;
public Game()
{
_gameCycle = new Task(GameCycle);
_gameCycle.Start();
_cycleActive = true;
}
private void GameCycle()
{
// Determine if the cycling is even happening?
Console.WriteLine("Attempting to cycle the game");
while (_cycleActive)
{
_cycleEnded = false;
Root.GetGame().GetRoomManager().OnCycle();
Root.GetGame().GetClientManager().OnCycle();
_cycleEnded = true;
Thread.Sleep(_cycleSleepTime);
}
}
}