Fix player palette double-add bug
This commit is contained in:
@@ -356,6 +356,10 @@ namespace OpenRa
|
||||
var d = left ? +1 : Player.PlayerColors.Count() - 1;
|
||||
|
||||
var newIndex = ((int)Game.world.LocalPlayer.PaletteIndex + d) % Player.PlayerColors.Count();
|
||||
|
||||
Game.IssueOrder(
|
||||
Order.Chat("color count " + Player.PlayerColors.Count()));
|
||||
|
||||
while (!PaletteAvailable(newIndex) && newIndex != (int)Game.world.LocalPlayer.PaletteIndex)
|
||||
newIndex = (newIndex + d) % Player.PlayerColors.Count();
|
||||
|
||||
|
||||
@@ -65,7 +65,9 @@ namespace OpenRa
|
||||
Timer.Time( "load rules: {0}" );
|
||||
|
||||
world = null; // trying to access the old world will NRE, rather than silently doing it wrong.
|
||||
Player.ResetPlayerColorList();
|
||||
world = new World();
|
||||
|
||||
Game.world.ActorAdded += a =>
|
||||
{
|
||||
if (a.Owner != null && a.Info.Traits.Contains<OwnedActorInfo>())
|
||||
|
||||
@@ -30,8 +30,16 @@ namespace OpenRa
|
||||
public World World { get { return PlayerActor.World; } }
|
||||
|
||||
public static List<Tuple<string, string, Color>> PlayerColors = new List<Tuple<string, string, Color>>();
|
||||
public static void ResetPlayerColorList()
|
||||
{
|
||||
// This is unsafe if the mapchange introduces/removes mods that defines new colors
|
||||
// TODO: ensure that each player's palette index is reassigned appropriately
|
||||
PlayerColors = new List<Tuple<string, string, Color>>();
|
||||
}
|
||||
|
||||
public static void RegisterPlayerColor(string palette, string name, Color c)
|
||||
{
|
||||
Log.Write("Adding player color {0}",name);
|
||||
PlayerColors.Add(new Tuple<string, string, Color>(palette, name, c));
|
||||
}
|
||||
|
||||
@@ -58,7 +66,7 @@ namespace OpenRa
|
||||
this.PlayerName = client != null ? client.Name : "Player {0}".F(index+1);
|
||||
this.Race = client != null ? (Race)client.Race : Race.Allies;
|
||||
}
|
||||
|
||||
|
||||
void UpdatePower()
|
||||
{
|
||||
var oldBalance = PowerProvided - PowerDrained;
|
||||
|
||||
Reference in New Issue
Block a user