Skip to content

Commit

Permalink
Fix map memory edge case (#37460)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trioct authored Feb 11, 2020
1 parent 5a90688 commit 0dcf11e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,9 @@ void cata_tiles::draw( const point &dest, const tripoint &center, int width, int
formatted_text( text, catacurses::red, NORTH ) );
}
}
if( !p.invisible[0] ) {
g->m.check_and_set_seen_cache( p.pos );
}
}
}
// tile overrides are already drawn in the previous code
Expand Down Expand Up @@ -1353,8 +1356,9 @@ void cata_tiles::draw( const point &dest, const tripoint &center, int width, int
would_apply_vision_effects( g->m.get_visibility( ch.visibility_cache[np.x][np.y], cache ) );
}
//calling draw to memorize everything.
//bypass cache check in case we learn something new about the terrain's connections
draw_terrain( p, lighting, height_3d, invisible );
if( g->m.check_seen_cache( p ) ) {
draw_terrain( p, lighting, height_3d, invisible );
draw_furniture( p, lighting, height_3d, invisible );
draw_trap( p, lighting, height_3d, invisible );
draw_vpart( p, lighting, height_3d, invisible );
Expand Down Expand Up @@ -2181,6 +2185,8 @@ bool cata_tiles::draw_terrain( const tripoint &p, const lit_level ll, int &heigh
int connect_group = 0;
if( t.obj().connects( connect_group ) ) {
get_connect_values( p, subtile, rotation, connect_group, {} );
// re-memorize previously seen terrain in case new connections have been seen
g->m.set_memory_seen_cache_dirty( p );
} else {
get_terrain_orientation( p, rotation, subtile, {}, invisible );
// do something to get other terrain orientation values
Expand Down
2 changes: 2 additions & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9398,6 +9398,7 @@ void game::place_player_overmap( const tripoint &om_dest )
m.clear_vehicle_cache( z );
m.clear_vehicle_list( z );
}
m.access_cache( get_levz() ).map_memory_seen_cache.reset();
// offset because load_map expects the coordinates of the top left corner, but the
// player will be centered in the middle of the map.
const tripoint map_om_pos( tripoint( 2 * om_dest.x, 2 * om_dest.y,
Expand Down Expand Up @@ -10403,6 +10404,7 @@ void game::vertical_shift( const int z_after )
m.clear_vehicle_cache( z_before );
m.access_cache( z_before ).vehicle_list.clear();
m.access_cache( z_before ).zone_vehicles.clear();
m.access_cache( z_before ).map_memory_seen_cache.reset();
m.set_transparency_cache_dirty( z_before );
m.set_outside_cache_dirty( z_before );
m.load( tripoint( get_levx(), get_levy(), z_after ), true );
Expand Down

0 comments on commit 0dcf11e

Please sign in to comment.