From ba632fbf8bc71dc63a1f8faf0761ee1c33408199 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 22 Nov 2025 13:06:24 +0000 Subject: [PATCH] Revert "In RemoveCellsFromPlayerShroud, don't call RemoveSource unless required." This reverts commit 86b92275771f89166bb9c69deb9fee484b785017. This commit relied on the relationship not changing, but when a player is defeated their relationship can change due to becoming a spectator. This can cause a crash if the shroud is not removed. Revert the commit to resolve this crash. --- OpenRA.Mods.Common/Effects/RevealShroudEffect.cs | 8 +------- OpenRA.Mods.Common/Traits/CreatesShroud.cs | 8 +------- OpenRA.Mods.Common/Traits/RevealsMap.cs | 16 +++++----------- OpenRA.Mods.Common/Traits/RevealsShroud.cs | 8 +------- 4 files changed, 8 insertions(+), 32 deletions(-) diff --git a/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs b/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs index 192db3ec0d..a9d4b05dc6 100644 --- a/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs +++ b/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs @@ -49,13 +49,7 @@ namespace OpenRA.Mods.Common.Effects p.Shroud.AddSource(this, sourceType, uv); } - void RemoveCellsFromPlayerShroud(Player p) - { - if (!validStances.HasRelationship(player.RelationshipWith(p))) - return; - - p.Shroud.RemoveSource(this); - } + void RemoveCellsFromPlayerShroud(Player p) { p.Shroud.RemoveSource(this); } PPos[] ProjectedCells(World world) { diff --git a/OpenRA.Mods.Common/Traits/CreatesShroud.cs b/OpenRA.Mods.Common/Traits/CreatesShroud.cs index 4f1eb6cbe4..f7761bd528 100644 --- a/OpenRA.Mods.Common/Traits/CreatesShroud.cs +++ b/OpenRA.Mods.Common/Traits/CreatesShroud.cs @@ -49,13 +49,7 @@ namespace OpenRA.Mods.Common.Traits p.Shroud.AddSource(this, Shroud.SourceType.Shroud, uv); } - protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) - { - if (!info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(p))) - return; - - p.Shroud.RemoveSource(this); - } + protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) { p.Shroud.RemoveSource(this); } public override WDist Range { diff --git a/OpenRA.Mods.Common/Traits/RevealsMap.cs b/OpenRA.Mods.Common/Traits/RevealsMap.cs index a01b89142d..4fb5fcbca3 100644 --- a/OpenRA.Mods.Common/Traits/RevealsMap.cs +++ b/OpenRA.Mods.Common/Traits/RevealsMap.cs @@ -44,13 +44,7 @@ namespace OpenRA.Mods.Common.Traits p.Shroud.AddSource(this, type, uv); } - protected void RemoveCellsFromPlayerShroud(Actor self, Player p) - { - if (!Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(p))) - return; - - p.Shroud.RemoveSource(this); - } + protected void RemoveCellsFromPlayerShroud(Player p) { p.Shroud.RemoveSource(this); } protected PPos[] ProjectedCells(Actor self) { @@ -64,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits var cells = ProjectedCells(self); foreach (var player in self.World.Players) { - RemoveCellsFromPlayerShroud(self, player); + RemoveCellsFromPlayerShroud(player); AddCellsToPlayerShroud(self, player, cells); } } @@ -73,13 +67,13 @@ namespace OpenRA.Mods.Common.Traits void INotifyActorDisposing.Disposing(Actor self) { foreach (var player in self.World.Players) - RemoveCellsFromPlayerShroud(self, player); + RemoveCellsFromPlayerShroud(player); } void INotifyKilled.Killed(Actor self, AttackInfo e) { foreach (var player in self.World.Players) - RemoveCellsFromPlayerShroud(self, player); + RemoveCellsFromPlayerShroud(player); } protected override void TraitEnabled(Actor self) @@ -92,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits protected override void TraitDisabled(Actor self) { foreach (var player in self.World.Players) - RemoveCellsFromPlayerShroud(self, player); + RemoveCellsFromPlayerShroud(player); } } } diff --git a/OpenRA.Mods.Common/Traits/RevealsShroud.cs b/OpenRA.Mods.Common/Traits/RevealsShroud.cs index c5731be0b8..f19f448763 100644 --- a/OpenRA.Mods.Common/Traits/RevealsShroud.cs +++ b/OpenRA.Mods.Common/Traits/RevealsShroud.cs @@ -55,13 +55,7 @@ namespace OpenRA.Mods.Common.Traits p.Shroud.AddSource(this, type, uv); } - protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) - { - if (!info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(p))) - return; - - p.Shroud.RemoveSource(this); - } + protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) { p.Shroud.RemoveSource(this); } public override WDist Range {