Fix replays continuing after desync
This commit is contained in:
committed by
Matthias Mailänder
parent
20a16ad5f8
commit
78677fd8ab
@@ -57,7 +57,9 @@ namespace OpenRA.Network
|
|||||||
bool generateSyncReport = false;
|
bool generateSyncReport = false;
|
||||||
int sentOrdersFrame = 0;
|
int sentOrdersFrame = 0;
|
||||||
float tickScale = 1f;
|
float tickScale = 1f;
|
||||||
bool outOfSync = false;
|
|
||||||
|
/// <Remarks> Should only be set in <see cref="OutOfSync"/></Remarks>
|
||||||
|
public bool IsOutOfSync { get; private set; } = false;
|
||||||
|
|
||||||
public struct ClientOrder
|
public struct ClientOrder
|
||||||
{
|
{
|
||||||
@@ -72,12 +74,12 @@ namespace OpenRA.Network
|
|||||||
|
|
||||||
void OutOfSync(int frame)
|
void OutOfSync(int frame)
|
||||||
{
|
{
|
||||||
if (outOfSync)
|
if (IsOutOfSync)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
syncReport.DumpSyncReport(frame);
|
syncReport.DumpSyncReport(frame);
|
||||||
World.OutOfSync();
|
World.OutOfSync();
|
||||||
outOfSync = true;
|
IsOutOfSync = true;
|
||||||
|
|
||||||
TextNotificationsManager.AddSystemLine($"Out of sync in frame {frame}.\nCompare syncreport.log with other players.");
|
TextNotificationsManager.AddSystemLine($"Out of sync in frame {frame}.\nCompare syncreport.log with other players.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -618,6 +618,9 @@ namespace OpenRA
|
|||||||
public void OutOfSync()
|
public void OutOfSync()
|
||||||
{
|
{
|
||||||
EndGame();
|
EndGame();
|
||||||
|
|
||||||
|
// In the event the replay goes out of sync, it becomes no longer usable. For polish we permanently pause the world.
|
||||||
|
ReplayTimestep = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,18 +45,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var speed = PlaybackSpeed.Regular;
|
var speed = PlaybackSpeed.Regular;
|
||||||
var originalTimestep = world.Timestep;
|
var originalTimestep = world.Timestep;
|
||||||
|
|
||||||
|
// In the event the replay goes out of sync, it becomes no longer usable. For polish we permanently pause the world.
|
||||||
|
Func<bool> isWidgetDisabled = () => orderManager.IsOutOfSync || orderManager.NetFrameNumber >= replayNetTicks;
|
||||||
|
|
||||||
var pauseButton = widget.Get<ButtonWidget>("BUTTON_PAUSE");
|
var pauseButton = widget.Get<ButtonWidget>("BUTTON_PAUSE");
|
||||||
pauseButton.IsVisible = () => world.ReplayTimestep != 0 && orderManager.NetFrameNumber < replayNetTicks;
|
pauseButton.IsVisible = () => world.ReplayTimestep != 0 && !isWidgetDisabled();
|
||||||
pauseButton.OnClick = () => world.ReplayTimestep = 0;
|
pauseButton.OnClick = () => world.ReplayTimestep = 0;
|
||||||
|
|
||||||
var playButton = widget.Get<ButtonWidget>("BUTTON_PLAY");
|
var playButton = widget.Get<ButtonWidget>("BUTTON_PLAY");
|
||||||
playButton.IsVisible = () => world.ReplayTimestep == 0 || orderManager.NetFrameNumber >= replayNetTicks;
|
playButton.IsVisible = () => world.ReplayTimestep == 0 || isWidgetDisabled();
|
||||||
playButton.OnClick = () => world.ReplayTimestep = (int)Math.Ceiling(originalTimestep * multipliers[speed]);
|
playButton.OnClick = () => world.ReplayTimestep = (int)Math.Ceiling(originalTimestep * multipliers[speed]);
|
||||||
playButton.IsDisabled = () => orderManager.NetFrameNumber >= replayNetTicks;
|
playButton.IsDisabled = isWidgetDisabled;
|
||||||
|
|
||||||
var slowButton = widget.Get<ButtonWidget>("BUTTON_SLOW");
|
var slowButton = widget.Get<ButtonWidget>("BUTTON_SLOW");
|
||||||
slowButton.IsHighlighted = () => speed == PlaybackSpeed.Slow;
|
slowButton.IsHighlighted = () => speed == PlaybackSpeed.Slow;
|
||||||
slowButton.IsDisabled = () => orderManager.NetFrameNumber >= replayNetTicks;
|
slowButton.IsDisabled = isWidgetDisabled;
|
||||||
slowButton.OnClick = () =>
|
slowButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
speed = PlaybackSpeed.Slow;
|
speed = PlaybackSpeed.Slow;
|
||||||
@@ -66,7 +69,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var normalSpeedButton = widget.Get<ButtonWidget>("BUTTON_REGULAR");
|
var normalSpeedButton = widget.Get<ButtonWidget>("BUTTON_REGULAR");
|
||||||
normalSpeedButton.IsHighlighted = () => speed == PlaybackSpeed.Regular;
|
normalSpeedButton.IsHighlighted = () => speed == PlaybackSpeed.Regular;
|
||||||
normalSpeedButton.IsDisabled = () => orderManager.NetFrameNumber >= replayNetTicks;
|
normalSpeedButton.IsDisabled = isWidgetDisabled;
|
||||||
normalSpeedButton.OnClick = () =>
|
normalSpeedButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
speed = PlaybackSpeed.Regular;
|
speed = PlaybackSpeed.Regular;
|
||||||
@@ -76,7 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var fastButton = widget.Get<ButtonWidget>("BUTTON_FAST");
|
var fastButton = widget.Get<ButtonWidget>("BUTTON_FAST");
|
||||||
fastButton.IsHighlighted = () => speed == PlaybackSpeed.Fast;
|
fastButton.IsHighlighted = () => speed == PlaybackSpeed.Fast;
|
||||||
fastButton.IsDisabled = () => orderManager.NetFrameNumber >= replayNetTicks;
|
fastButton.IsDisabled = isWidgetDisabled;
|
||||||
fastButton.OnClick = () =>
|
fastButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
speed = PlaybackSpeed.Fast;
|
speed = PlaybackSpeed.Fast;
|
||||||
@@ -86,7 +89,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var maximumButton = widget.Get<ButtonWidget>("BUTTON_MAXIMUM");
|
var maximumButton = widget.Get<ButtonWidget>("BUTTON_MAXIMUM");
|
||||||
maximumButton.IsHighlighted = () => speed == PlaybackSpeed.Maximum;
|
maximumButton.IsHighlighted = () => speed == PlaybackSpeed.Maximum;
|
||||||
maximumButton.IsDisabled = () => orderManager.NetFrameNumber >= replayNetTicks;
|
maximumButton.IsDisabled = isWidgetDisabled;
|
||||||
maximumButton.OnClick = () =>
|
maximumButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
speed = PlaybackSpeed.Maximum;
|
speed = PlaybackSpeed.Maximum;
|
||||||
|
|||||||
Reference in New Issue
Block a user