diff --git a/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs b/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs index 69ec728b12..9d0a4a58e8 100644 --- a/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs +++ b/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs @@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.Notification, self.Owner.Faction.InternalName); if (radarPings != null) - radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); + radarPings.Add(() => self.Owner.IsAlliedWith(self.World.RenderPlayer), self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); } lastAttackTime = self.World.WorldTick; diff --git a/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs b/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs index 1a468a8c8b..dd809207ac 100644 --- a/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs +++ b/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs @@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.Notification, self.Owner.Faction.InternalName); if (radarPings != null) - radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); + radarPings.Add(() => self.Owner.IsAlliedWith(self.World.RenderPlayer), self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); } lastAttackTime = self.World.WorldTick; diff --git a/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs index 0def9d6418..e2998d2714 100644 --- a/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.Common/Widgets/WorldCommandWidget.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Widgets public override bool HandleKeyPress(KeyInput e) { - if (world == null || world.LocalPlayer == null) + if (world == null) return false; return ProcessInput(e); @@ -64,6 +64,10 @@ namespace OpenRA.Mods.Common.Widgets if (key == ks.ToSelectionKey) return ToSelection(); + // Put all functions that are valid for observers/spectators above this line. + if (world.LocalPlayer == null || world.LocalPlayer.Spectating) + return false; + // Put all functions that aren't unit-specific before this line! if (!world.Selection.Actors.Any() || world.IsGameOver) return false; @@ -188,7 +192,7 @@ namespace OpenRA.Mods.Common.Widgets bool CycleBases() { var bases = world.ActorsWithTrait() - .Where(a => a.Actor.Owner == world.LocalPlayer) + .Where(a => a.Actor.Owner == world.RenderPlayer) .Select(b => b.Actor) .ToList(); @@ -197,7 +201,7 @@ namespace OpenRA.Mods.Common.Widgets { var building = world.ActorsWithTrait() .Select(b => b.Actor) - .FirstOrDefault(a => a.Owner == world.LocalPlayer && a.Info.HasTraitInfo()); + .FirstOrDefault(a => a.Owner == world.RenderPlayer && a.Info.HasTraitInfo()); // No buildings left if (building == null) @@ -223,7 +227,7 @@ namespace OpenRA.Mods.Common.Widgets bool CycleProductionBuildings() { var facilities = world.ActorsWithTrait() - .Where(a => a.Actor.Owner == world.LocalPlayer && !a.Actor.Info.HasTraitInfo()) + .Where(a => a.Actor.Owner == world.RenderPlayer && !a.Actor.Info.HasTraitInfo()) .OrderBy(f => f.Actor.Info.TraitInfo().Produces.First()) .Select(b => b.Actor) .ToList();