diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index b4af0f25d4..8f33d9500e 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -58,7 +58,7 @@ namespace OpenRA static string ChooseReplayFilename() { - return DateTime.UtcNow.ToString("OpenRA-yyyy-MM-ddTHHmmssZ.rep"); + return DateTime.UtcNow.ToString("OpenRA-yyyy-MM-ddTHHmmssZ"); } static void JoinInner(OrderManager om) diff --git a/OpenRA.Game/Network/ReplayRecorderConnection.cs b/OpenRA.Game/Network/ReplayRecorderConnection.cs index c7aba98b6b..249574ac1c 100644 --- a/OpenRA.Game/Network/ReplayRecorderConnection.cs +++ b/OpenRA.Game/Network/ReplayRecorderConnection.cs @@ -34,12 +34,23 @@ namespace OpenRA.Network void StartSavingReplay(byte[] initialContent) { var filename = chooseFilename(); - var replayPath = Path.Combine(Platform.SupportDir, "Replays"); + var replaysDirectory = Path.Combine(Platform.SupportDir, "Replays"); - if (!Directory.Exists(replayPath)) - Directory.CreateDirectory(replayPath); + if (!Directory.Exists(replaysDirectory)) + Directory.CreateDirectory(replaysDirectory); - var file = File.Create(Path.Combine(replayPath, filename)); + string fullFilename; + var id = -1; + do + { + fullFilename = Path.Combine(replaysDirectory, id < 0 + ? "{0}.rep".F(filename) + : "{0}-{1}.rep".F(filename, id)); + id++; + } + while (File.Exists(fullFilename)); + + var file = File.Create(fullFilename); file.Write(initialContent); this.writer = new BinaryWriter(file); }