Fix overwriting Sandbox with stale cached version
This commit is contained in:
@@ -198,6 +198,12 @@ namespace Torch.Server.Managers
|
||||
|
||||
public void SaveConfig()
|
||||
{
|
||||
if (((TorchServer)Torch).HasRun)
|
||||
{
|
||||
Log.Warn("Checkpoint cache is stale, not saving dedicated config.");
|
||||
return;
|
||||
}
|
||||
|
||||
DedicatedConfig.Save(Path.Combine(Torch.Config.InstancePath, CONFIG_NAME));
|
||||
Log.Info("Saved dedicated config.");
|
||||
|
||||
|
@@ -41,7 +41,6 @@ namespace Torch.Server
|
||||
{
|
||||
private bool _canRun;
|
||||
private TimeSpan _elapsedPlayTime;
|
||||
private bool _hasRun;
|
||||
private bool _isRunning;
|
||||
private float _simRatio;
|
||||
private ServerState _state;
|
||||
@@ -65,6 +64,8 @@ namespace Torch.Server
|
||||
sessionManager.AddFactory(x => new MultiplayerManagerDedicated(this));
|
||||
}
|
||||
|
||||
public bool HasRun { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public float SimulationRatio { get => _simRatio; set => SetValue(ref _simRatio, value); }
|
||||
|
||||
@@ -120,7 +121,7 @@ namespace Torch.Server
|
||||
if (State != ServerState.Stopped)
|
||||
return;
|
||||
|
||||
if (_hasRun)
|
||||
if (IsRunning || HasRun)
|
||||
{
|
||||
Restart();
|
||||
return;
|
||||
@@ -129,7 +130,6 @@ namespace Torch.Server
|
||||
State = ServerState.Starting;
|
||||
IsRunning = true;
|
||||
CanRun = false;
|
||||
_hasRun = true;
|
||||
Log.Info("Starting server.");
|
||||
MySandboxGame.ConfigDedicated = DedicatedInstance.DedicatedConfig.Model;
|
||||
|
||||
@@ -144,6 +144,7 @@ namespace Torch.Server
|
||||
Log.Error("Server is already stopped");
|
||||
Log.Info("Stopping server.");
|
||||
base.Stop();
|
||||
HasRun = true;
|
||||
Log.Info("Server stopped.");
|
||||
|
||||
State = ServerState.Stopped;
|
||||
|
@@ -272,7 +272,6 @@ namespace Torch.Commands
|
||||
Debug.Assert(torch != null);
|
||||
torch.Stop();
|
||||
}, this, TaskContinuationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -230,7 +230,6 @@ namespace Torch
|
||||
MySandboxGame.Static.Invoke(action, caller);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void InvokeBlocking(Action action, int timeoutMs = -1, [CallerMemberName] string caller = "")
|
||||
|
Reference in New Issue
Block a user