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