From 3656d36b2cc0855ae7a1ea07ecda56cc14a1a177 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:10:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20click=20=E6=B3=8A=E6=9D=BE=E5=88=86?= =?UTF-8?q?=E5=B8=83=E8=B6=85=E5=87=BA=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaCore/Controller/ControlScaleProxy.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/MaaCore/Controller/ControlScaleProxy.cpp b/src/MaaCore/Controller/ControlScaleProxy.cpp index c52bbcbd26..8bbd957e59 100644 --- a/src/MaaCore/Controller/ControlScaleProxy.cpp +++ b/src/MaaCore/Controller/ControlScaleProxy.cpp @@ -140,19 +140,26 @@ asst::Point asst::ControlScaleProxy::rand_point_in_rect(const Rect& rect) { int x = 0, y = 0; if (rect.width == 0) { + Log.warn("click rect width is 0"); x = rect.x; } else { - int x_rand = std::poisson_distribution(rect.width / 2.)(m_rand_engine); - + int x_rand; + do { + x_rand = std::poisson_distribution(rect.width / 2.)(m_rand_engine); + } while (x_rand < 0 || x_rand >= rect.width); x = x_rand + rect.x; } if (rect.height == 0) { + Log.warn("click rect height is 0"); y = rect.y; } else { - int y_rand = std::poisson_distribution(rect.height / 2.)(m_rand_engine); + int y_rand; + do { + y_rand = std::poisson_distribution(rect.height / 2.)(m_rand_engine); + } while (y_rand < 0 || y_rand >= rect.height); y = y_rand + rect.y; }