From 92d4ed6e90df3815c4a4ce8824313049df66dd6c Mon Sep 17 00:00:00 2001 From: Oleg Antipin <60584843+olanti-p@users.noreply.github.com> Date: Thu, 7 May 2020 00:47:04 +0300 Subject: [PATCH] Avoid revealing hidden tiles when selecting automove destination on CURSES (#40194) (cherry picked from commit 3d706f38110314577e6f55e8d89b0674ede16373) --- src/animation.cpp | 22 +++++++++++++++------- src/game.cpp | 2 +- src/game.h | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/animation.cpp b/src/animation.cpp index 539e7b1cdf350..069179803949b 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -553,8 +553,8 @@ void game::draw_hit_player( const player &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 ) +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 ); @@ -562,7 +562,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 ); } } @@ -571,15 +580,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, center, points, noreveal ); return; } @@ -587,13 +595,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, center, points, noreveal ); } #endif diff --git a/src/game.cpp b/src/game.cpp index 262c5bb2d47e0..04342029cd668 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3256,7 +3256,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 767ad951ee788..1def24ddea95b 100644 --- a/src/game.h +++ b/src/game.h @@ -643,7 +643,7 @@ class game void draw_hit_mon( const tripoint &p, const monster &m, bool dead = false ); void draw_hit_player( const player &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();