From 48ab3b66b6ec0a1aca3637adc81a2c4e0683940a Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Mon, 5 Aug 2024 10:31:29 +0200 Subject: [PATCH] [fix] Fix *correctly* regression introduced by commit 936b1dc09c7360072b21544cc599756bba0fa906 (Fix regression in editor to place units.) (and not fixed by 59d30da09aaa35448fe0fe404298799f72c01802) #closes https://github.com/Wargus/wargus/issues/449 Allow AI to build building. Thanks to MamiyaOtaru for investigation and fix. --- src/unit/build.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/unit/build.cpp b/src/unit/build.cpp index 47c7f87ff7..dbd2fe9948 100644 --- a/src/unit/build.cpp +++ b/src/unit/build.cpp @@ -464,10 +464,11 @@ std::optional CanBuildHere(const CUnit *unit, const CUnitType &type, co // Check special rules for AI players if (unit && unit->Player->AiEnabled) { - if (!ranges::any_of(type.AiBuildingRules, [&](const auto &rule) { - CUnit *ontoptarget = nullptr; - return rule->Check(unit, type, pos, ontoptarget); - })) { + if (!type.AiBuildingRules.empty() + && ranges::none_of(type.AiBuildingRules, [&](const auto &rule) { + CUnit *ontoptarget = nullptr; + return rule->Check(unit, type, pos, ontoptarget); + })) { return std::nullopt; } }