Skip to content

Commit

Permalink
New logic for connections to memorized tiles
Browse files Browse the repository at this point in the history
Previously when a tile was memorized we used the memorized terrain type
to determine whether it was in the connect_group of interest.

However, that doesn't always work, because the memorized tile might be
furniture or vehicle instead.  Also, it doesn't work for curses because
we don't have the tile type at all, only the symbol, from which we
cannot reverse-engineer what connect_groups it belonged to.

The new approach is that if a tile is memorized at all, we assume you
know the true terrain type.  This fails in other situations; you will
now magically know when a wall collapses even if you don't see the new
terrain, but it is less problematic overall.
  • Loading branch information
jbytheway committed Dec 28, 2018
1 parent f601449 commit 6dcb1bb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/map.cpp
Expand Up @@ -1343,25 +1343,25 @@ uint8_t map::get_known_connections( const tripoint &p, int connect_group ) const
bool is_transparent =
ch.transparency_cache[p.x][p.y] > LIGHT_TRANSPARENCY_SOLID;
uint8_t val = 0;
auto const is_memorized =
[&]( const tripoint & q ) {
return !g->u.get_memorized_tile( getabs( q ) ).tile.empty();
};

// populate connection information
for( int i = 0; i < 4; ++i ) {
tripoint neighbour = p + offsets[i];
if( !inbounds( neighbour ) ) {
continue;
}
const ter_t *neighbour_terrain = nullptr;
if( is_transparent || ch.visibility_cache[neighbour.x][neighbour.y] <= LL_BRIGHT ) {
neighbour_terrain = &ter( neighbour ).obj();
} else {
ter_str_id t_id( g->u.get_memorized_tile( getabs( neighbour ) ).tile );
if( t_id.is_valid() ) {
neighbour_terrain = &t_id.obj();
if( is_transparent ||
ch.visibility_cache[neighbour.x][neighbour.y] <= LL_BRIGHT ||
is_memorized( neighbour ) ) {
const ter_t &neighbour_terrain = ter( neighbour ).obj();
if( neighbour_terrain.connects_to( connect_group ) ) {
val += 1 << i;
}
}
if( neighbour_terrain && neighbour_terrain->connects_to( connect_group ) ) {
val += 1 << i;
}
}

return val;
Expand Down

0 comments on commit 6dcb1bb

Please sign in to comment.