From f08f2ad9ed1d8a89605cf546a9c565df302b08cf Mon Sep 17 00:00:00 2001 From: Viss Valdyr <33199510+Lamandus@users.noreply.github.com> Date: Sun, 2 Feb 2025 07:49:24 +0100 Subject: [PATCH 01/12] Update panels.cpp --- src/panels.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/panels.cpp b/src/panels.cpp index d4612af367c3..6c62b6f0bc07 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1755,6 +1755,18 @@ static void draw_compass( avatar &, const catacurses::window &w ) g->mon_info( w ); wnoutrefresh( w ); } +static void draw_compact_compass( avatar &u, const catacurses::window &w ) { + werase( w ); + + const auto &visible_creatures = u.get_visible_creatures( 60 ); + std::string enemies_text; + for( const auto &creature : visible_creatures ) { + enemies_text += creature->disp_name() + " "; + } + + mvwprintz( w, point( 1, 0 ), c_white, enemies_text ); + wnoutrefresh( w ); +} static void draw_compass_padding( avatar &, const catacurses::window &w ) { @@ -2032,6 +2044,7 @@ bool default_render() static std::vector initialize_default_classic_panels() { std::vector ret; +ret.emplace_back( draw_compact_compass, translate_marker( "Compact Compass" ), 8, 44, true ); ret.emplace_back( draw_health_classic, translate_marker( "Health" ), 7, 44, true ); ret.emplace_back( draw_location_classic, translate_marker( "Location" ), 1, 44, From 663998e5a3f14ba08ca822ce7becdad23f633973 Mon Sep 17 00:00:00 2001 From: Viss Valdyr <33199510+Lamandus@users.noreply.github.com> Date: Sun, 2 Feb 2025 10:12:55 +0100 Subject: [PATCH 02/12] New Compasses --- src/panels.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/src/panels.cpp b/src/panels.cpp index 6c62b6f0bc07..2a1def86ee20 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1755,19 +1755,53 @@ static void draw_compass( avatar &, const catacurses::window &w ) g->mon_info( w ); wnoutrefresh( w ); } -static void draw_compact_compass( avatar &u, const catacurses::window &w ) { +static std::string direction_to_enemy( const tripoint &enemy_pos, const tripoint &player_pos ) +{ + const int dx = enemy_pos.x - player_pos.x; + const int dy = enemy_pos.y - player_pos.y; + const int adx = std::abs( dx ); + const int ady = std::abs( dy ); + + if( adx > 2 * ady ) { + return dx > 0 ? "E" : "W"; + } else if( ady > 2 * adx ) { + return dy > 0 ? "S" : "N"; + } else if( dx > 0 && dy > 0 ) { + return "SE"; + } else if( dx > 0 && dy < 0 ) { + return "NE"; + } else if( dx < 0 && dy > 0 ) { + return "SW"; + } else { + return "NW"; + } +} + +static void draw_simple_compass( avatar &u, const catacurses::window &w ) +{ werase( w ); - const auto &visible_creatures = u.get_visible_creatures( 60 ); - std::string enemies_text; + const auto &visible_creatures = u.get_visible_creatures( -1 ); + std::map direction_count; + const tripoint player_pos = u.pos(); + for( const auto &creature : visible_creatures ) { - enemies_text += creature->disp_name() + " "; + const tripoint enemy_pos = creature->pos(); + std::string direction = direction_to_enemy( enemy_pos, player_pos ); + direction_count[direction]++; + } + + std::string enemies_text; + for( const auto &entry : direction_count ) { + enemies_text += entry.first + "(" + std::to_string( entry.second ) + ") "; } mvwprintz( w, point( 1, 0 ), c_white, enemies_text ); wnoutrefresh( w ); } + + static void draw_compass_padding( avatar &, const catacurses::window &w ) { werase( w ); @@ -2044,7 +2078,6 @@ bool default_render() static std::vector initialize_default_classic_panels() { std::vector ret; -ret.emplace_back( draw_compact_compass, translate_marker( "Compact Compass" ), 8, 44, true ); ret.emplace_back( draw_health_classic, translate_marker( "Health" ), 7, 44, true ); ret.emplace_back( draw_location_classic, translate_marker( "Location" ), 1, 44, @@ -2065,6 +2098,10 @@ ret.emplace_back( draw_compact_compass, translate_marker( "Compact Compass" ), 8 ret.emplace_back( draw_armor, translate_marker( "Armor" ), 5, 44, false ); ret.emplace_back( draw_compass_padding, translate_marker( "Compass" ), 8, 44, true ); + ret.emplace_back( draw_compass_padding, translate_marker( "Comp.Compass" ), 3, 44, + false ); + ret.emplace_back( draw_simple_compass, translate_marker( "Sim.Compass" ), 1, 44, false ); + ret.emplace_back( draw_messages_classic, translate_marker( "Log" ), -2, 44, true ); #if defined(TILES) ret.emplace_back( draw_mminimap, translate_marker( "Map" ), -1, 44, true, @@ -2092,6 +2129,8 @@ static std::vector initialize_default_compact_panels() ret.emplace_back( draw_armor, translate_marker( "Armor" ), 5, 32, false ); ret.emplace_back( draw_messages_classic, translate_marker( "Log" ), -2, 32, true ); ret.emplace_back( draw_compass, translate_marker( "Compass" ), 8, 32, true ); + ret.emplace_back( draw_compass, translate_marker( "Comp.Compass" ), 3, 32, false ); + ret.emplace_back( draw_simple_compass, translate_marker( "Sim.Compass" ), 1, 44, false ); #if defined(TILES) ret.emplace_back( draw_mminimap, translate_marker( "Map" ), -1, 32, true, default_render, true ); @@ -2124,6 +2163,9 @@ static std::vector initialize_default_label_narrow_panels() ret.emplace_back( draw_armor_padding, translate_marker( "Armor" ), 5, 32, false ); ret.emplace_back( draw_compass_padding, translate_marker( "Compass" ), 8, 32, true ); + ret.emplace_back( draw_compass_padding, translate_marker( "Comp.Compass" ), 3, 32, + false ); + ret.emplace_back( draw_simple_compass, translate_marker( "Sim.Compass" ), 1, 44, false ); #if defined(TILES) ret.emplace_back( draw_mminimap, translate_marker( "Map" ), -1, 32, true, default_render, true ); @@ -2157,6 +2199,9 @@ static std::vector initialize_default_label_panels() ret.emplace_back( draw_armor_padding, translate_marker( "Armor" ), 5, 44, false ); ret.emplace_back( draw_compass_padding, translate_marker( "Compass" ), 8, 44, true ); + ret.emplace_back( draw_compass_padding, translate_marker( "Comp.Compass" ), 3, 32, + false ); + ret.emplace_back( draw_simple_compass, translate_marker( "Sim.Compass" ), 1, 44, false ); #if defined(TILES) ret.emplace_back( draw_mminimap, translate_marker( "Map" ), -1, 44, true, default_render, true ); From 7a1ec05e8f9df98f79e7d870c768af70dc9ee079 Mon Sep 17 00:00:00 2001 From: Viss Valdyr <33199510+Lamandus@users.noreply.github.com> Date: Sun, 2 Feb 2025 10:18:44 +0100 Subject: [PATCH 03/12] Update panels.cpp --- src/panels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels.cpp b/src/panels.cpp index 2a1def86ee20..c387252c056a 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1781,7 +1781,7 @@ static void draw_simple_compass( avatar &u, const catacurses::window &w ) { werase( w ); - const auto &visible_creatures = u.get_visible_creatures( -1 ); + const auto &visible_creatures = u.get_visible_creatures( 200 ); std::map direction_count; const tripoint player_pos = u.pos(); From e64e60720ce750ea8fd170682285499256e4e993 Mon Sep 17 00:00:00 2001 From: Viss Valdyr <33199510+Lamandus@users.noreply.github.com> Date: Sun, 2 Feb 2025 10:23:12 +0100 Subject: [PATCH 04/12] Update panels.cpp --- src/panels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels.cpp b/src/panels.cpp index c387252c056a..7e3e81c08da0 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1796,7 +1796,7 @@ static void draw_simple_compass( avatar &u, const catacurses::window &w ) enemies_text += entry.first + "(" + std::to_string( entry.second ) + ") "; } - mvwprintz( w, point( 1, 0 ), c_white, enemies_text ); + mvwprintz( w, point( 0, 0 ), c_white, enemies_text ); wnoutrefresh( w ); } From 7f0389b77958178a956499b127dde101272847e2 Mon Sep 17 00:00:00 2001 From: Viss Valdyr <33199510+Lamandus@users.noreply.github.com> Date: Mon, 3 Feb 2025 20:10:01 +0100 Subject: [PATCH 05/12] Update panels.cpp --- src/panels.cpp | 109 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 91 insertions(+), 18 deletions(-) diff --git a/src/panels.cpp b/src/panels.cpp index 7e3e81c08da0..9a887e34614d 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1755,26 +1755,99 @@ static void draw_compass( avatar &, const catacurses::window &w ) g->mon_info( w ); wnoutrefresh( w ); } -static std::string direction_to_enemy( const tripoint &enemy_pos, const tripoint &player_pos ) -{ +std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoint &player_pos ) +{ + // Really close to optimal 22.5 degree line + // Calculated from the continued fraction estimate of cos(22.5deg) / sin(22.5deg) + constexpr int x0 = 80782; + constexpr int y0 = 33461; + + // Sections: + struct wedge_range { + const char *direction; + + int x0, y0; + int x1, y1; + }; + + constexpr std::array wedges = {{ + { "N", -y0, -x0, y0, -x0 }, + {"NE", y0, -x0, x0, -y0 }, + { "E", x0, -y0, x0, y0 }, + {"SE", x0, y0, y0, x0 }, + { "S", y0, x0, -y0, x0 }, + {"SW", -y0, x0, -x0, y0 }, + { "W", -x0, y0, -x0, -y0 }, + {"NW", -x0, -y0, -y0, -x0 } + }}; + + auto between = []( int cx, int cy, const wedge_range &wr ) { + auto side_of_sign = []( int ax, int ay, int bx, int by ) { + int dot = ax * by - ay * bx; + + return (dot > 0) - (dot < 0); // Returns [-1, 0, +1] sign of dot product + }; + + int dot_ab = side_of_sign( wr.x0, wr.y0, wr.x1, wr.y1 ); + int dot_ac = side_of_sign( wr.x0, wr.y0, cx, cy ); + int dot_cb = side_of_sign( cx, cy, wr.x1, wr.y1 ); + + return (dot_ab == dot_ac) && (dot_ab == dot_cb ); + }; const int dx = enemy_pos.x - player_pos.x; const int dy = enemy_pos.y - player_pos.y; - const int adx = std::abs( dx ); - const int ady = std::abs( dy ); - - if( adx > 2 * ady ) { - return dx > 0 ? "E" : "W"; - } else if( ady > 2 * adx ) { - return dy > 0 ? "S" : "N"; - } else if( dx > 0 && dy > 0 ) { - return "SE"; - } else if( dx > 0 && dy < 0 ) { - return "NE"; - } else if( dx < 0 && dy > 0 ) { - return "SW"; - } else { - return "NW"; + + for( const auto &wr : wedges ) { + if( between( dx, dy, wr ) ) { + return wr.direction; + } + } + return "--"; +} + +void check( const char* msg, std::function fn ) { + printf( msg ); + + constexpr int dim = 21; + constexpr int mid = dim / 2; + std::string grid[dim][dim]; + grid[mid][mid] = "--"; + + std::map counts; + + constexpr int r2 = mid * mid; + + for( int y = 0; y < dim; ++y ) { + for( int x = 0; x < dim; ++x ) { + grid[y][x] = "--"; + if( x == mid && y == mid ) { + continue; + } + + int d2 = (x - mid) * (x - mid) + (y - mid) * (y - mid); + if( false || d2 < r2 ) { + grid[y][x] = fn( { x, y, 0}, {mid, mid, 0} ); + counts[grid[y][x]] += 1; + } + } } + for( int y = 0; y < dim; ++y ) { + for( int x = 0; x < dim; ++x ) { + printf( "%*.*s ", 2, 2, grid[y][x].c_str() ); + } + printf( "\n" ); + } + printf( "Tiles per direction:\n" ); + for( const auto &p : counts ) { + printf( "%*.*s %d\n", 2, 2, p.first.c_str(), p.second ); + } + printf( "\n\n" ); +} + +int main() { + check( "Improved\n", direction_to_enemy_improved ); + + return 0; } static void draw_simple_compass( avatar &u, const catacurses::window &w ) @@ -1787,7 +1860,7 @@ static void draw_simple_compass( avatar &u, const catacurses::window &w ) for( const auto &creature : visible_creatures ) { const tripoint enemy_pos = creature->pos(); - std::string direction = direction_to_enemy( enemy_pos, player_pos ); + std::string direction = direction_to_enemy_improved( enemy_pos, player_pos ); direction_count[direction]++; } From 4109a1d1ef1311f59b17050bcfdafaf6eb6c738c Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 19:10:56 +0000 Subject: [PATCH 06/12] style(autofix.ci): automated formatting --- src/panels.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/panels.cpp b/src/panels.cpp index 9a887e34614d..fb1c5c939bd0 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1765,34 +1765,35 @@ std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoi // Sections: struct wedge_range { const char *direction; - + int x0, y0; int x1, y1; }; constexpr std::array wedges = {{ - { "N", -y0, -x0, y0, -x0 }, - {"NE", y0, -x0, x0, -y0 }, - { "E", x0, -y0, x0, y0 }, - {"SE", x0, y0, y0, x0 }, - { "S", y0, x0, -y0, x0 }, - {"SW", -y0, x0, -x0, y0 }, - { "W", -x0, y0, -x0, -y0 }, - {"NW", -x0, -y0, -y0, -x0 } - }}; - - auto between = []( int cx, int cy, const wedge_range &wr ) { + { "N", -y0, -x0, y0, -x0 }, + {"NE", y0, -x0, x0, -y0 }, + { "E", x0, -y0, x0, y0 }, + {"SE", x0, y0, y0, x0 }, + { "S", y0, x0, -y0, x0 }, + {"SW", -y0, x0, -x0, y0 }, + { "W", -x0, y0, -x0, -y0 }, + {"NW", -x0, -y0, -y0, -x0 } + } + }; + + auto between = []( int cx, int cy, const wedge_range & wr ) { auto side_of_sign = []( int ax, int ay, int bx, int by ) { int dot = ax * by - ay * bx; - return (dot > 0) - (dot < 0); // Returns [-1, 0, +1] sign of dot product + return ( dot > 0 ) - ( dot < 0 ); // Returns [-1, 0, +1] sign of dot product }; int dot_ab = side_of_sign( wr.x0, wr.y0, wr.x1, wr.y1 ); int dot_ac = side_of_sign( wr.x0, wr.y0, cx, cy ); int dot_cb = side_of_sign( cx, cy, wr.x1, wr.y1 ); - return (dot_ab == dot_ac) && (dot_ab == dot_cb ); + return ( dot_ab == dot_ac ) && ( dot_ab == dot_cb ); }; const int dx = enemy_pos.x - player_pos.x; const int dy = enemy_pos.y - player_pos.y; @@ -1805,7 +1806,8 @@ std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoi return "--"; } -void check( const char* msg, std::function fn ) { +void check( const char *msg, std::function fn ) +{ printf( msg ); constexpr int dim = 21; @@ -1824,7 +1826,7 @@ void check( const char* msg, std::function Date: Mon, 3 Feb 2025 21:17:41 +0100 Subject: [PATCH 07/12] corrections --- src/panels.cpp | 58 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/panels.cpp b/src/panels.cpp index fb1c5c939bd0..53648400a50b 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1755,38 +1755,39 @@ static void draw_compass( avatar &, const catacurses::window &w ) g->mon_info( w ); wnoutrefresh( w ); } + +// Forward declarations +std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoint &player_pos ); +void check( const char *msg, std::function fn ); + +// Improved direction function std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoint &player_pos ) { - // Really close to optimal 22.5 degree line - // Calculated from the continued fraction estimate of cos(22.5deg) / sin(22.5deg) + // Constants based on cos(22.5°) / sin(22.5°) approximation constexpr int x0 = 80782; constexpr int y0 = 33461; - // Sections: struct wedge_range { const char *direction; - int x0, y0; int x1, y1; }; constexpr std::array wedges = {{ - { "N", -y0, -x0, y0, -x0 }, - {"NE", y0, -x0, x0, -y0 }, - { "E", x0, -y0, x0, y0 }, - {"SE", x0, y0, y0, x0 }, - { "S", y0, x0, -y0, x0 }, - {"SW", -y0, x0, -x0, y0 }, - { "W", -x0, y0, -x0, -y0 }, - {"NW", -x0, -y0, -y0, -x0 } - } - }; - - auto between = []( int cx, int cy, const wedge_range & wr ) { + { "N", -y0, -x0, y0, -x0 }, + { "NE", y0, -x0, x0, -y0 }, + { "E", x0, -y0, x0, y0 }, + { "SE", x0, y0, y0, x0 }, + { "S", y0, x0, -y0, x0 }, + { "SW", -y0, x0, -x0, y0 }, + { "W", -x0, y0, -x0, -y0 }, + { "NW", -x0, -y0, -y0, -x0 } + }}; + + auto between = []( int cx, int cy, const wedge_range &wr ) { auto side_of_sign = []( int ax, int ay, int bx, int by ) { int dot = ax * by - ay * bx; - - return ( dot > 0 ) - ( dot < 0 ); // Returns [-1, 0, +1] sign of dot product + return ( dot > 0 ) - ( dot < 0 ); }; int dot_ab = side_of_sign( wr.x0, wr.y0, wr.x1, wr.y1 ); @@ -1795,6 +1796,7 @@ std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoi return ( dot_ab == dot_ac ) && ( dot_ab == dot_cb ); }; + const int dx = enemy_pos.x - player_pos.x; const int dy = enemy_pos.y - player_pos.y; @@ -1806,9 +1808,10 @@ std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoi return "--"; } +// Corrected check function void check( const char *msg, std::function fn ) { - printf( msg ); + printf( "%s\n", msg ); // Secure printf usage constexpr int dim = 21; constexpr int mid = dim / 2; @@ -1821,34 +1824,37 @@ void check( const char *msg, std::function Date: Mon, 3 Feb 2025 20:18:36 +0000 Subject: [PATCH 08/12] style(autofix.ci): automated formatting --- src/panels.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/panels.cpp b/src/panels.cpp index 53648400a50b..4a8731d2238c 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1774,17 +1774,18 @@ std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoi }; constexpr std::array wedges = {{ - { "N", -y0, -x0, y0, -x0 }, - { "NE", y0, -x0, x0, -y0 }, - { "E", x0, -y0, x0, y0 }, - { "SE", x0, y0, y0, x0 }, - { "S", y0, x0, -y0, x0 }, - { "SW", -y0, x0, -x0, y0 }, - { "W", -x0, y0, -x0, -y0 }, - { "NW", -x0, -y0, -y0, -x0 } - }}; - - auto between = []( int cx, int cy, const wedge_range &wr ) { + { "N", -y0, -x0, y0, -x0 }, + { "NE", y0, -x0, x0, -y0 }, + { "E", x0, -y0, x0, y0 }, + { "SE", x0, y0, y0, x0 }, + { "S", y0, x0, -y0, x0 }, + { "SW", -y0, x0, -x0, y0 }, + { "W", -x0, y0, -x0, -y0 }, + { "NW", -x0, -y0, -y0, -x0 } + } + }; + + auto between = []( int cx, int cy, const wedge_range & wr ) { auto side_of_sign = []( int ax, int ay, int bx, int by ) { int dot = ax * by - ay * bx; return ( dot > 0 ) - ( dot < 0 ); From 78946feaa1af65f87e2aa9eb566975a90b130d00 Mon Sep 17 00:00:00 2001 From: Viss Valdyr <33199510+Lamandus@users.noreply.github.com> Date: Tue, 4 Feb 2025 06:38:46 +0100 Subject: [PATCH 09/12] Update src/panels.cpp Co-authored-by: scarf --- src/panels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels.cpp b/src/panels.cpp index 4a8731d2238c..0e0bfabf3e07 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1758,7 +1758,7 @@ static void draw_compass( avatar &, const catacurses::window &w ) // Forward declarations std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoint &player_pos ); -void check( const char *msg, std::function fn ); +void check( const char *msg, std::function std::string> fn ); // Improved direction function std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoint &player_pos ) From 0a7be3f6f285053a15f8dc2fe7aafb636ede65f0 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 05:39:46 +0000 Subject: [PATCH 10/12] style(autofix.ci): automated formatting --- src/panels.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/panels.cpp b/src/panels.cpp index 0e0bfabf3e07..5f25b7d6cf8e 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1758,7 +1758,8 @@ static void draw_compass( avatar &, const catacurses::window &w ) // Forward declarations std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoint &player_pos ); -void check( const char *msg, std::function std::string> fn ); +void check( const char *msg, std::function < auto( const tripoint &, + const tripoint & ) -> std::string > fn ); // Improved direction function std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoint &player_pos ) From 5a7317a46abe59c33a73a8744b51741c0147650d Mon Sep 17 00:00:00 2001 From: Viss Valdyr <33199510+Lamandus@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:20:54 +0100 Subject: [PATCH 11/12] Update panels.cpp --- src/panels.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/panels.cpp b/src/panels.cpp index 5f25b7d6cf8e..6e915c43a2b7 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1854,12 +1854,6 @@ void check( const char *msg, std::function Date: Wed, 5 Feb 2025 07:09:03 +0100 Subject: [PATCH 12/12] Update panels.cpp --- src/panels.cpp | 44 -------------------------------------------- 1 file changed, 44 deletions(-) diff --git a/src/panels.cpp b/src/panels.cpp index 6e915c43a2b7..0fe36b069272 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1810,50 +1810,6 @@ std::string direction_to_enemy_improved( const tripoint &enemy_pos, const tripoi return "--"; } -// Corrected check function -void check( const char *msg, std::function fn ) -{ - printf( "%s\n", msg ); // Secure printf usage - - constexpr int dim = 21; - constexpr int mid = dim / 2; - std::string grid[dim][dim]; - grid[mid][mid] = "--"; - - std::map counts; - - constexpr int r2 = mid * mid; - - for( int y = 0; y < dim; ++y ) { - for( int x = 0; x < dim; ++x ) { - if( x == mid && y == mid ) { - continue; - } - - int d2 = ( x - mid ) * ( x - mid ) + ( y - mid ) * ( y - mid ); - if( d2 < r2 ) { - grid[y][x] = fn( { x, y, 0 }, { mid, mid, 0 } ); - counts[grid[y][x]] += 1; - } else { - grid[y][x] = "--"; - } - } - } - - for( int y = 0; y < dim; ++y ) { - for( int x = 0; x < dim; ++x ) { - printf( "%2s ", grid[y][x].c_str() ); - } - printf( "\n" ); - } - - printf( "Tiles per direction:\n" ); - for( const auto &p : counts ) { - printf( "%2s %d\n", p.first.c_str(), p.second ); - } - printf( "\n" ); -} - static void draw_simple_compass( avatar &u, const catacurses::window &w ) {