MCPcopy Create free account
hub / github.com/CleverRaven/Cataclysm-DDA / build_map_cache

Method build_map_cache

src/map.cpp:8342–8380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8340}
8341
8342void map::build_map_cache( const int zlev, bool skip_lightmap )
8343{
8344 const int minz = zlevels ? -OVERMAP_DEPTH : zlev;
8345 const int maxz = zlevels ? OVERMAP_HEIGHT : zlev;
8346 bool seen_cache_dirty = false;
8347 for( int z = minz; z <= maxz; z++ ) {
8348 // trigger FOV recalculation only when there is a change on the player's level or if fov_3d is enabled
8349 const bool affects_seen_cache = z == zlev || fov_3d;
8350 build_outside_cache( z );
8351 build_transparency_cache( z );
8352 bool floor_cache_was_dirty = build_floor_cache( z );
8353 seen_cache_dirty |= ( floor_cache_was_dirty && affects_seen_cache );
8354 if( floor_cache_was_dirty && z > -OVERMAP_DEPTH ) {
8355 get_cache( z - 1 ).r_up_cache->invalidate();
8356 }
8357 seen_cache_dirty |= get_cache( z ).seen_cache_dirty && affects_seen_cache;
8358 }
8359 // needs a separate pass as it changes the caches on neighbour z-levels (e.g. floor_cache);
8360 // otherwise such changes might be overwritten by main cache-building logic
8361 for( int z = minz; z <= maxz; z++ ) {
8362 do_vehicle_caching( z );
8363 }
8364
8365 seen_cache_dirty |= build_vision_transparency_cache( zlev );
8366
8367 if( seen_cache_dirty ) {
8368 skew_vision_cache.clear();
8369 }
8370 // Initial value is illegal player position.
8371 const tripoint p = get_player_character().pos();
8372 static tripoint player_prev_pos;
8373 if( seen_cache_dirty || player_prev_pos != p ) {
8374 build_seen_cache( p, zlev );
8375 player_prev_pos = p;
8376 }
8377 if( !skip_lightmap ) {
8378 generate_lightmap( zlev );
8379 }
8380}
8381
8382//////////
8383///// coordinate helpers

Callers 15

start_gameMethod · 0.80
loadMethod · 0.80
drawMethod · 0.80
look_aroundMethod · 0.80
update_mapMethod · 0.80
place_playerMethod · 0.80
do_turnFunction · 0.80
test_allMethod · 0.80
update_cacheFunction · 0.80
reset_cachesFunction · 0.80
test_reachabilityFunction · 0.80

Calls 3

invalidateMethod · 0.45
clearMethod · 0.45
posMethod · 0.45

Tested by 5

test_allMethod · 0.64
update_cacheFunction · 0.64
reset_cachesFunction · 0.64
test_reachabilityFunction · 0.64
clear_game_and_set_rampFunction · 0.64