Skip to content

Commit

Permalink
Encapsulate lum
Browse files Browse the repository at this point in the history
  • Loading branch information
ifreund committed Feb 10, 2020
1 parent 98ac91f commit 2f3e33d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}
Expand Down
2 changes: 1 addition & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
9 changes: 9 additions & 0 deletions src/submap.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ class submap : public maptile_soa<SEEX, SEEY> // 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 ) {
Expand Down

0 comments on commit 2f3e33d

Please sign in to comment.