Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid revealing hidden tiles when selecting automove destination on CURSES #40194

Merged
merged 2 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,16 +555,25 @@ 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 &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 @@ -573,29 +582,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 @@ -3482,7 +3482,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 @@ -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 &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