Fix tooltip descriptions for spectators.

This commit is contained in:
matjaeck
2018-07-28 14:25:36 +00:00
committed by abcdefg30
parent be2c41d51c
commit d33ac0c838
2 changed files with 14 additions and 3 deletions

View File

@@ -30,6 +30,14 @@ namespace OpenRA.Mods.Common.Traits
{ {
readonly Actor self; readonly Actor self;
public Player Owner
{
get
{
return self.EffectiveOwner != null ? self.EffectiveOwner.Owner : self.Owner;
}
}
public TooltipDescription(Actor self, TooltipDescriptionInfo info) public TooltipDescription(Actor self, TooltipDescriptionInfo info)
: base(info) : base(info)
{ {
@@ -41,8 +49,11 @@ namespace OpenRA.Mods.Common.Traits
if (IsTraitDisabled) if (IsTraitDisabled)
return false; return false;
var stance = forPlayer.Stances[self.Owner]; // Visibility can't be determined for null owners or viewers
if (!Info.ValidStances.HasStance(stance)) if (Owner == null || forPlayer == null)
return false;
if (!Info.ValidStances.HasStance(Owner.Stances[forPlayer]))
return false; return false;
return true; return true;

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
foreach (var info in viewport.ActorTooltipExtra) foreach (var info in viewport.ActorTooltipExtra)
{ {
if (info.IsTooltipVisible(world.LocalPlayer)) if (info.IsTooltipVisible(world.RenderPlayer))
{ {
if (index != 0) if (index != 0)
extraText += "\n"; extraText += "\n";