diff --git a/OpenRA.Game/GameInformation.cs b/OpenRA.Game/GameInformation.cs index 7eaa02b6db..a2b88360a4 100644 --- a/OpenRA.Game/GameInformation.cs +++ b/OpenRA.Game/GameInformation.cs @@ -118,7 +118,7 @@ namespace OpenRA Color = runtimePlayer.Color, Team = client.Team, SpawnPoint = runtimePlayer.SpawnPoint, - IsRandomFaction = runtimePlayer.Country.Race != client.Country, + IsRandomFaction = runtimePlayer.Country.Race != client.Race, IsRandomSpawnPoint = runtimePlayer.SpawnPoint != client.SpawnPoint }; diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index a0a13b7720..8f0539df57 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -102,7 +102,7 @@ namespace OpenRA.Network public int Index; public HSLColor PreferredColor; // Color that the client normally uses from settings.yaml. public HSLColor Color; // Actual color that the client is using. Usually the same as PreferredColor but can be different on maps with locked colors. - public string Country; + public string Race; public int SpawnPoint; public string Name; public string IpAddress; diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index dec224bdc4..5c9a4daae0 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -154,7 +154,7 @@ namespace OpenRA.Network Name = Game.Settings.Player.Name, PreferredColor = Game.Settings.Player.Color, Color = Game.Settings.Player.Color, - Country = "random", + Race = "Random", SpawnPoint = 0, Team = 0, State = Session.ClientState.Invalid diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index 3cb52d7f53..a04346a9d2 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -52,8 +52,20 @@ namespace OpenRA .WithInterface().Where(c => !requireSelectable || c.Selectable) .ToList(); - return selectableCountries.FirstOrDefault(c => c.Race == name) + var selected = selectableCountries.FirstOrDefault(c => c.Race == name) ?? selectableCountries.Random(world.SharedRandom); + + // Don't loop infinite + for (var i = 0; i <= 10 && selected.RandomRaceMembers.Any(); i++) + { + var race = selected.RandomRaceMembers.Random(world.SharedRandom); + selected = selectableCountries.FirstOrDefault(c => c.Race == race); + + if (selected == null) + throw new YamlException("Unknown race: {0}".F(race)); + } + + return selected; } public Player(World world, Session.Client client, Session.Slot slot, PlayerReference pr) @@ -70,7 +82,7 @@ namespace OpenRA Color = client.Color; PlayerName = client.Name; botType = client.Bot; - Country = ChooseCountry(world, client.Country); + Country = ChooseCountry(world, client.Race); } else { diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 7636943d8a..7489035e20 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -64,7 +64,7 @@ namespace OpenRA.Server else c.Color = c.PreferredColor; if (pr.LockRace) - c.Country = pr.Race; + c.Race = pr.Race; if (pr.LockSpawn) c.SpawnPoint = pr.Spawn; if (pr.LockTeam) @@ -289,7 +289,7 @@ namespace OpenRA.Server Slot = LobbyInfo.FirstEmptySlot(), PreferredColor = handshake.Client.Color, Color = handshake.Client.Color, - Country = "random", + Race = "Random", SpawnPoint = 0, Team = 0, State = Session.ClientState.Invalid, diff --git a/OpenRA.Game/Traits/World/Country.cs b/OpenRA.Game/Traits/World/Country.cs index 0970a5ae60..e034874331 100644 --- a/OpenRA.Game/Traits/World/Country.cs +++ b/OpenRA.Game/Traits/World/Country.cs @@ -18,6 +18,9 @@ namespace OpenRA.Traits [Desc("This is the internal name for owner checks.")] public readonly string Race = null; + [Desc("Pick a random race as the player's race out of this list.")] + public readonly string[] RandomRaceMembers = { }; + [Desc("The side that the country belongs to. For example, England belongs to the 'Allies' side.")] public readonly string Side = null; diff --git a/OpenRA.Game/Widgets/MapPreviewWidget.cs b/OpenRA.Game/Widgets/MapPreviewWidget.cs index e64b316efb..4dec43de68 100644 --- a/OpenRA.Game/Widgets/MapPreviewWidget.cs +++ b/OpenRA.Game/Widgets/MapPreviewWidget.cs @@ -32,7 +32,7 @@ namespace OpenRA.Widgets ClientIndex = client.Index; PlayerName = client.Name; Team = client.Team; - Country = client.Country; + Country = client.Race; SpawnPoint = client.SpawnPoint; } diff --git a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs index 92f67dd5aa..8ee979efe3 100644 --- a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs @@ -270,7 +270,7 @@ namespace OpenRA.Mods.Common.Server Name = botType, Bot = botType, Slot = parts[0], - Country = "random", + Race = "Random", SpawnPoint = 0, Team = 0, State = Session.ClientState.NotReady, @@ -738,7 +738,7 @@ namespace OpenRA.Mods.Common.Server if (server.LobbyInfo.Slots[targetClient.Slot].LockRace) return true; - targetClient.Country = parts[1]; + targetClient.Race = parts[1]; server.SyncLobbyClients(); return true; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index 39ddcde156..d96accdeef 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -144,7 +144,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic colorPreview = lobby.Get("COLOR_MANAGER"); colorPreview.Color = Game.Settings.Player.Color; - countries.Add("random", new LobbyCountry { Name = "Any" }); foreach (var c in modRules.Actors["world"].Traits.WithInterface().Where(c => c.Selectable)) countries.Add(c.Race, new LobbyCountry { Name = c.Name, Side = c.Side, Description = c.Description }); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index 446bcb014c..163987b45d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic Func setupItem = (race, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, - () => client.Country == race, + () => client.Race == race, () => orderManager.IssueOrder(Order.Command("race {0} {1}".F(client.Index, race)))); var country = countries[race]; item.Get("LABEL").GetText = () => country.Name; @@ -398,7 +398,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var dropdown = parent.Get("FACTION"); dropdown.IsDisabled = () => s.LockRace || orderManager.LocalClient.IsReady; dropdown.OnMouseDown = _ => ShowRaceDropDown(dropdown, c, orderManager, countries); - var factionDescription = countries[c.Country].Description; + var factionDescription = countries[c.Race].Description; dropdown.GetTooltipText = () => factionDescription; SetupFactionWidget(dropdown, s, c, countries); } @@ -407,9 +407,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic Dictionary countries) { var factionName = parent.Get("FACTIONNAME"); - factionName.GetText = () => countries[c.Country].Name; + factionName.GetText = () => countries[c.Race].Name; var factionFlag = parent.Get("FACTIONFLAG"); - factionFlag.GetImageName = () => c.Country; + factionFlag.GetImageName = () => c.Race; factionFlag.GetImageCollection = () => "flags"; } diff --git a/mods/cnc/chrome.yaml b/mods/cnc/chrome.yaml index 07323716c3..0f8a6d2670 100644 --- a/mods/cnc/chrome.yaml +++ b/mods/cnc/chrome.yaml @@ -461,7 +461,7 @@ scrollbar: chrome.png flags: chrome.png nod: 352,0,32,16 gdi: 352,16,32,16 - random: 352,32,32,16 + Random: 352,32,32,16 strategic: strategic.png unowned: 0,0,32,32 diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml index c7d204aa70..b5c0ef80c8 100644 --- a/mods/cnc/rules/world.yaml +++ b/mods/cnc/rules/world.yaml @@ -81,6 +81,10 @@ World: FogVariants: typea, typeb, typec, typed OverrideFullShroud: full OverrideFullFog: full + Country@Random: + Name: Any + Race: Random + RandomRaceMembers: gdi, nod Country@gdi: Name: GDI Race: gdi diff --git a/mods/d2k/chrome.yaml b/mods/d2k/chrome.yaml index a8037bb792..135b297c9a 100644 --- a/mods/d2k/chrome.yaml +++ b/mods/d2k/chrome.yaml @@ -91,7 +91,7 @@ flags: buttons.png atreides: 0,114,22,21 harkonnen: 22,114,23,21 ordos: 45,114,22,21 - random: 67,114,23,21 + Random: 67,114,23,21 spectator: 67,114,23,21 # Used for the menu diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index fb2c37e5ee..5e270dcad6 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -94,6 +94,10 @@ World: OverrideFullShroud: full OverrideFullFog: full ShroudBlend: Multiply + Country@Random: + Name: Any + Race: Random + RandomRaceMembers: atreides, harkonnen, ordos Country@Atreides: Name: Atreides Race: atreides diff --git a/mods/ra/chrome.yaml b/mods/ra/chrome.yaml index 15cbcf9971..8bc287b2b1 100644 --- a/mods/ra/chrome.yaml +++ b/mods/ra/chrome.yaml @@ -471,7 +471,9 @@ strategic: strategic.png flags: buttons.png soviet: 0,112,30,15 allies: 30,112,30,15 - random: 60,112,30,15 + Random: 60,112,30,15 + RandomAllies: 30,172,30,15 + RandomSoviet: 0,172,30,15 spectator: 60,112,30,15 russia: 0,127,30,15 diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index a821e08fd1..cffc0e3592 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -126,6 +126,24 @@ World: Race: ukraine Side: Soviet Description: Ukraine: Demolitions\nSpecial Ability: Parabombs\nSpecial Unit: Demolition Truck + Country@random: + Name: Any + Race: Random + RandomRaceMembers: RandomAllies, RandomSoviet + Side: Random + Description: A random country. + Country@randomallies: + Name: Allied + Race: RandomAllies + RandomRaceMembers: allies, england, france, germany + Side: Random + Description: A random Allied country. + Country@randomsoviet: + Name: Soviet + Race: RandomSoviet + RandomRaceMembers: soviet, russia, ukraine + Side: Random + Description: A random Soviet country. DomainIndex: SmudgeLayer@SCORCH: Type: Scorch diff --git a/mods/ra/uibits/buttons.png b/mods/ra/uibits/buttons.png index e98f5306e1..ac725da6fb 100644 Binary files a/mods/ra/uibits/buttons.png and b/mods/ra/uibits/buttons.png differ diff --git a/mods/ts/chrome.yaml b/mods/ts/chrome.yaml index 4f08919a6a..03058d79e3 100644 --- a/mods/ts/chrome.yaml +++ b/mods/ts/chrome.yaml @@ -453,7 +453,7 @@ strategic: strategic.png flags: buttons.png gdi: 30,112,30,15 nod: 0,112,30,15 - random: 60,112,30,15 + Random: 60,112,30,15 spectator: 60,112,30,15 music: musicplayer.png diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index fc667cf5e2..05a4496782 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -79,6 +79,10 @@ World: VoxelNormalsPalette@normals: Name: normals Type: TiberianSun + Country@Random: + Name: Any + Race: Random + RandomRaceMembers: gdi, nod Country@0: Name: GDI Race: gdi