Change LoadMapSettings to accept a Ruleset.

This commit is contained in:
Paul Chote
2016-03-09 18:27:20 +00:00
parent d7bdc840d6
commit 43a3d42d31
2 changed files with 10 additions and 10 deletions

View File

@@ -1013,28 +1013,28 @@ namespace OpenRA.Mods.Common.Server
};
}
public static void LoadMapSettings(Session.Global gs, Map map)
public static void LoadMapSettings(Session.Global gs, Ruleset rules)
{
var devMode = map.Rules.Actors["player"].TraitInfo<DeveloperModeInfo>();
var devMode = rules.Actors["player"].TraitInfo<DeveloperModeInfo>();
gs.AllowCheats = devMode.Enabled;
var crateSpawner = map.Rules.Actors["world"].TraitInfoOrDefault<CrateSpawnerInfo>();
var crateSpawner = rules.Actors["world"].TraitInfoOrDefault<CrateSpawnerInfo>();
gs.Crates = crateSpawner != null && crateSpawner.Enabled;
var shroud = map.Rules.Actors["player"].TraitInfo<ShroudInfo>();
var shroud = rules.Actors["player"].TraitInfo<ShroudInfo>();
gs.Fog = shroud.FogEnabled;
gs.Shroud = !shroud.ExploredMapEnabled;
var resources = map.Rules.Actors["player"].TraitInfo<PlayerResourcesInfo>();
var resources = rules.Actors["player"].TraitInfo<PlayerResourcesInfo>();
gs.StartingCash = resources.DefaultCash;
var startingUnits = map.Rules.Actors["world"].TraitInfoOrDefault<SpawnMPUnitsInfo>();
var startingUnits = rules.Actors["world"].TraitInfoOrDefault<SpawnMPUnitsInfo>();
gs.StartingUnitsClass = startingUnits == null ? "none" : startingUnits.StartingUnitsClass;
var mapBuildRadius = map.Rules.Actors["world"].TraitInfoOrDefault<MapBuildRadiusInfo>();
var mapBuildRadius = rules.Actors["world"].TraitInfoOrDefault<MapBuildRadiusInfo>();
gs.AllyBuildRadius = mapBuildRadius != null && mapBuildRadius.AllyBuildRadiusEnabled;
var mapOptions = map.Rules.Actors["world"].TraitInfo<MapOptionsInfo>();
var mapOptions = rules.Actors["world"].TraitInfo<MapOptionsInfo>();
gs.ShortGame = mapOptions.ShortGameEnabled;
gs.TechLevel = mapOptions.TechLevel;
gs.Difficulty = mapOptions.Difficulty ?? mapOptions.Difficulties.FirstOrDefault();
@@ -1050,7 +1050,7 @@ namespace OpenRA.Mods.Common.Server
.Where(s => s != null)
.ToDictionary(s => s.PlayerReference, s => s);
LoadMapSettings(server.LobbyInfo.GlobalSettings, server.Map);
LoadMapSettings(server.LobbyInfo.GlobalSettings, server.Map.Rules);
}
static HSLColor SanitizePlayerColor(S server, HSLColor askedColor, int playerIndex, Connection connectionToEcho = null)

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Server
return;
var defaults = new Session.Global();
LobbyCommands.LoadMapSettings(defaults, server.Map);
LobbyCommands.LoadMapSettings(defaults, server.Map.Rules);
if (server.LobbyInfo.GlobalSettings.AllowCheats != defaults.AllowCheats)
server.SendOrderTo(conn, "Message", "Allow Cheats: {0}".F(server.LobbyInfo.GlobalSettings.AllowCheats));