From 768c3de58912363202e17dbedd802e49efc38079 Mon Sep 17 00:00:00 2001 From: olanti-p Date: Tue, 5 May 2020 16:01:45 +0300 Subject: [PATCH 1/2] Don't reveal tiles when drawing automove trajectory --- src/animation.cpp | 20 ++++++++++++++------ src/game.cpp | 2 +- src/game.h | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/animation.cpp b/src/animation.cpp index 0cb17a1cd497f..ce63f4d12ee18 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -556,7 +556,7 @@ void game::draw_hit_player( const Character &p, const int dam ) namespace { void draw_line_curses( game &g, const tripoint &/*pos*/, const tripoint ¢er, - const std::vector &ret ) + const std::vector &ret, bool noreveal ) { for( const tripoint &p : ret ) { const auto critter = g.critter_at( p, true ); @@ -564,7 +564,16 @@ void draw_line_curses( game &g, const tripoint &/*pos*/, const tripoint ¢er, // NPCs and monsters get drawn with inverted colors if( critter && g.u.sees( *critter ) ) { critter->draw( g.w_terrain, center, true ); + } else if( noreveal && !g.u.sees( p ) ) { + // Draw a meaningless symbol. Avoids revealing tile, but keeps feedback + const char sym = '?'; + const nc_color col = c_dark_gray; + const catacurses::window &w = g.w_terrain; + const int k = p.x + getmaxx( w ) / 2 - center.x; + const int j = p.y + getmaxy( w ) / 2 - center.y; + mvwputch( w, point( k, j ), col, sym ); } else { + // This function reveals tile at p and writes it to the player's memory g.m.drawsq( g.w_terrain, g.u, p, true, true, center ); } } @@ -573,15 +582,14 @@ void draw_line_curses( game &g, const tripoint &/*pos*/, const tripoint ¢er, #if defined(TILES) void game::draw_line( const tripoint &p, const tripoint ¢er, - const std::vector &points ) + const std::vector &points, bool noreveal ) { if( !u.sees( p ) ) { return; } - // TODO: needed for tiles ver too?? if( !use_tiles ) { - draw_line_curses( *this, p, center, points ); + draw_line_curses( *this, p, center, points, noreveal ); return; } @@ -589,13 +597,13 @@ void game::draw_line( const tripoint &p, const tripoint ¢er, } #else void game::draw_line( const tripoint &p, const tripoint ¢er, - const std::vector &points ) + const std::vector &points, bool noreveal ) { if( !u.sees( p ) ) { return; } - draw_line_curses( *this, p, center, points ); + draw_line_curses( *this, p, center, points, noreveal ); } #endif diff --git a/src/game.cpp b/src/game.cpp index fc4758de9fcd2..743a52c6dfc22 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3482,7 +3482,7 @@ void game::draw_ter( const tripoint ¢er, const bool looking, const bool draw // Draw auto-move preview trail const tripoint &final_destination = destination_preview.back(); tripoint line_center = u.pos() + u.view_offset; - draw_line( final_destination, line_center, destination_preview ); + draw_line( final_destination, line_center, destination_preview, true ); mvwputch( w_terrain, final_destination.xy() - u.view_offset.xy() + point( POSX - u.posx(), POSY - u.posy() ), c_white, 'X' ); } diff --git a/src/game.h b/src/game.h index d80c429094853..0b68ae562f688 100644 --- a/src/game.h +++ b/src/game.h @@ -655,7 +655,7 @@ class game void draw_hit_mon( const tripoint &p, const monster &m, bool dead = false ); void draw_hit_player( const Character &p, int dam ); void draw_line( const tripoint &p, const tripoint ¢er_point, - const std::vector &points ); + const std::vector &points, bool noreveal = false ); void draw_line( const tripoint &p, const std::vector &points ); void draw_weather( const weather_printable &wPrint ); void draw_sct(); From 9acae94527eb35a8688fc03518f2c9dac3c71e91 Mon Sep 17 00:00:00 2001 From: olanti-p Date: Tue, 5 May 2020 16:39:11 +0300 Subject: [PATCH 2/2] Remove some dead code --- src/animation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/animation.cpp b/src/animation.cpp index ce63f4d12ee18..54d9c6ab732e8 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -555,8 +555,8 @@ void game::draw_hit_player( const Character &p, const int dam ) /* Line drawing code, not really an animation but should be separated anyway */ namespace { -void draw_line_curses( game &g, const tripoint &/*pos*/, const tripoint ¢er, - const std::vector &ret, bool noreveal ) +void draw_line_curses( game &g, const tripoint ¢er, const std::vector &ret, + bool noreveal ) { for( const tripoint &p : ret ) { const auto critter = g.critter_at( p, true ); @@ -589,7 +589,7 @@ void game::draw_line( const tripoint &p, const tripoint ¢er, } if( !use_tiles ) { - draw_line_curses( *this, p, center, points, noreveal ); + draw_line_curses( *this, center, points, noreveal ); return; } @@ -603,7 +603,7 @@ void game::draw_line( const tripoint &p, const tripoint ¢er, return; } - draw_line_curses( *this, p, center, points, noreveal ); + draw_line_curses( *this, center, points, noreveal ); } #endif