Minor optimization. Save a call to IsAlliedWith if not disguised. #18791.

This commit is contained in:
Vapre
2021-03-02 21:47:42 +01:00
committed by Paul Chote
parent 808d8e63bc
commit 38f0d50648

View File

@@ -261,15 +261,14 @@ namespace OpenRA
public Color PlayerRelationshipColor(Actor a) public Color PlayerRelationshipColor(Actor a)
{ {
var player = a.World.RenderPlayer ?? a.World.LocalPlayer; var renderPlayer = a.World.RenderPlayer;
var player = renderPlayer ?? a.World.LocalPlayer;
if (player != null && !player.Spectating) if (player != null && !player.Spectating)
{ {
var apparentOwner = a.EffectiveOwner != null && a.EffectiveOwner.Disguised var effectiveOwner = a.EffectiveOwner;
? a.EffectiveOwner.Owner var apparentOwner = a.Owner;
: a.Owner; if (effectiveOwner != null && effectiveOwner.Disguised && !a.Owner.IsAlliedWith(renderPlayer))
apparentOwner = effectiveOwner.Owner;
if (a.Owner.IsAlliedWith(a.World.RenderPlayer))
apparentOwner = a.Owner;
if (apparentOwner == player) if (apparentOwner == player)
return stanceColors.Self; return stanceColors.Self;