Skip to content

Commit

Permalink
Avoid revealing hidden tiles when selecting automove destination on C…
Browse files Browse the repository at this point in the history
…URSES (CleverRaven#40194)

(cherry picked from commit 3d706f3)
  • Loading branch information
olanti-p authored and tung committed Jul 27, 2020
1 parent 0060bcf commit 92d4ed6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions src/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,16 +553,25 @@ 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 &center,
const std::vector<tripoint> &ret )
void draw_line_curses( game &g, const tripoint &center, const std::vector<tripoint> &ret,
bool noreveal )
{
for( const tripoint &p : ret ) {
const auto critter = g.critter_at( p, true );

// 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 );
}
}
Expand All @@ -571,29 +580,28 @@ void draw_line_curses( game &g, const tripoint &/*pos*/, const tripoint &center,

#if defined(TILES)
void game::draw_line( const tripoint &p, const tripoint &center,
const std::vector<tripoint> &points )
const std::vector<tripoint> &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;
}

tilecontext->init_draw_line( p, points, "line_target", true );
}
#else
void game::draw_line( const tripoint &p, const tripoint &center,
const std::vector<tripoint> &points )
const std::vector<tripoint> &points, bool noreveal )
{
if( !u.sees( p ) ) {
return;
}

draw_line_curses( *this, p, center, points );
draw_line_curses( *this, center, points, noreveal );
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3256,7 +3256,7 @@ void game::draw_ter( const tripoint &center, 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' );
}
Expand Down
2 changes: 1 addition & 1 deletion src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 &center_point,
const std::vector<tripoint> &points );
const std::vector<tripoint> &points, bool noreveal = false );
void draw_line( const tripoint &p, const std::vector<tripoint> &points );
void draw_weather( const weather_printable &wPrint );
void draw_sct();
Expand Down

0 comments on commit 92d4ed6

Please sign in to comment.