Skip to content

Commit

Permalink
Encapsulate frn
Browse files Browse the repository at this point in the history
  • Loading branch information
ifreund committed Feb 10, 2020
1 parent 082e978 commit 98ac91f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ bool map::build_transparency_cache( const int zlev )
}

if( !( cur_submap->get_ter( { sx, sy } ).obj().transparent &&
cur_submap->frn[sx][sy].obj().transparent ) ) {
cur_submap->get_furn( {sx, sy } ).obj().transparent ) ) {
value = LIGHT_TRANSPARENCY_SOLID;
zero_value = LIGHT_TRANSPARENCY_SOLID;
continue;
Expand Down Expand Up @@ -326,7 +326,7 @@ void map::generate_lightmap( const int zlev )
if( terrain->light_emitted > 0 ) {
add_light_source( p, terrain->light_emitted );
}
const furn_id furniture = cur_submap->frn[sx][sy];
const furn_id furniture = cur_submap->get_furn( {sx, sy } );
if( furniture->light_emitted > 0 ) {
add_light_source( p, furniture->light_emitted );
}
Expand Down
2 changes: 1 addition & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7395,7 +7395,7 @@ fake_map::fake_map( const furn_id &fur_type, const ter_id &ter_type, const trap_
std::unique_ptr<submap> sm = std::make_unique<submap>();

sm->set_all_ter( ter_type );
std::uninitialized_fill_n( &sm->frn[0][0], SEEX * SEEY, fur_type );
sm->set_all_furn( fur_type );
std::uninitialized_fill_n( &sm->trp[0][0], SEEX * SEEY, trap_type );

setsubmap( get_nonant( { gridx, gridy, fake_map_z } ), sm.get() );
Expand Down
5 changes: 5 additions & 0 deletions src/submap.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class submap : public maptile_soa<SEEX, SEEY> // TODO: Use private inheritanc
frn[p.x][p.y] = furn;
}

void set_all_furn( const furn_id &furn ) {
constexpr size_t block_size = SEEX * SEEY;
std::uninitialized_fill_n( &frn[0][0], block_size, furn );
}

ter_id get_ter( const point &p ) const {
return ter[p.x][p.y];
}
Expand Down

0 comments on commit 98ac91f

Please sign in to comment.