From 95f4180f1d31fd7d3a50b23e8e9d1735197b72fb Mon Sep 17 00:00:00 2001 From: Gin <> Date: Fri, 13 Oct 2023 19:46:17 -0700 Subject: [PATCH] m --- .../PokemonSV/Programs/PokemonSV_Navigation.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_Navigation.cpp b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_Navigation.cpp index f9dfa6167..21996deb2 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_Navigation.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_Navigation.cpp @@ -523,15 +523,17 @@ bool detect_closest_pokecenter_and_move_map_cursor_there(const ProgramInfo& info } // Find the detected PokeCenter icon closest to the screen center (where player character is on the map). for(const auto& box: pokecenter_watcher.found_locations()){ - std::ostringstream os; - os << "Found pokecenter at box: x=" << box.x << ", y=" << box.y << ", width=" << box.width << ", height=" << box.height << std::endl; - console.log(os.str()); const double loc_x = (box.x + box.width/2) * screen_width; const double loc_y = (box.y + box.height/2) * screen_height; const double x_diff = loc_x - center_x, y_diff = loc_y - center_y; - const double dist = x_diff * x_diff + y_diff * y_diff; - if (max_dist < dist){ - max_dist = dist; + const double dist2 = x_diff * x_diff + y_diff * y_diff; + std::ostringstream os; + os << "Found pokecenter at box: x=" << box.x << ", y=" << box.y << ", width=" << box.width << ", height=" << box.height << + ", dist to center " << std::sqrt(dist2) << " pixels"; + console.log(os.str()); + + if (max_dist < dist2){ + max_dist = dist2; closest_icon_x = loc_x; closest_icon_y = loc_y; } }