Fix classic SP maps failing to import into the editor

This commit is contained in:
Scott_NZ
2012-12-06 02:46:37 +13:00
parent 38db7d1e50
commit bb5212d2bb
3 changed files with 67 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
@@ -397,6 +397,7 @@ namespace OpenRA.Editor
map.ResizeCordon((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value, map.ResizeCordon((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value,
(int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value); (int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value);
map.Players.Clear();
map.MakeDefaultPlayers(); map.MakeDefaultPlayers();
NewMap(map); NewMap(map);
@@ -526,6 +527,7 @@ namespace OpenRA.Editor
void SetupDefaultPlayers(object sender, EventArgs e) void SetupDefaultPlayers(object sender, EventArgs e)
{ {
dirty = true; dirty = true;
surface1.Map.Players.Clear();
surface1.Map.MakeDefaultPlayers(); surface1.Map.MakeDefaultPlayers();
surface1.Chunks.Clear(); surface1.Chunks.Clear();

View File

@@ -162,7 +162,7 @@ namespace OpenRA.Editor
LoadSmudges(file, "SMUDGE"); LoadSmudges(file, "SMUDGE");
foreach (var p in Players) foreach (var p in Players)
LoadPlayer(file, p, (legacyMapFormat == IniMapFormat.RedAlert)); LoadPlayer(file, p);
var wps = file.GetSection("Waypoints") var wps = file.GetSection("Waypoints")
.Where(kv => int.Parse(kv.Value) > 0) .Where(kv => int.Parse(kv.Value) > 0)
@@ -412,10 +412,61 @@ namespace OpenRA.Editor
} }
} }
void LoadPlayer(IniFile file, string section, bool isRA) void LoadPlayer(IniFile file, string section)
{ {
var c = section == "BadGuy" ? "red" : string c;
isRA ? "blue" : "gold"; string race;
switch (section)
{
case "Spain":
c = "gold";
race = "allies";
break;
case "Greece":
c = "blue";
race = "allies";
break;
case "USSR":
c = "red";
race = "soviet";
break;
case "England":
c = "green";
race = "allies";
break;
case "Ukraine":
c = "orange";
race = "soviet";
break;
case "Germany":
c = "salmon";
race = "allies";
break;
case "France":
c = "teal";
race = "allies";
break;
case "Turkey":
c = "salmon";
race = "allies";
break;
case "GoodGuy":
c = "gold";
race = "gdi";
break;
case "BadGuy":
c = "red";
race = "nod";
break;
case "Neutral":
c = "neutral";
race = "allies";
break;
default:
c = "neutral";
race = "allies";
break;
}
var color = namedColorMapping[c]; var color = namedColorMapping[c];
@@ -424,7 +475,7 @@ namespace OpenRA.Editor
Name = section, Name = section,
OwnsWorld = section == "Neutral", OwnsWorld = section == "Neutral",
NonCombatant = section == "Neutral", NonCombatant = section == "Neutral",
Race = isRA ? (section == "BadGuy" ? "soviet" : "allies") : (section == "BadGuy" ? "nod" : "gdi"), Race = race,
ColorRamp = new ColorRamp( ColorRamp = new ColorRamp(
(byte)((color.First.GetHue() / 360.0f) * 255), (byte)((color.First.GetHue() / 360.0f) * 255),
(byte)(color.First.GetSaturation() * 255), (byte)(color.First.GetSaturation() * 255),

View File

@@ -385,18 +385,17 @@ namespace OpenRA
public void MakeDefaultPlayers() public void MakeDefaultPlayers()
{ {
Players.Clear();
var firstRace = OpenRA.Rules.Info["world"].Traits var firstRace = OpenRA.Rules.Info["world"].Traits
.WithInterface<CountryInfo>().First(c => c.Selectable).Race; .WithInterface<CountryInfo>().First(c => c.Selectable).Race;
Players.Add("Neutral", new PlayerReference if (!Players.ContainsKey("Neutral"))
{ Players.Add("Neutral", new PlayerReference
Name = "Neutral", {
Race = firstRace, Name = "Neutral",
OwnsWorld = true, Race = firstRace,
NonCombatant = true OwnsWorld = true,
}); NonCombatant = true
});
var numSpawns = GetSpawnPoints().Length; var numSpawns = GetSpawnPoints().Length;
for (var index = 0; index < numSpawns; index++) for (var index = 0; index < numSpawns; index++)