From 32dc3ae420cf039ab0c47075cb160c893a2ac04c Mon Sep 17 00:00:00 2001 From: MistEO Date: Mon, 27 Jan 2025 13:09:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20target=5Foffset=20?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix https://github.com/MaaXYZ/MaaFramework/issues/523 --- source/MaaFramework/Task/Component/Actuator.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/MaaFramework/Task/Component/Actuator.cpp b/source/MaaFramework/Task/Component/Actuator.cpp index 160801541..d767bef79 100644 --- a/source/MaaFramework/Task/Component/Actuator.cpp +++ b/source/MaaFramework/Task/Component/Actuator.cpp @@ -300,10 +300,11 @@ cv::Rect Actuator::get_target_rect(const MAA_RES_NS::Action::Target target, cons } auto image = controller()->cached_image(); - int x = std::clamp(raw.x, 0, image.cols); - int y = std::clamp(raw.y, 0, image.rows); - int width = std::clamp(raw.width, 0, image.cols - x); - int height = std::clamp(raw.height, 0, image.rows - y); + + int x = std::clamp(raw.x + target.offset.x, 0, image.cols); + int y = std::clamp(raw.y + target.offset.y, 0, image.rows); + int width = std::clamp(raw.width + target.offset.width, 0, image.cols - x); + int height = std::clamp(raw.height + target.offset.height, 0, image.rows - y); return cv::Rect(x, y, width, height); }