retain race, name across map change

This commit is contained in:
Chris Forbes
2009-12-22 21:59:14 +13:00
parent f57865bd32
commit cabdb40147
2 changed files with 8 additions and 3 deletions

View File

@@ -61,8 +61,11 @@ namespace OpenRa.Game
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
var race = players.ContainsKey(i) ? players[i].Race : Race.Allies;
var name = players.ContainsKey(i) ? players[i].PlayerName : "Player {0}".F(i+1);
var a = new Actor(null, new int2(int.MaxValue, int.MaxValue), null); var a = new Actor(null, new int2(int.MaxValue, int.MaxValue), null);
players[i] = new Player(a, i, i, "Multi{0}".F(i), Race.Allies); players[i] = new Player(a, i, i, name, race, "Multi{0}".F(i));
a.Owner = players[i]; a.Owner = players[i];
a.traits.Add(new Traits.ProductionQueue(a)); a.traits.Add(new Traits.ProductionQueue(a));
Game.world.Add(a); Game.world.Add(a);
@@ -133,7 +136,7 @@ namespace OpenRa.Game
var parts = s.Value.Split( ',' ); var parts = s.Value.Split( ',' );
var loc = int.Parse(parts[3]); var loc = int.Parse(parts[3]);
world.Add(new Actor(Rules.UnitInfo[parts[1].ToLowerInvariant()], new int2(loc % 128, loc / 128), world.Add(new Actor(Rules.UnitInfo[parts[1].ToLowerInvariant()], new int2(loc % 128, loc / 128),
players.Values.FirstOrDefault(p => p.PlayerName == parts[0]) ?? players[0])); players.Values.FirstOrDefault(p => p.InternalName == parts[0]) ?? players[0]));
} }
} }

View File

@@ -14,6 +14,7 @@ namespace OpenRa.Game
public int Palette; public int Palette;
public int Kills; public int Kills;
public string PlayerName; public string PlayerName;
public string InternalName;
public Race Race; public Race Race;
public readonly int Index; public readonly int Index;
public int Cash; public int Cash;
@@ -25,11 +26,12 @@ namespace OpenRa.Game
public bool IsReady; public bool IsReady;
public Player( Actor playerActor, int index, int palette, string playerName, Race race ) public Player( Actor playerActor, int index, int palette, string playerName, Race race, string internalName )
{ {
this.PlayerActor = playerActor; this.PlayerActor = playerActor;
this.Index = index; this.Index = index;
this.Palette = palette; this.Palette = palette;
this.InternalName = internalName;
this.PlayerName = playerName; this.PlayerName = playerName;
this.Race = race; this.Race = race;
this.Cash = 10000; this.Cash = 10000;