Merge pull request #7987 from pchote/fix-player-bogosity
Fix random country display.
This commit is contained in:
@@ -27,7 +27,6 @@ namespace OpenRA
|
|||||||
|
|
||||||
public bool LockRace = false;
|
public bool LockRace = false;
|
||||||
public string Race;
|
public string Race;
|
||||||
public string RaceFlagName;
|
|
||||||
|
|
||||||
// ColorRamp naming retained for backward compatibility
|
// ColorRamp naming retained for backward compatibility
|
||||||
public bool LockColor = false;
|
public bool LockColor = false;
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ namespace OpenRA
|
|||||||
public readonly int ClientIndex;
|
public readonly int ClientIndex;
|
||||||
public readonly PlayerReference PlayerReference;
|
public readonly PlayerReference PlayerReference;
|
||||||
|
|
||||||
|
// The country (including Random, etc) that was selected in the lobby
|
||||||
|
public readonly CountryInfo DisplayCountry;
|
||||||
|
|
||||||
public WinState WinState = WinState.Undefined;
|
public WinState WinState = WinState.Undefined;
|
||||||
public bool IsBot;
|
public bool IsBot;
|
||||||
public int SpawnPoint;
|
public int SpawnPoint;
|
||||||
@@ -46,8 +49,6 @@ namespace OpenRA
|
|||||||
public Shroud Shroud;
|
public Shroud Shroud;
|
||||||
public World World { get; private set; }
|
public World World { get; private set; }
|
||||||
|
|
||||||
string selectedCountryName;
|
|
||||||
|
|
||||||
CountryInfo ChooseCountry(World world, string name, bool requireSelectable = true)
|
CountryInfo ChooseCountry(World world, string name, bool requireSelectable = true)
|
||||||
{
|
{
|
||||||
var selectableCountries = world.Map.Rules.Actors["world"].Traits
|
var selectableCountries = world.Map.Rules.Actors["world"].Traits
|
||||||
@@ -57,8 +58,6 @@ namespace OpenRA
|
|||||||
var selected = selectableCountries.FirstOrDefault(c => c.Race == name)
|
var selected = selectableCountries.FirstOrDefault(c => c.Race == name)
|
||||||
?? selectableCountries.Random(world.SharedRandom);
|
?? selectableCountries.Random(world.SharedRandom);
|
||||||
|
|
||||||
selectedCountryName = selected.Name;
|
|
||||||
|
|
||||||
// Don't loop infinite
|
// Don't loop infinite
|
||||||
for (var i = 0; i <= 10 && selected.RandomRaceMembers.Any(); i++)
|
for (var i = 0; i <= 10 && selected.RandomRaceMembers.Any(); i++)
|
||||||
{
|
{
|
||||||
@@ -87,8 +86,8 @@ namespace OpenRA
|
|||||||
PlayerName = client.Name;
|
PlayerName = client.Name;
|
||||||
botType = client.Bot;
|
botType = client.Bot;
|
||||||
Country = ChooseCountry(world, client.Race, !pr.LockRace);
|
Country = ChooseCountry(world, client.Race, !pr.LockRace);
|
||||||
pr.Race = selectedCountryName;
|
DisplayCountry = world.Map.Rules.Actors["world"].Traits
|
||||||
pr.RaceFlagName = client.Race;
|
.WithInterface<CountryInfo>().First(c => c.Race == client.Race);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -101,8 +100,8 @@ namespace OpenRA
|
|||||||
Spectating = pr.Spectating;
|
Spectating = pr.Spectating;
|
||||||
botType = pr.Bot;
|
botType = pr.Bot;
|
||||||
Country = ChooseCountry(world, pr.Race, false);
|
Country = ChooseCountry(world, pr.Race, false);
|
||||||
pr.RaceFlagName = pr.Race;
|
DisplayCountry = world.Map.Rules.Actors["world"].Traits
|
||||||
pr.Race = Country.Name;
|
.WithInterface<CountryInfo>().First(c => c.Race == pr.Race);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
|
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Name = "Everyone",
|
Name = "Everyone",
|
||||||
NonCombatant = true,
|
NonCombatant = true,
|
||||||
Spectating = true,
|
Spectating = true,
|
||||||
|
Race = "Random",
|
||||||
Allies = w.Players.Where(p => !p.NonCombatant && p.Playable).Select(p => p.InternalName).ToArray()
|
Allies = w.Players.Where(p => !p.NonCombatant && p.Playable).Select(p => p.InternalName).ToArray()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flag.GetImageName = () => pp.PlayerReference.RaceFlagName;
|
flag.GetImageName = () => pp.DisplayCountry.Race;
|
||||||
item.Get<LabelWidget>("FACTION").GetText = () => pp.PlayerReference.Race;
|
item.Get<LabelWidget>("FACTION").GetText = () => pp.DisplayCountry.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
var team = item.Get<LabelWidget>("TEAM");
|
var team = item.Get<LabelWidget>("TEAM");
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var flag = template.Get<ImageWidget>("FLAG");
|
var flag = template.Get<ImageWidget>("FLAG");
|
||||||
flag.GetImageCollection = () => "flags";
|
flag.GetImageCollection = () => "flags";
|
||||||
if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally)
|
if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally)
|
||||||
flag.GetImageName = () => player.PlayerReference.RaceFlagName;
|
flag.GetImageName = () => player.DisplayCountry.Race;
|
||||||
else
|
else
|
||||||
flag.GetImageName = () => player.Country.Race;
|
flag.GetImageName = () => player.Country.Race;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user