Tooltip is a conditional trait.
Fix Analyzer warning: V3146 Possible null dereference.
This commit is contained in:
committed by
Paul Chote
parent
8d7e5f4663
commit
0e39cc7829
@@ -189,7 +189,10 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var tooltip = target.TraitsImplementing<ITooltip>().FirstOrDefault();
|
var tooltip = target.TraitsImplementing<ITooltip>().FirstEnabledTraitOrDefault();
|
||||||
|
if (tooltip == null)
|
||||||
|
throw new ArgumentNullException("tooltip", "Missing tooltip or invalid target.");
|
||||||
|
|
||||||
AsPlayer = tooltip.Owner;
|
AsPlayer = tooltip.Owner;
|
||||||
AsActor = target.Info;
|
AsActor = target.Info;
|
||||||
AsTooltipInfo = tooltip.TooltipInfo;
|
AsTooltipInfo = tooltip.TooltipInfo;
|
||||||
@@ -213,7 +216,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
AsPlayer = newOwner;
|
AsPlayer = newOwner;
|
||||||
AsActor = actorInfo;
|
AsActor = actorInfo;
|
||||||
AsTooltipInfo = actorInfo.TraitInfos<TooltipInfo>().FirstOrDefault();
|
AsTooltipInfo = actorInfo.TraitInfos<TooltipInfo>().FirstOrDefault(info => info.EnabledByDefault);
|
||||||
|
|
||||||
HandleDisguise(oldEffectiveActor, oldEffectiveOwner, oldDisguiseSetting);
|
HandleDisguise(oldEffectiveActor, oldEffectiveOwner, oldDisguiseSetting);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user