Unhardcode starting maps
This commit is contained in:
@@ -48,7 +48,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public class Global
|
||||
{
|
||||
public string Map = "testmap";
|
||||
public string Map;
|
||||
public string[] Packages = {}; // filename:sha1 pairs.
|
||||
public string[] Mods = { "ra" }; // mod names
|
||||
public int OrderLatency = 3;
|
||||
@@ -62,6 +62,8 @@ namespace OpenRA.FileFormats
|
||||
Folders, Packages, Rules,
|
||||
Sequences, Chrome, Assemblies, ChromeLayout,
|
||||
Weapons, Voices, Terrain;
|
||||
|
||||
public readonly string ShellmapUid;
|
||||
|
||||
public Manifest(string[] mods)
|
||||
{
|
||||
@@ -79,6 +81,8 @@ namespace OpenRA.FileFormats
|
||||
Weapons = YamlList(yaml, "Weapons");
|
||||
Voices = YamlList(yaml, "Voices");
|
||||
Terrain = YamlList(yaml, "Terrain");
|
||||
|
||||
ShellmapUid = yaml["ShellmapUid"].Value;
|
||||
}
|
||||
|
||||
static string[] YamlList(Dictionary<string, MiniYaml> ys, string key) { return ys[key].Nodes.Keys.ToArray(); }
|
||||
|
||||
@@ -131,11 +131,7 @@ namespace OpenRA
|
||||
|
||||
var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods);
|
||||
Timer.Time( "manifest: {0}" );
|
||||
|
||||
// TODO: Only do this on mod change
|
||||
AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods);
|
||||
Timer.Time( "maplist: {0}" );
|
||||
|
||||
|
||||
Game.LoadModAssemblies(manifest);
|
||||
Game.changePending = false;
|
||||
Game.mapName = mapName;
|
||||
@@ -165,7 +161,7 @@ namespace OpenRA
|
||||
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.clientSize = clientSize;
|
||||
@@ -176,8 +172,9 @@ namespace OpenRA
|
||||
PerfHistory.items["text"].hasNormalTick = false;
|
||||
PerfHistory.items["cursor"].hasNormalTick = false;
|
||||
Game.controller = controller;
|
||||
AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods);
|
||||
|
||||
ChangeMap(mapName);
|
||||
ChangeMap(new Manifest(LobbyInfo.GlobalSettings.Mods).ShellmapUid);
|
||||
|
||||
if( Settings.Replay != "" )
|
||||
orderManager = new OrderManager( new ReplayConnection( Settings.Replay ) );
|
||||
@@ -217,6 +214,10 @@ namespace OpenRA
|
||||
{
|
||||
if (changePending && PackageDownloader.IsIdle())
|
||||
{
|
||||
// TODO: Only do this on mod change
|
||||
AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods);
|
||||
Timer.Time( "maplist: {0}" );
|
||||
|
||||
ChangeMap(LobbyInfo.GlobalSettings.Map);
|
||||
return;
|
||||
}
|
||||
@@ -457,7 +458,7 @@ namespace OpenRA
|
||||
{
|
||||
var current = Directory.GetCurrentDirectory();
|
||||
if (Directory.GetDirectoryRoot(current) == current)
|
||||
throw new InvalidOperationException("Unable to load MIX files.");
|
||||
throw new InvalidOperationException("Unable to find game root.");
|
||||
Directory.SetCurrentDirectory("..");
|
||||
}
|
||||
|
||||
@@ -476,7 +477,7 @@ namespace OpenRA
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ namespace OpenRA.GameRules
|
||||
// External game settings
|
||||
public readonly string NetworkHost = "";
|
||||
public readonly int NetworkPort = 0;
|
||||
public readonly string Map = "testmap";
|
||||
public readonly int Player = 1;
|
||||
public readonly string Replay = "";
|
||||
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.
|
||||
* This file is part of OpenRA.
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Server
|
||||
static bool isInternetServer;
|
||||
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;
|
||||
isInternetServer = internetServer;
|
||||
@@ -67,11 +67,14 @@ namespace OpenRA.Server
|
||||
lobbyInfo = new Session();
|
||||
lobbyInfo.GlobalSettings.Mods = mods;
|
||||
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
|
||||
|
||||
lobbyInfo.GlobalSettings.Map = map;
|
||||
|
||||
Console.WriteLine("Initial mods: ");
|
||||
foreach( var m in lobbyInfo.GlobalSettings.Mods )
|
||||
Console.WriteLine("- {0}", m);
|
||||
|
||||
Console.WriteLine("Initial map: {0}",lobbyInfo.GlobalSettings.Map);
|
||||
|
||||
try
|
||||
{
|
||||
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.
|
||||
* This file is part of OpenRA.
|
||||
@@ -19,7 +19,8 @@
|
||||
#endregion
|
||||
|
||||
using System.Net;
|
||||
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class CreateServerMenuDelegate : WidgetDelegate
|
||||
@@ -63,10 +64,20 @@ namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
Game.chrome.rootWidget.ShowMenu(null);
|
||||
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,
|
||||
Game.Settings.GameName, Game.Settings.ListenPort,
|
||||
Game.Settings.ExternalPort, Game.Settings.InitialMods);
|
||||
gameName, Game.Settings.ListenPort,
|
||||
Game.Settings.ExternalPort, mods, map);
|
||||
|
||||
Log.Write("Joining server");
|
||||
Game.JoinServer(IPAddress.Loopback.ToString(), Game.Settings.ListenPort);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Uid: testmap
|
||||
Uid: 97516324
|
||||
|
||||
MapFormat: 1
|
||||
|
||||
|
||||
@@ -50,4 +50,6 @@ Voices:
|
||||
mods/cnc/voices.yaml:
|
||||
|
||||
Terrain:
|
||||
mods/cnc/terrain.yaml
|
||||
mods/cnc/terrain.yaml
|
||||
|
||||
ShellmapUid:119926504
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Uid: testmap
|
||||
Uid: 45646351
|
||||
|
||||
MapFormat: 1
|
||||
|
||||
|
||||
@@ -48,4 +48,6 @@ Voices:
|
||||
mods/ra/voices.yaml
|
||||
|
||||
Terrain:
|
||||
mods/ra/terrain.yaml
|
||||
mods/ra/terrain.yaml
|
||||
|
||||
ShellmapUid:1134734410
|
||||
|
||||
Reference in New Issue
Block a user