From 08d07eeb069b8b80771ee1859f7bfb86e8de3e9c Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Tue, 14 Oct 2025 14:26:16 +0300 Subject: [PATCH] Fix bot traits crashing on missing ResourceMapBotModule --- OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs | 2 +- OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs | 2 +- .../Traits/BotModules/McvExpansionManagerBotModule.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs index 48ce53aa53..70b9d4edfb 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs @@ -257,7 +257,7 @@ namespace OpenRA.Mods.Common.Traits { if (firstTick) { - ResourceMapModule = bot.Player.PlayerActor.TraitsImplementing().First(t => t.IsTraitEnabled()); + ResourceMapModule = bot.Player.PlayerActor.TraitsImplementing().FirstOrDefault(t => t.IsTraitEnabled()); firstTick = false; } diff --git a/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs index aa2bfd332c..0626ea7fdd 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs @@ -149,7 +149,7 @@ namespace OpenRA.Mods.Common.Traits if (firstTick) { - resourceMapModule = bot.Player.PlayerActor.TraitsImplementing().First(t => t.IsTraitEnabled()); + resourceMapModule = bot.Player.PlayerActor.TraitsImplementing().FirstOrDefault(t => t.IsTraitEnabled()); firstTick = false; } diff --git a/OpenRA.Mods.Common/Traits/BotModules/McvExpansionManagerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/McvExpansionManagerBotModule.cs index c16a122500..1ce1ff1936 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/McvExpansionManagerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/McvExpansionManagerBotModule.cs @@ -522,7 +522,7 @@ namespace OpenRA.Mods.Common.Traits if (firstTick) { - resourceMapModule = bot.Player.PlayerActor.TraitsImplementing().First(t => t.IsTraitEnabled()); + resourceMapModule = bot.Player.PlayerActor.TraitsImplementing().FirstOrDefault(t => t.IsTraitEnabled()); SwitchExpansionMode(Info.InitialExpansionMode); pathDistanceSquareFactor = resourceMapModule.GetIndiceRowCount() * resourceMapModule.GetIndiceRowCount()