From c512626ab0bd7609b242987c6ba2f54361db5e72 Mon Sep 17 00:00:00 2001 From: Matthew Bowra-Dean Date: Sat, 27 Mar 2010 23:16:16 +1300 Subject: [PATCH] Fixed crash on large palette indexes. --- OpenRA.Game/Chrome.cs | 2 +- OpenRA.Game/Graphics/Minimap.cs | 2 +- OpenRA.Game/Player.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs index a822cd71ed..36ac7ab43f 100644 --- a/OpenRA.Game/Chrome.cs +++ b/OpenRA.Game/Chrome.cs @@ -512,7 +512,7 @@ namespace OpenRA paletteRect.Top + Game.viewport.Location.Y + 5, paletteRect.Right + Game.viewport.Location.X - 5, paletteRect.Bottom+Game.viewport.Location.Y - 5), - Player.PlayerColors[client.PaletteIndex].c); + Player.PlayerColors[client.PaletteIndex % Player.PlayerColors.Count()].c); lineRenderer.Flush(); f.DrawText(rgbaRenderer, client.Country, new int2(r.Left + 220, y), Color.White); f.DrawText(rgbaRenderer, client.State.ToString(), new int2(r.Left + 290, y), Color.White); diff --git a/OpenRA.Game/Graphics/Minimap.cs b/OpenRA.Game/Graphics/Minimap.cs index b20d77ef51..5f710ac7be 100644 --- a/OpenRA.Game/Graphics/Minimap.cs +++ b/OpenRA.Game/Graphics/Minimap.cs @@ -194,7 +194,7 @@ namespace OpenRA.Graphics lineRenderer.FillRect(new RectangleF( Game.viewport.Location.X + pos.X + 2, Game.viewport.Location.Y + pos.Y + 2, - 12, 12), Player.PlayerColors[ p.Second.PaletteIndex ].c); + 12, 12), Player.PlayerColors[ p.Second.PaletteIndex % Player.PlayerColors.Count() ].c); rgbaRenderer.DrawSprite(ownedSpawnPoint, pos, "chrome"); } diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index 3c7b151dfe..672ff81bd8 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -73,8 +73,8 @@ namespace OpenRA if (client != null) { Index = client.Index; - Palette = PlayerColors[client.PaletteIndex].a; - Color = PlayerColors[client.PaletteIndex].c; + Palette = PlayerColors[client.PaletteIndex % PlayerColors.Count()].a; + Color = PlayerColors[client.PaletteIndex % PlayerColors.Count()].c; PlayerName = client.Name; InternalName = "Multi{0}".F(client.Index); }