From 14ca13d2620c7fd6b69759e7f6ec18faff45b858 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sat, 2 Nov 2024 16:19:16 +0100 Subject: [PATCH] dirty caches on translucency change --- src/lightmap.cpp | 8 ++++---- src/map.cpp | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lightmap.cpp b/src/lightmap.cpp index fd8d60ec63791..c6ddb854cbd79 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -227,16 +227,16 @@ bool map::build_vision_transparency_cache( int zlev ) } } + memcpy( &vision_transparency_cache, &transparency_cache, sizeof( transparency_cache ) ); + // This segment handles blocking vision through TRANSLUCENT flagged terrain. + // We don't need to deal with cache dirtying, because that was handled when the terrain was changed. for( const tripoint_bub_ms &loc : points_in_radius( p, MAX_VIEW_DISTANCE ) ) { if( map::ter( loc ).obj().has_flag( ter_furn_flag::TFLAG_TRANSLUCENT ) && loc != p ) { - dirty |= vision_transparency_cache[loc.x()][loc.y()] != LIGHT_TRANSPARENCY_SOLID; - solid_tiles.emplace_back( loc ); + vision_transparency_cache[loc.x()][loc.y()] = LIGHT_TRANSPARENCY_SOLID; } } - memcpy( &vision_transparency_cache, &transparency_cache, sizeof( transparency_cache ) ); - // The tile player is standing on should always be visible vision_transparency_cache[p.x()][p.y()] = LIGHT_TRANSPARENCY_OPEN_AIR; diff --git a/src/map.cpp b/src/map.cpp index cfe8a3bd8b110..4cd029fb6c250 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1848,7 +1848,9 @@ bool map::furn_set( const tripoint_bub_ms &p, const furn_id &new_furniture, cons if( !new_f.emissions.empty() ) { field_furn_locs.push_back( p ); } - if( old_f.transparent != new_f.transparent ) { + if( old_f.transparent != new_f.transparent || + old_f.has_flag( ter_furn_flag::TFLAG_TRANSLUCENT ) != new_f.has_flag( + ter_furn_flag::TFLAG_TRANSLUCENT ) ) { set_transparency_cache_dirty( p ); set_seen_cache_dirty( p ); } @@ -2352,7 +2354,9 @@ bool map::ter_set( const tripoint_bub_ms &p, const ter_id &new_terrain, bool avo if( !new_t.emissions.empty() ) { field_ter_locs.push_back( p ); } - if( old_t.transparent != new_t.transparent ) { + if( old_t.transparent != new_t.transparent || + old_t.has_flag( ter_furn_flag::TFLAG_TRANSLUCENT ) != new_t.has_flag( + ter_furn_flag::TFLAG_TRANSLUCENT ) ) { set_transparency_cache_dirty( p ); set_seen_cache_dirty( p ); }