Skip to content

Commit

Permalink
[fix] Fix *correctly* regression introduced by commit 936b1dc (Fix re…
Browse files Browse the repository at this point in the history
…gression in editor to place units.) (and not fixed by 59d30da)

#closes Wargus/wargus#449
Allow AI to build building.
Thanks to MamiyaOtaru for investigation and fix.
  • Loading branch information
Jarod42 committed Aug 5, 2024
1 parent 443545c commit 48ab3b6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/unit/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,11 @@ std::optional<CUnit *> 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;
}
}
Expand Down

0 comments on commit 48ab3b6

Please sign in to comment.