From 63467cd0007dc648ee88213b51b6482c051ba1d8 Mon Sep 17 00:00:00 2001 From: Scott_NZ Date: Sat, 2 Mar 2013 16:18:09 +1300 Subject: [PATCH] Revert client colours to their preferred colours after the map is changed to a map which doesn't lock colours. --- OpenRA.Game/Network/Session.cs | 4 +++- OpenRA.Game/Network/UnitOrders.cs | 1 + OpenRA.Game/Server/Server.cs | 2 ++ OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index f911449363..7e63d9ba4a 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -42,7 +42,9 @@ namespace OpenRA.Network public class Client { public int Index; - public ColorRamp ColorRamp; + public ColorRamp PreferredColorRamp; // Color that the client normally uses from settings.yaml. + public ColorRamp ColorRamp; // Actual color that the client is using. + // Usually the same as PreferredColorRamp but can be different on maps with locked colors. public string Country; public int SpawnPoint; public string Name; diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index 8f0c4a6bf5..cdd06bb41e 100755 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -119,6 +119,7 @@ namespace OpenRA.Network var info = new Session.Client() { Name = Game.Settings.Player.Name, + PreferredColorRamp = Game.Settings.Player.ColorRamp, ColorRamp = Game.Settings.Player.ColorRamp, Country = "random", SpawnPoint = 0, diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 54eef011f2..478b12085a 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -374,6 +374,8 @@ namespace OpenRA.Server return; if (pr.LockColor) c.ColorRamp = pr.ColorRamp; + else + c.ColorRamp = c.PreferredColorRamp; if (pr.LockRace) c.Country = pr.Race; if (pr.LockSpawn) diff --git a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs index c2313dfaa8..1530fcb925 100644 --- a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs @@ -230,7 +230,7 @@ namespace OpenRA.Mods.RA.Server var hue = (byte)server.Random.Next(255); var sat = (byte)server.Random.Next(255); var lum = (byte)server.Random.Next(51,255); - bot.ColorRamp = new ColorRamp(hue, sat, lum, 10); + bot.ColorRamp = bot.PreferredColorRamp = new ColorRamp(hue, sat, lum, 10); server.lobbyInfo.Clients.Add(bot); } @@ -472,7 +472,7 @@ namespace OpenRA.Mods.RA.Server return true; var ci = parts[1].Split(',').Select(cc => int.Parse(cc)).ToArray(); - targetClient.ColorRamp = new ColorRamp((byte)ci[0], (byte)ci[1], (byte)ci[2], (byte)ci[3]); + targetClient.ColorRamp = targetClient.PreferredColorRamp = new ColorRamp((byte)ci[0], (byte)ci[1], (byte)ci[2], (byte)ci[3]); server.SyncLobbyInfo(); return true; }}