Unhardcode starting maps
This commit is contained in:
@@ -48,7 +48,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
public class Global
|
public class Global
|
||||||
{
|
{
|
||||||
public string Map = "testmap";
|
public string Map;
|
||||||
public string[] Packages = {}; // filename:sha1 pairs.
|
public string[] Packages = {}; // filename:sha1 pairs.
|
||||||
public string[] Mods = { "ra" }; // mod names
|
public string[] Mods = { "ra" }; // mod names
|
||||||
public int OrderLatency = 3;
|
public int OrderLatency = 3;
|
||||||
@@ -63,6 +63,8 @@ namespace OpenRA.FileFormats
|
|||||||
Sequences, Chrome, Assemblies, ChromeLayout,
|
Sequences, Chrome, Assemblies, ChromeLayout,
|
||||||
Weapons, Voices, Terrain;
|
Weapons, Voices, Terrain;
|
||||||
|
|
||||||
|
public readonly string ShellmapUid;
|
||||||
|
|
||||||
public Manifest(string[] mods)
|
public Manifest(string[] mods)
|
||||||
{
|
{
|
||||||
var yaml = mods
|
var yaml = mods
|
||||||
@@ -79,6 +81,8 @@ namespace OpenRA.FileFormats
|
|||||||
Weapons = YamlList(yaml, "Weapons");
|
Weapons = YamlList(yaml, "Weapons");
|
||||||
Voices = YamlList(yaml, "Voices");
|
Voices = YamlList(yaml, "Voices");
|
||||||
Terrain = YamlList(yaml, "Terrain");
|
Terrain = YamlList(yaml, "Terrain");
|
||||||
|
|
||||||
|
ShellmapUid = yaml["ShellmapUid"].Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string[] YamlList(Dictionary<string, MiniYaml> ys, string key) { return ys[key].Nodes.Keys.ToArray(); }
|
static string[] YamlList(Dictionary<string, MiniYaml> ys, string key) { return ys[key].Nodes.Keys.ToArray(); }
|
||||||
|
|||||||
@@ -132,10 +132,6 @@ namespace OpenRA
|
|||||||
var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods);
|
var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods);
|
||||||
Timer.Time( "manifest: {0}" );
|
Timer.Time( "manifest: {0}" );
|
||||||
|
|
||||||
// TODO: Only do this on mod change
|
|
||||||
AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods);
|
|
||||||
Timer.Time( "maplist: {0}" );
|
|
||||||
|
|
||||||
Game.LoadModAssemblies(manifest);
|
Game.LoadModAssemblies(manifest);
|
||||||
Game.changePending = false;
|
Game.changePending = false;
|
||||||
Game.mapName = mapName;
|
Game.mapName = mapName;
|
||||||
@@ -165,7 +161,7 @@ namespace OpenRA
|
|||||||
Debug("Map change {0} -> {1}".F(Game.mapName, mapName));
|
Debug("Map change {0} -> {1}".F(Game.mapName, mapName));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Initialize(string mapName, Renderer renderer, int2 clientSize, int localPlayer, Controller controller)
|
internal static void Initialize(Renderer renderer, int2 clientSize, int localPlayer, Controller controller)
|
||||||
{
|
{
|
||||||
Game.renderer = renderer;
|
Game.renderer = renderer;
|
||||||
Game.clientSize = clientSize;
|
Game.clientSize = clientSize;
|
||||||
@@ -176,8 +172,9 @@ namespace OpenRA
|
|||||||
PerfHistory.items["text"].hasNormalTick = false;
|
PerfHistory.items["text"].hasNormalTick = false;
|
||||||
PerfHistory.items["cursor"].hasNormalTick = false;
|
PerfHistory.items["cursor"].hasNormalTick = false;
|
||||||
Game.controller = controller;
|
Game.controller = controller;
|
||||||
|
AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods);
|
||||||
|
|
||||||
ChangeMap(mapName);
|
ChangeMap(new Manifest(LobbyInfo.GlobalSettings.Mods).ShellmapUid);
|
||||||
|
|
||||||
if( Settings.Replay != "" )
|
if( Settings.Replay != "" )
|
||||||
orderManager = new OrderManager( new ReplayConnection( Settings.Replay ) );
|
orderManager = new OrderManager( new ReplayConnection( Settings.Replay ) );
|
||||||
@@ -217,6 +214,10 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
if (changePending && PackageDownloader.IsIdle())
|
if (changePending && PackageDownloader.IsIdle())
|
||||||
{
|
{
|
||||||
|
// TODO: Only do this on mod change
|
||||||
|
AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods);
|
||||||
|
Timer.Time( "maplist: {0}" );
|
||||||
|
|
||||||
ChangeMap(LobbyInfo.GlobalSettings.Map);
|
ChangeMap(LobbyInfo.GlobalSettings.Map);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -457,7 +458,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var current = Directory.GetCurrentDirectory();
|
var current = Directory.GetCurrentDirectory();
|
||||||
if (Directory.GetDirectoryRoot(current) == current)
|
if (Directory.GetDirectoryRoot(current) == current)
|
||||||
throw new InvalidOperationException("Unable to load MIX files.");
|
throw new InvalidOperationException("Unable to find game root.");
|
||||||
Directory.SetCurrentDirectory("..");
|
Directory.SetCurrentDirectory("..");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,7 +477,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
var controller = new Controller();
|
var controller = new Controller();
|
||||||
|
|
||||||
Game.Initialize(Game.Settings.Map, renderer, new int2(resolution), Game.Settings.Player, controller);
|
Game.Initialize(renderer, new int2(resolution), Game.Settings.Player, controller);
|
||||||
|
|
||||||
Game.ResetTimer();
|
Game.ResetTimer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ namespace OpenRA.GameRules
|
|||||||
// External game settings
|
// External game settings
|
||||||
public readonly string NetworkHost = "";
|
public readonly string NetworkHost = "";
|
||||||
public readonly int NetworkPort = 0;
|
public readonly int NetworkPort = 0;
|
||||||
public readonly string Map = "testmap";
|
|
||||||
public readonly int Player = 1;
|
public readonly int Player = 1;
|
||||||
public readonly string Replay = "";
|
public readonly string Replay = "";
|
||||||
public readonly string PlayerName = "";
|
public readonly string PlayerName = "";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Server
|
|||||||
static bool isInternetServer;
|
static bool isInternetServer;
|
||||||
static string masterServerUrl;
|
static string masterServerUrl;
|
||||||
|
|
||||||
public static void ServerMain(bool internetServer, string masterServerUrl, string name, int port, int extport, string[] mods)
|
public static void ServerMain(bool internetServer, string masterServerUrl, string name, int port, int extport, string[] mods, string map)
|
||||||
{
|
{
|
||||||
Server.masterServerUrl = masterServerUrl;
|
Server.masterServerUrl = masterServerUrl;
|
||||||
isInternetServer = internetServer;
|
isInternetServer = internetServer;
|
||||||
@@ -67,11 +67,14 @@ namespace OpenRA.Server
|
|||||||
lobbyInfo = new Session();
|
lobbyInfo = new Session();
|
||||||
lobbyInfo.GlobalSettings.Mods = mods;
|
lobbyInfo.GlobalSettings.Mods = mods;
|
||||||
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
|
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
|
||||||
|
lobbyInfo.GlobalSettings.Map = map;
|
||||||
|
|
||||||
Console.WriteLine("Initial mods: ");
|
Console.WriteLine("Initial mods: ");
|
||||||
foreach( var m in lobbyInfo.GlobalSettings.Mods )
|
foreach( var m in lobbyInfo.GlobalSettings.Mods )
|
||||||
Console.WriteLine("- {0}", m);
|
Console.WriteLine("- {0}", m);
|
||||||
|
|
||||||
|
Console.WriteLine("Initial map: {0}",lobbyInfo.GlobalSettings.Map);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
listener.Start();
|
listener.Start();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -19,7 +19,8 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
namespace OpenRA.Widgets.Delegates
|
namespace OpenRA.Widgets.Delegates
|
||||||
{
|
{
|
||||||
public class CreateServerMenuDelegate : WidgetDelegate
|
public class CreateServerMenuDelegate : WidgetDelegate
|
||||||
@@ -64,9 +65,19 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
Game.chrome.rootWidget.ShowMenu(null);
|
Game.chrome.rootWidget.ShowMenu(null);
|
||||||
Log.Write("Creating server");
|
Log.Write("Creating server");
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Get this from a map chooser
|
||||||
|
string map = Game.AvailableMaps.Keys.FirstOrDefault();
|
||||||
|
|
||||||
|
// TODO: Get this from a mod chooser
|
||||||
|
var mods = Game.Settings.InitialMods;
|
||||||
|
|
||||||
|
// TODO: Get this from a textbox
|
||||||
|
var gameName = Game.Settings.GameName;
|
||||||
|
|
||||||
Server.Server.ServerMain(AdvertiseServerOnline, Game.Settings.MasterServer,
|
Server.Server.ServerMain(AdvertiseServerOnline, Game.Settings.MasterServer,
|
||||||
Game.Settings.GameName, Game.Settings.ListenPort,
|
gameName, Game.Settings.ListenPort,
|
||||||
Game.Settings.ExternalPort, Game.Settings.InitialMods);
|
Game.Settings.ExternalPort, mods, map);
|
||||||
|
|
||||||
Log.Write("Joining server");
|
Log.Write("Joining server");
|
||||||
Game.JoinServer(IPAddress.Loopback.ToString(), Game.Settings.ListenPort);
|
Game.JoinServer(IPAddress.Loopback.ToString(), Game.Settings.ListenPort);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Uid: testmap
|
Uid: 97516324
|
||||||
|
|
||||||
MapFormat: 1
|
MapFormat: 1
|
||||||
|
|
||||||
|
|||||||
@@ -51,3 +51,5 @@ Voices:
|
|||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
mods/cnc/terrain.yaml
|
mods/cnc/terrain.yaml
|
||||||
|
|
||||||
|
ShellmapUid:119926504
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Uid: testmap
|
Uid: 45646351
|
||||||
|
|
||||||
MapFormat: 1
|
MapFormat: 1
|
||||||
|
|
||||||
|
|||||||
@@ -49,3 +49,5 @@ Voices:
|
|||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
mods/ra/terrain.yaml
|
mods/ra/terrain.yaml
|
||||||
|
|
||||||
|
ShellmapUid:1134734410
|
||||||
|
|||||||
Reference in New Issue
Block a user