refactor game joining; add replay joining support
This commit is contained in:
@@ -52,29 +52,36 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void JoinServer(string host, int port)
|
public static void JoinServer(string host, int port)
|
||||||
{
|
{
|
||||||
if (orderManager != null) orderManager.Dispose();
|
|
||||||
|
|
||||||
var replayFilename = ChooseReplayFilename();
|
var replayFilename = ChooseReplayFilename();
|
||||||
string path = Path.Combine( Game.SupportDir, "Replays" );
|
string path = Path.Combine( Game.SupportDir, "Replays" );
|
||||||
if( !Directory.Exists( path ) ) Directory.CreateDirectory( path );
|
if( !Directory.Exists( path ) ) Directory.CreateDirectory( path );
|
||||||
var replayFile = File.Create( Path.Combine( path, replayFilename ) );
|
var replayFile = File.Create( Path.Combine( path, replayFilename ) );
|
||||||
|
|
||||||
orderManager = new OrderManager( host, port, new ReplayRecorderConnection( new NetworkConnection( host, port ), replayFile ) );
|
JoinInner(new OrderManager(host, port,
|
||||||
lastConnectionState = ConnectionState.PreConnecting;
|
new ReplayRecorderConnection(new NetworkConnection(host, port), replayFile)));
|
||||||
ConnectionStateChanged(orderManager);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static string ChooseReplayFilename()
|
static string ChooseReplayFilename()
|
||||||
{
|
{
|
||||||
return DateTime.UtcNow.ToString("OpenRA-yyyy-MM-ddThhmmssZ.rep");
|
return DateTime.UtcNow.ToString("OpenRA-yyyy-MM-ddThhmmssZ.rep");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void JoinLocal()
|
static void JoinInner(OrderManager om)
|
||||||
{
|
{
|
||||||
if (orderManager != null) orderManager.Dispose();
|
if (orderManager != null) orderManager.Dispose();
|
||||||
orderManager = new OrderManager("<no server>", -1, new EchoConnection());
|
orderManager = om;
|
||||||
lastConnectionState = ConnectionState.PreConnecting;
|
lastConnectionState = ConnectionState.PreConnecting;
|
||||||
ConnectionStateChanged( orderManager );
|
ConnectionStateChanged(orderManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void JoinReplay(string replayFile)
|
||||||
|
{
|
||||||
|
JoinInner(new OrderManager("<no server>", -1, new ReplayConnection(replayFile)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void JoinLocal()
|
||||||
|
{
|
||||||
|
JoinInner(new OrderManager("<no server>", -1, new EchoConnection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int RenderFrame = 0;
|
public static int RenderFrame = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user