From f21f314bfea65654b65a04545749029b62f36ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Wed, 16 Oct 2013 21:09:45 +0200 Subject: [PATCH] avoid magic number for replay duration calculation --- OpenRA.Game/Game.cs | 2 +- OpenRA.Game/Network/Replay.cs | 5 ++--- OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index f8f6190e61..843930bd66 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -75,7 +75,7 @@ namespace OpenRA public static int RenderFrame = 0; public static int NetFrameNumber { get { return orderManager.NetFrameNumber; } } 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 ConnectionStateChanged = _ => { }; static ConnectionState lastConnectionState = ConnectionState.PreConnecting; diff --git a/OpenRA.Game/Network/Replay.cs b/OpenRA.Game/Network/Replay.cs index ec0f685ecb..bf165c5ecf 100644 --- a/OpenRA.Game/Network/Replay.cs +++ b/OpenRA.Game/Network/Replay.cs @@ -13,7 +13,7 @@ using OpenRA.Network; namespace OpenRA.Network { - /* a maze of twisty little hacks,... */ + /* HACK: a maze of twisty little hacks... */ public class Replay { public readonly string Filename; @@ -49,7 +49,7 @@ namespace OpenRA.Network lastFrame = Math.Max(lastFrame, frame); }); - Duration = lastFrame; + Duration = lastFrame * Game.NetTickScale; LobbyInfo = lobbyInfo; } @@ -66,4 +66,3 @@ namespace OpenRA.Network } } } - diff --git a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs index 4a7b1229af..c9e34d0937 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs @@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic currentMap = currentReplay.Map(); panel.Get("DURATION").GetText = - () => WidgetUtils.FormatTime(currentReplay.Duration * 3 /* TODO: 3:1 ratio isnt always true. */); + () => WidgetUtils.FormatTime(currentReplay.Duration); panel.Get("MAP_PREVIEW").Map = () => currentMap; panel.Get("MAP_TITLE").GetText = () => currentMap != null ? currentMap.Title : "(Unknown Map)";