From 825c93d04a7064a28a5353a36c33c758802f680a Mon Sep 17 00:00:00 2001 From: LHoG <1476261+lhog@users.noreply.github.com> Date: Sat, 24 Feb 2024 13:46:30 +0400 Subject: [PATCH] Fix transport unload engine crash. https://github.com/beyond-all-reason/spring/issues/1319 --- rts/Sim/Units/CommandAI/MobileCAI.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rts/Sim/Units/CommandAI/MobileCAI.cpp b/rts/Sim/Units/CommandAI/MobileCAI.cpp index c21e1bc67c..779785a1a4 100644 --- a/rts/Sim/Units/CommandAI/MobileCAI.cpp +++ b/rts/Sim/Units/CommandAI/MobileCAI.cpp @@ -1557,7 +1557,8 @@ bool CMobileCAI::FindEmptySpot(const CUnit* unloadee, const float3& center, floa // radius is the size of the command unloading-zone (e.g. dragged by player); // spread is the *minimum* distance between any pair of unloaded units which // also has to respect radius - spread = std::clamp(spread, 1.0f * SQUARE_SIZE, radius); + radius = std::max(radius, static_cast(SQUARE_SIZE)); + spread = std::clamp(spread, static_cast(SQUARE_SIZE), radius); // more attempts for larger unloading zones for (int a = 0; a < maxAttempts; ++a) {