allow custom masterserver URL

This commit is contained in:
Chris Forbes
2010-03-15 15:49:42 +13:00
parent fd23407792
commit 845bbf0f39
3 changed files with 6 additions and 3 deletions

View File

@@ -154,7 +154,7 @@ namespace OpenRA
internal static void CreateServer() internal static void CreateServer()
{ {
// todo: LobbyInfo is the wrong place for this. // todo: LobbyInfo is the wrong place for this.
Server.Server.ServerMain(Settings.InternetServer, Settings.GameName, Settings.ListenPort, Server.Server.ServerMain(Settings.InternetServer, Settings.MasterServer, Settings.GameName, Settings.ListenPort,
Settings.ExternalPort, LobbyInfo.GlobalSettings.Mods); Settings.ExternalPort, LobbyInfo.GlobalSettings.Mods);
JoinServer(IPAddress.Loopback.ToString(), Settings.ListenPort); JoinServer(IPAddress.Loopback.ToString(), Settings.ListenPort);

View File

@@ -49,6 +49,7 @@ namespace OpenRA.GameRules
public readonly int ListenPort = 1234; public readonly int ListenPort = 1234;
public readonly int ExternalPort = 1234; public readonly int ExternalPort = 1234;
public readonly bool InternetServer = true; public readonly bool InternetServer = true;
public readonly string MasterServer = "http://open-ra.org/master/";
// Gameplay options // Gameplay options
// TODO: These need to die // TODO: These need to die

View File

@@ -51,9 +51,11 @@ namespace OpenRA.Server
// of leeway. // of leeway.
static int lastPing = 0; static int lastPing = 0;
static bool isInternetServer; static bool isInternetServer;
static string masterServerUrl;
public static void ServerMain(bool internetServer, string name, int port, int extport, string[] mods) public static void ServerMain(bool internetServer, string masterServerUrl, string name, int port, int extport, string[] mods)
{ {
Server.masterServerUrl = masterServerUrl;
isInternetServer = internetServer; isInternetServer = internetServer;
listener = new TcpListener(IPAddress.Any, port); listener = new TcpListener(IPAddress.Any, port);
initialMods = mods; initialMods = mods;
@@ -561,7 +563,7 @@ namespace OpenRA.Server
if (wc.IsBusy || !isInternetServer) return; if (wc.IsBusy || !isInternetServer) return;
wc.DownloadDataAsync(new Uri( wc.DownloadDataAsync(new Uri(
"http://open-ra.org/master/ping.php?port={0}&name={1}&state={2}&players={3}&mods={4}&map={5}".F( masterServerUrl + "ping.php?port={0}&name={1}&state={2}&players={3}&mods={4}&map={5}".F(
ExternalPort, Uri.EscapeUriString(Name), ExternalPort, Uri.EscapeUriString(Name),
GameStarted ? 2 : 1, // todo: post-game states, etc. GameStarted ? 2 : 1, // todo: post-game states, etc.
lobbyInfo.Clients.Count, lobbyInfo.Clients.Count,