From 38f0d506486d15506af91e1b9f9acf757d9bb946 Mon Sep 17 00:00:00 2001 From: Vapre Date: Tue, 2 Mar 2021 21:47:42 +0100 Subject: [PATCH] Minor optimization. Save a call to `IsAlliedWith` if not disguised. #18791. --- OpenRA.Game/Player.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index fb7c21be7c..73a2252054 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -261,15 +261,14 @@ namespace OpenRA 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) { - var apparentOwner = a.EffectiveOwner != null && a.EffectiveOwner.Disguised - ? a.EffectiveOwner.Owner - : a.Owner; - - if (a.Owner.IsAlliedWith(a.World.RenderPlayer)) - apparentOwner = a.Owner; + var effectiveOwner = a.EffectiveOwner; + var apparentOwner = a.Owner; + if (effectiveOwner != null && effectiveOwner.Disguised && !a.Owner.IsAlliedWith(renderPlayer)) + apparentOwner = effectiveOwner.Owner; if (apparentOwner == player) return stanceColors.Self;