avoid magic number for replay duration calculation

This commit is contained in:
Matthias Mailänder
2013-10-16 21:09:45 +02:00
parent f51bd87332
commit f21f314bfe
3 changed files with 4 additions and 5 deletions

View File

@@ -75,7 +75,7 @@ namespace OpenRA
public static int RenderFrame = 0; public static int RenderFrame = 0;
public static int NetFrameNumber { get { return orderManager.NetFrameNumber; } } public static int NetFrameNumber { get { return orderManager.NetFrameNumber; } }
public static int LocalTick { get { return orderManager.LocalFrameNumber; } } public static int LocalTick { get { return orderManager.LocalFrameNumber; } }
const int NetTickScale = 3; // 120ms net tick for 40ms local tick public const int NetTickScale = 3; // 120ms net tick for 40ms local tick
public static event Action<OrderManager> ConnectionStateChanged = _ => { }; public static event Action<OrderManager> ConnectionStateChanged = _ => { };
static ConnectionState lastConnectionState = ConnectionState.PreConnecting; static ConnectionState lastConnectionState = ConnectionState.PreConnecting;

View File

@@ -13,7 +13,7 @@ using OpenRA.Network;
namespace OpenRA.Network namespace OpenRA.Network
{ {
/* a maze of twisty little hacks,... */ /* HACK: a maze of twisty little hacks... */
public class Replay public class Replay
{ {
public readonly string Filename; public readonly string Filename;
@@ -49,7 +49,7 @@ namespace OpenRA.Network
lastFrame = Math.Max(lastFrame, frame); lastFrame = Math.Max(lastFrame, frame);
}); });
Duration = lastFrame; Duration = lastFrame * Game.NetTickScale;
LobbyInfo = lobbyInfo; LobbyInfo = lobbyInfo;
} }
@@ -66,4 +66,3 @@ namespace OpenRA.Network
} }
} }
} }

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
currentMap = currentReplay.Map(); currentMap = currentReplay.Map();
panel.Get<LabelWidget>("DURATION").GetText = panel.Get<LabelWidget>("DURATION").GetText =
() => WidgetUtils.FormatTime(currentReplay.Duration * 3 /* TODO: 3:1 ratio isnt always true. */); () => WidgetUtils.FormatTime(currentReplay.Duration);
panel.Get<MapPreviewWidget>("MAP_PREVIEW").Map = () => currentMap; panel.Get<MapPreviewWidget>("MAP_PREVIEW").Map = () => currentMap;
panel.Get<LabelWidget>("MAP_TITLE").GetText = panel.Get<LabelWidget>("MAP_TITLE").GetText =
() => currentMap != null ? currentMap.Title : "(Unknown Map)"; () => currentMap != null ? currentMap.Title : "(Unknown Map)";