diff --git a/OpenRA.Game/Network/Replay.cs b/OpenRA.Game/Network/Replay.cs
deleted file mode 100644
index a62f628860..0000000000
--- a/OpenRA.Game/Network/Replay.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-#region Copyright & License Information
-/*
- * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
- * This file is part of OpenRA, which is free software. It is made
- * available to you under the terms of the GNU General Public License
- * as published by the Free Software Foundation. For more information,
- * see COPYING.
- */
-#endregion
-
-using System;
-
-namespace OpenRA.Network
-{
- public class Replay
- {
- public readonly string Filename;
- public readonly int Duration;
- public readonly Session LobbyInfo;
-
- public Replay(string filename)
- {
- Filename = filename;
-
- using (var conn = new ReplayConnection(filename))
- {
- Duration = conn.TickCount * Game.NetTickScale;
- LobbyInfo = conn.LobbyInfo;
- }
- }
-
- public Map Map()
- {
- if (LobbyInfo == null)
- return null;
-
- var map = LobbyInfo.GlobalSettings.Map;
- return Game.modData.MapCache[map].Map;
- }
- }
-}
diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index 0085f53d30..c0d217d017 100644
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -129,7 +129,6 @@
-
diff --git a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs
index a1a23ff6a2..38d1c009bb 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs
@@ -19,6 +19,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class ReplayBrowserLogic
{
Widget panel;
+ MapPreview selectedMap = MapCache.UnknownMap;
+ string selectedFilename;
+ string selectedDuration;
+ string selectedPlayers;
+ bool selectedValid;
[ObjectCreator.UseCtor]
public ReplayBrowserLogic(Widget widget, Action onExit, Action onStart)
@@ -44,15 +49,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
var watch = panel.Get("WATCH_BUTTON");
- watch.IsDisabled = () => currentReplay == null || currentMap == null || currentReplay.Duration == 0;
+ watch.IsDisabled = () => !selectedValid || selectedMap.Status != MapStatus.Available;
watch.OnClick = () => { WatchReplay(); onStart(); };
- panel.Get("REPLAY_INFO").IsVisible = () => currentReplay != null;
+ panel.Get("REPLAY_INFO").IsVisible = () => selectedFilename != null;;
+ panel.Get("DURATION").GetText = () => selectedDuration;
+ panel.Get("MAP_PREVIEW").Preview = () => selectedMap;
+ panel.Get("MAP_TITLE").GetText = () => selectedMap.Title;
+ panel.Get("PLAYERS").GetText = () => selectedPlayers;
}
- Replay currentReplay;
- MapPreview currentMap = MapCache.UnknownMap;
-
void SelectReplay(string filename)
{
if (filename == null)
@@ -60,32 +66,31 @@ namespace OpenRA.Mods.RA.Widgets.Logic
try
{
- currentReplay = new Replay(filename);
- currentMap = Game.modData.MapCache[currentReplay.LobbyInfo.GlobalSettings.Map];
-
- panel.Get("DURATION").GetText =
- () => WidgetUtils.FormatTime(currentReplay.Duration);
- panel.Get("MAP_PREVIEW").Preview = () => currentMap;
- panel.Get("MAP_TITLE").GetText =
- () => currentMap != null ? currentMap.Title : "(Unknown Map)";
-
- var players = currentReplay.LobbyInfo.Slots
- .Count(s => currentReplay.LobbyInfo.ClientInSlot(s.Key) != null);
- panel.Get("PLAYERS").GetText = () => players.ToString();
+ using (var conn = new ReplayConnection(filename))
+ {
+ selectedFilename = filename;
+ selectedMap = Game.modData.MapCache[conn.LobbyInfo.GlobalSettings.Map];
+ selectedDuration = WidgetUtils.FormatTime(conn.TickCount * Game.NetTickScale);
+ selectedPlayers = conn.LobbyInfo.Slots
+ .Count(s => conn.LobbyInfo.ClientInSlot(s.Key) != null)
+ .ToString();
+ selectedValid = conn.TickCount > 0;
+ }
}
catch (Exception e)
{
Log.Write("debug", "Exception while parsing replay: {0}", e);
- currentReplay = null;
- currentMap = MapCache.UnknownMap;
+ selectedFilename = null;
+ selectedValid = false;
+ selectedMap = MapCache.UnknownMap;
}
}
void WatchReplay()
{
- if (currentReplay != null)
+ if (selectedFilename != null)
{
- Game.JoinReplay(currentReplay.Filename);
+ Game.JoinReplay(selectedFilename);
Ui.CloseWindow();
}
}
@@ -93,7 +98,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
void AddReplay(ScrollPanelWidget list, string filename, ScrollItemWidget template)
{
var item = ScrollItemWidget.Setup(template,
- () => currentReplay != null && currentReplay.Filename == filename,
+ () => selectedFilename == filename,
() => SelectReplay(filename),
() => WatchReplay());
var f = Path.GetFileName(filename);