Remove obsolete Player index cruft
This commit is contained in:
@@ -128,7 +128,7 @@ namespace OpenRA
|
||||
{
|
||||
if( player != null )
|
||||
return player;
|
||||
return world.players.Values.First( x => x.InternalName == PlayerName );
|
||||
return world.Players.First( x => x.InternalName == PlayerName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace OpenRA.Network
|
||||
/* todo: this is still a hack.
|
||||
* the cases we're trying to avoid are the extra players on the host's client -- Neutral, other MapPlayers,
|
||||
* bots,.. */
|
||||
return world.players.Values.FirstOrDefault(
|
||||
p => p.ClientIndex == c.Index && p.PlayerName == c.Name);
|
||||
return world.Players.FirstOrDefault(
|
||||
p => (p.ClientIndex == c.Index && p.PlayerRef.Playable && !p.IsBot));
|
||||
}
|
||||
|
||||
public static void ProcessOrder(OrderManager orderManager, World world, int clientId, Order order)
|
||||
@@ -151,8 +151,8 @@ namespace OpenRA.Network
|
||||
if (Game.orderManager.LobbyInfo.GlobalSettings.LockTeams)
|
||||
return;
|
||||
|
||||
var targetPlayer = order.Player.World.players[order.TargetLocation.X];
|
||||
var newStance = (Stance)order.TargetLocation.Y;
|
||||
var targetPlayer = order.Player.World.Players.FirstOrDefault(p => p.InternalName == order.TargetString);
|
||||
var newStance = (Stance)order.TargetLocation.X;
|
||||
|
||||
SetPlayerStance(world, order.Player, targetPlayer, newStance);
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace OpenRA
|
||||
public readonly string PlayerName;
|
||||
public readonly string InternalName;
|
||||
public readonly CountryInfo Country;
|
||||
public readonly int Index;
|
||||
public readonly bool NonCombatant = false;
|
||||
public readonly int ClientIndex;
|
||||
public readonly PlayerReference PlayerRef;
|
||||
@@ -40,10 +39,9 @@ namespace OpenRA
|
||||
public Shroud Shroud { get { return World.LocalShroud; }}
|
||||
public World World { get; private set; }
|
||||
|
||||
public Player(World world, Session.Client client, PlayerReference pr, int index)
|
||||
public Player(World world, Session.Client client, PlayerReference pr)
|
||||
{
|
||||
World = world;
|
||||
Index = index;
|
||||
InternalName = pr.Name;
|
||||
PlayerRef = pr;
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA
|
||||
public static int hash_player( Player p )
|
||||
{
|
||||
if( p != null )
|
||||
return p.Index * 0x567;
|
||||
return (int)( p.PlayerActor.ActorID << 16 ) * 0x567;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
var anim = new Animation(RenderSimple.GetImage(building, Tileset), () => 0);
|
||||
anim.PlayRepeating("idle");
|
||||
yield return new Renderable(anim.Image, 0.5f * anim.Image.size * (1 - Scale), Palette ?? PlayerPalette + owner.Index, 0, Scale);
|
||||
yield return new Renderable(anim.Image, 0.5f * anim.Image.size * (1 - Scale), Palette ?? PlayerPalette + owner.InternalName, 0, Scale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Traits
|
||||
Info = self.Info.Traits.Get<RenderSimpleInfo>();
|
||||
}
|
||||
|
||||
public string Palette(Player p) { return Info.Palette ?? Info.PlayerPalette + p.Index; }
|
||||
public string Palette(Player p) { return Info.Palette ?? Info.PlayerPalette + p.InternalName; }
|
||||
|
||||
public virtual IEnumerable<Renderable> Render(Actor self)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public void InitPalette( WorldRenderer wr )
|
||||
{
|
||||
var paletteName = "{0}{1}".F( info.BaseName, owner.Index );
|
||||
var paletteName = "{0}{1}".F( info.BaseName, owner.InternalName );
|
||||
var newpal = new Palette(wr.GetPalette(info.BasePalette),
|
||||
new PlayerColorRemap(owner.ColorRamp, info.PaletteFormat));
|
||||
wr.AddPalette(paletteName, newpal);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Collections;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.FileFormats;
|
||||
@@ -35,21 +36,16 @@ namespace OpenRA
|
||||
|
||||
public XRandom SharedRandom;
|
||||
|
||||
public readonly Dictionary<int, Player> players = new Dictionary<int, Player>();
|
||||
public readonly List<Player> Players = new List<Player>();
|
||||
|
||||
public void AddPlayer(Player p) { players[p.Index] = p; }
|
||||
|
||||
int localPlayerIndex = -999;
|
||||
public Player LocalPlayer
|
||||
{
|
||||
get { return players.ContainsKey(localPlayerIndex) ? players[localPlayerIndex] : null; }
|
||||
}
|
||||
public void AddPlayer(Player p) { Players.Add(p); }
|
||||
public Player LocalPlayer { get; private set; }
|
||||
public readonly Shroud LocalShroud;
|
||||
|
||||
public void SetLocalPlayer(int index)
|
||||
public void SetLocalPlayer(string pr)
|
||||
{
|
||||
if (!(orderManager.Connection is ReplayConnection))
|
||||
localPlayerIndex = index;
|
||||
LocalPlayer = Players.FirstOrDefault(p => p.InternalName == pr);
|
||||
}
|
||||
|
||||
public readonly Actor WorldActor;
|
||||
@@ -108,8 +104,8 @@ namespace OpenRA
|
||||
cmp.CreatePlayers(this);
|
||||
|
||||
// Set defaults for any unset stances
|
||||
foreach (var p in players.Values)
|
||||
foreach (var q in players.Values)
|
||||
foreach (var p in Players)
|
||||
foreach (var q in Players)
|
||||
if (!p.Stances.ContainsKey(q))
|
||||
p.Stances[q] = Stance.Neutral;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user