From 2f3e33d718af647b5f0c75ba441b039320771536 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Mon, 10 Feb 2020 02:42:23 +0100 Subject: [PATCH] Encapsulate lum --- src/lightmap.cpp | 2 +- src/map.cpp | 2 +- src/submap.h | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lightmap.cpp b/src/lightmap.cpp index 32959b21f15e0..cfb868e350d88 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -317,7 +317,7 @@ void map::generate_lightmap( const int zlev ) } } - if( cur_submap->lum[sx][sy] && has_items( p ) ) { + if( cur_submap->get_lum( { sx, sy } ) && has_items( p ) ) { auto items = i_at( p ); add_light_from_items( p, items.begin(), items.end() ); } diff --git a/src/map.cpp b/src/map.cpp index c022561cfad59..8d53a52a2e0c2 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3942,7 +3942,7 @@ void map::i_clear( const tripoint &p ) submaps_with_active_items.erase( tripoint( abs_sub.x + p.x / SEEX, abs_sub.y + p.y / SEEY, p.z ) ); } - current_submap->lum[l.x][l.y] = 0; + current_submap->set_lum( l, 0 ); current_submap->itm[l.x][l.y].clear(); } diff --git a/src/submap.h b/src/submap.h index 0ca6dba7bdf7d..1b4b515ce2461 100644 --- a/src/submap.h +++ b/src/submap.h @@ -110,6 +110,15 @@ class submap : public maptile_soa // TODO: Use private inheritanc rad[p.x][p.y] = radiation; } + uint8_t get_lum( const point &p ) const { + return lum[p.x][p.y]; + } + + void set_lum( const point &p, uint8_t luminance ) { + is_uniform = false; + lum[p.x][p.y] = luminance; + } + void update_lum_add( const point &p, const item &i ) { is_uniform = false; if( i.is_emissive() && lum[p.x][p.y] < 255 ) {