Remove direct access to MapPreview.Rules.
This commit is contained in:
@@ -86,11 +86,13 @@ namespace OpenRA
|
||||
public MapVisibility Visibility;
|
||||
|
||||
Lazy<Ruleset> rules;
|
||||
public Ruleset Rules => rules?.Value;
|
||||
public bool InvalidCustomRules { get; private set; }
|
||||
public bool DefinesUnsafeCustomRules { get; private set; }
|
||||
public bool RulesLoaded { get; private set; }
|
||||
|
||||
public ActorInfo WorldActorInfo => rules?.Value.Actors[SystemActors.World];
|
||||
public ActorInfo PlayerActorInfo => rules?.Value.Actors[SystemActors.Player];
|
||||
|
||||
public void SetRulesetGenerator(ModData modData, Func<(Ruleset Ruleset, bool DefinesUnsafeCustomRules)> generator)
|
||||
{
|
||||
InvalidCustomRules = false;
|
||||
@@ -154,16 +156,18 @@ namespace OpenRA
|
||||
public MapClassification Class => innerData.Class;
|
||||
public MapVisibility Visibility => innerData.Visibility;
|
||||
|
||||
public Ruleset Rules => innerData.Rules;
|
||||
public bool InvalidCustomRules => innerData.InvalidCustomRules;
|
||||
public bool RulesLoaded => innerData.RulesLoaded;
|
||||
|
||||
public ActorInfo WorldActorInfo => innerData.WorldActorInfo;
|
||||
public ActorInfo PlayerActorInfo => innerData.PlayerActorInfo;
|
||||
|
||||
public bool DefinesUnsafeCustomRules
|
||||
{
|
||||
get
|
||||
{
|
||||
// Force lazy rules to be evaluated
|
||||
var force = innerData.Rules;
|
||||
var force = innerData.WorldActorInfo;
|
||||
return innerData.DefinesUnsafeCustomRules;
|
||||
}
|
||||
}
|
||||
@@ -338,7 +342,7 @@ namespace OpenRA
|
||||
|
||||
public void PreloadRules()
|
||||
{
|
||||
var unused = Rules;
|
||||
var unused = WorldActorInfo;
|
||||
}
|
||||
|
||||
public void UpdateRemoteSearch(MapStatus status, MiniYaml yaml, Action<MapPreview> parseMetadata = null)
|
||||
|
||||
@@ -1209,7 +1209,7 @@ namespace OpenRA.Server
|
||||
// The null padding is needed to keep the player indexes in sync with world.Players on the clients
|
||||
// This will need to change if future code wants to use worldPlayers for other purposes
|
||||
var playerRandom = new MersenneTwister(LobbyInfo.GlobalSettings.RandomSeed);
|
||||
foreach (var cmpi in Map.Rules.Actors[SystemActors.World].TraitInfos<ICreatePlayersInfo>())
|
||||
foreach (var cmpi in Map.WorldActorInfo.TraitInfos<ICreatePlayersInfo>())
|
||||
cmpi.CreateServerPlayers(Map, LobbyInfo, worldPlayers, playerRandom);
|
||||
|
||||
if (recorder != null)
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Traits
|
||||
[Desc("Display order for the explore map checkbox in the lobby.")]
|
||||
public readonly int ExploredMapCheckboxDisplayOrder = 0;
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
yield return new LobbyBooleanOption("explored", ExploredMapCheckboxLabel, ExploredMapCheckboxDescription,
|
||||
ExploredMapCheckboxVisible, ExploredMapCheckboxDisplayOrder, ExploredMapCheckboxEnabled, ExploredMapCheckboxLocked);
|
||||
|
||||
@@ -530,7 +530,7 @@ namespace OpenRA.Traits
|
||||
[RequireExplicitImplementation]
|
||||
public interface ILobbyOptions : ITraitInfoInterface
|
||||
{
|
||||
IEnumerable<LobbyOption> LobbyOptions(Ruleset rules);
|
||||
IEnumerable<LobbyOption> LobbyOptions(MapPreview map);
|
||||
}
|
||||
|
||||
public class LobbyOption
|
||||
|
||||
Reference in New Issue
Block a user