From 9e1f7cad5527bbd1d2646fa4039d28bb87a5cd3f Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 1 Jan 2026 12:35:44 +0000 Subject: [PATCH] Fix duplicated text notifications when sound device is not available. --- .../Traits/Player/ProductionQueue.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs index 388a7b92da..9d249c7502 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs @@ -492,21 +492,23 @@ namespace OpenRA.Mods.Common.Traits { if (Info.PayUpFront && cost > playerResources.GetCashAndResources()) return; - var hasPlayedSound = false; + + var notified = false; BeginProduction(new ProductionItem(this, order.TargetString, cost, playerPower, () => self.World.AddFrameEndTask(_ => { // Make sure the item hasn't been invalidated between the ProductionItem ticking and this FrameEndTask running if (!Queue.Any(i => i.Done && i.Item == unit.Name)) { - hasPlayedSound = false; + notified = false; return; } var isBuilding = unit.HasTraitInfo(); - if (isBuilding && !hasPlayedSound) + if (isBuilding && !notified) { - hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName); + Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(self.Owner, Info.ReadyTextNotification); + notified = true; } else if (!isBuilding) { @@ -515,10 +517,11 @@ namespace OpenRA.Mods.Common.Traits Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(self.Owner, Info.ReadyTextNotification); } - else if (!hasPlayedSound && time > 0) + else if (!notified && time > 0) { - hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Faction.InternalName); + Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(self.Owner, Info.BlockedTextNotification); + notified = true; } } })), !order.Queued);