diff --git a/OpenRA.Server/Server.cs b/OpenRA.Server/Server.cs index cbf8cf2d9f..38e7f32e01 100644 --- a/OpenRA.Server/Server.cs +++ b/OpenRA.Server/Server.cs @@ -108,7 +108,7 @@ namespace OpenRA.Server Index = newConn.PlayerIndex, PaletteIndex = ChooseFreePalette(), Name = "Player {0}".F(1 + newConn.PlayerIndex), - Race = 1, + Race = "allies", /* hack */ State = Session.ClientState.NotReady }); @@ -249,14 +249,7 @@ namespace OpenRA.Server return true; } - int race; - if (!int.TryParse(s, out race) || race < 0 || race > 1) - { - Console.WriteLine("Invalid race: {0}", s); - return false; - } - - GetClient(conn).Race = 1 + race; + GetClient(conn).Race = s; SyncLobbyInfo(); return true; }}, diff --git a/OpenRa.FileFormats/Session.cs b/OpenRa.FileFormats/Session.cs index a89080cc33..87a459764a 100644 --- a/OpenRa.FileFormats/Session.cs +++ b/OpenRa.FileFormats/Session.cs @@ -21,7 +21,7 @@ namespace OpenRa.FileFormats { public int Index; public int PaletteIndex; - public int Race; + public string Race; public int SpawnPoint; public string Name; public ClientState State; diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index 0d4c6a5606..c4ce21670d 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -153,10 +153,10 @@ namespace OpenRa { DrawDownloadBar(); - chromeCollection = (world.LocalPlayer.Race == Race.Allies) ? "chrome-allies" : "chrome-soviet"; - radarCollection = (world.LocalPlayer.Race == Race.Allies) ? "radar-allies" : "radar-soviet"; - paletteCollection = (world.LocalPlayer.Race == Race.Allies) ? "palette-allies" : "palette-soviet"; - digitCollection = (world.LocalPlayer.Race == Race.Allies) ? "digits-allies" : "digits-soviet"; + chromeCollection = "chrome-" + world.LocalPlayer.Race; + radarCollection = "radar-" + world.LocalPlayer.Race; + paletteCollection = "palette-" + world.LocalPlayer.Race; + digitCollection = "digits-" + world.LocalPlayer.Race; buttons.Clear(); @@ -362,8 +362,9 @@ namespace OpenRa void CycleRace(bool left) { - Game.IssueOrder( - Order.Chat("/race " + (((int)Game.world.LocalPlayer.Race - 1) ^ 1))); + // hack + var newRace = Game.world.LocalPlayer.Race == RaceUtil.Allies ? RaceUtil.Soviet : RaceUtil.Allies; + Game.IssueOrder(Order.Chat("/race " + newRace)); } void CycleReady(bool left) @@ -466,7 +467,7 @@ namespace OpenRa paletteRect.Bottom+Game.viewport.Location.Y - 5), Player.PlayerColors[client.PaletteIndex].c); lineRenderer.Flush(); - renderer.DrawText(((Race)client.Race).ToString(), new int2(r.Left + 220, y), Color.White); + renderer.DrawText(client.Race, new int2(r.Left + 220, y), Color.White); renderer.DrawText(client.State.ToString(), new int2(r.Left + 290, y), Color.White); renderer.DrawText((client.SpawnPoint == 0)? "-" : client.SpawnPoint.ToString(), new int2(r.Left + 410, y), Color.White); y += 30; @@ -568,7 +569,7 @@ namespace OpenRa string[] tabKeys = { "normal", "ready", "selected" }; var producing = queue.CurrentItem(groupName); var index = q.Key == currentTab ? 2 : (producing != null && producing.Done) ? 1 : 0; - var race = (world.LocalPlayer.Race == Race.Allies) ? "allies" : "soviet"; + var race = world.LocalPlayer.Race; rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer,"tabs-"+tabKeys[index], race+"-"+q.Key), new float2(x, y), "chrome"); buttons.Add(Pair.New(new RectangleF(x, y, tabWidth, tabHeight), diff --git a/OpenRa.Game/Combat.cs b/OpenRa.Game/Combat.cs index 7146fe1fc8..469d78abe4 100644 --- a/OpenRa.Game/Combat.cs +++ b/OpenRa.Game/Combat.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using OpenRa.GameRules; using OpenRa.Effects; +using OpenRa.GameRules; using OpenRa.Traits; namespace OpenRa diff --git a/OpenRa.Game/GameRules/VoiceInfo.cs b/OpenRa.Game/GameRules/VoiceInfo.cs index 8505ecaf26..4526dd09db 100644 --- a/OpenRa.Game/GameRules/VoiceInfo.cs +++ b/OpenRa.Game/GameRules/VoiceInfo.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using IjwFramework.Types; -using IjwFramework.Collections; namespace OpenRa.GameRules { diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index 613f8d92a3..86c1233cab 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -1,11 +1,9 @@ using System; -using System.Linq; using System.Collections.Generic; -using OpenRa.GameRules; -using OpenRa.Graphics; -using OpenRa.Traits; -using OpenRa.FileFormats; using System.Drawing; +using System.Linq; +using OpenRa.FileFormats; +using OpenRa.Traits; namespace OpenRa { @@ -18,7 +16,7 @@ namespace OpenRa public int Kills; public string PlayerName; public string InternalName; - public Race Race; + public string Race; public readonly int Index; public int Cash = 10000; public int Ore = 0; @@ -64,7 +62,7 @@ namespace OpenRa this.PaletteIndex = client != null ? client.PaletteIndex : index; this.PlayerName = client != null ? client.Name : "Player {0}".F(index+1); - this.Race = client != null ? (Race)client.Race : Race.Allies; + this.Race = client != null ? client.Race : RaceUtil.Allies; } void UpdatePower() @@ -179,10 +177,10 @@ namespace OpenRa PlayerName = client.Name; } - if (Race != (Race)client.Race) + if (Race != client.Race) { - Game.chat.AddLine(this, "is now playing {0}".F((Race)client.Race)); - Race = (Race)client.Race; + Game.chat.AddLine(this, "is now playing {0}".F(client.Race)); + Race = client.Race; } if (PaletteIndex != client.PaletteIndex) diff --git a/OpenRa.Game/Race.cs b/OpenRa.Game/Race.cs index c83771921d..77d39f1c65 100644 --- a/OpenRa.Game/Race.cs +++ b/OpenRa.Game/Race.cs @@ -2,11 +2,20 @@ using System; namespace OpenRa { - [Flags] - public enum Race + public static class RaceUtil { - None = 0, - Allies = 1, - Soviet = 2 + /* just while we do the transition */ + public static readonly string Allies = "allies"; + public static readonly string Soviet = "soviet"; + + public static readonly string DefaultRace = Allies; } + + //[Flags] + //public enum Race + //{ + // None = 0, + // Allies = 1, + // Soviet = 2 + //} } diff --git a/OpenRa.Game/Sound.cs b/OpenRa.Game/Sound.cs index c5ee0417bc..fac9cd4b96 100644 --- a/OpenRa.Game/Sound.cs +++ b/OpenRa.Game/Sound.cs @@ -1,10 +1,9 @@ using System; +using System.Collections.Generic; using IjwFramework.Collections; using OpenRa.FileFormats; -using OpenRa.Traits; using OpenRa.Support; -using System.Runtime.InteropServices; -using System.Collections.Generic; +using OpenRa.Traits; namespace OpenRa { @@ -110,7 +109,7 @@ namespace OpenRa return; } - var variants = (voicedUnit.Owner.Race == Race.Soviet) + var variants = (voicedUnit.Owner.Race == RaceUtil.Soviet) ? vi.SovietVariants : vi.AlliedVariants; var variant = variants[voicedUnit.ActorID % variants.Length]; diff --git a/OpenRa.Game/Traits/Buildable.cs b/OpenRa.Game/Traits/Buildable.cs index 28c6d408e3..51e91269bd 100755 --- a/OpenRa.Game/Traits/Buildable.cs +++ b/OpenRa.Game/Traits/Buildable.cs @@ -10,7 +10,7 @@ namespace OpenRa.Traits public readonly int TechLevel = -1; public readonly string[] Prerequisites = { }; public readonly string[] BuiltAt = { }; - public readonly Race[] Owner = { }; + public readonly string[] Owner = { }; public readonly int Cost = 0; public readonly string Description = ""; public readonly string LongDesc = "";