diff --git a/src/lightmap.cpp b/src/lightmap.cpp index ac2eadff1dc89..e0b05b54e028e 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -241,11 +241,14 @@ void map::generate_lightmap( const int zlev ) ) && outside_cache[p.x + dir_x[i]][p.y + dir_y[i]] ) { if( light_transparency( p ) > LIGHT_TRANSPARENCY_SOLID ) { - lm[p.x][p.y][quadrant::default_] = natural_light; + update_light_quadrants( + lm[p.x][p.y], natural_light, quadrant::default_ ); apply_directional_light( p, dir_d[i], natural_light ); } else { - lm[p.x][p.y][dir_quadrants[i][0]] = natural_light; - lm[p.x][p.y][dir_quadrants[i][1]] = natural_light; + update_light_quadrants( + lm[p.x][p.y], natural_light, dir_quadrants[i][0] ); + update_light_quadrants( + lm[p.x][p.y], natural_light, dir_quadrants[i][1] ); } } } diff --git a/tests/vision_test.cpp b/tests/vision_test.cpp index bbca0f0476239..06141819c441b 100644 --- a/tests/vision_test.cpp +++ b/tests/vision_test.cpp @@ -21,6 +21,7 @@ void full_map_test( const std::vector &setup, g->place_player( tripoint( 60, 60, 0 ) ); g->reset_light_level(); + g->u.worn.clear(); // Remove any light-emitting clothing g->u.clear_effects(); clear_map(); @@ -48,9 +49,16 @@ void full_map_test( const std::vector &setup, tripoint origin; for( int y = 0; y < height; ++y ) { for( int x = 0; x < width; ++x ) { - if( setup[y][x] == 'U' || setup[y][x] == 'u' ) { - origin = g->u.pos() - point( x, y ); - break; + switch( setup[y][x] ) { + case 'V': + case 'U': + case 'u': + origin = g->u.pos() - point( x, y ); + if( setup[y][x] == 'V' ) { + item headlamp( "wearable_light_on" ); + g->u.worn.push_back( headlamp ); + } + break; } } } @@ -63,7 +71,7 @@ void full_map_test( const std::vector &setup, REQUIRE( player_offset.x >= 0 ); REQUIRE( player_offset.x < width ); char player_char = setup[player_offset.y][player_offset.x]; - REQUIRE( ( player_char == 'U' || player_char == 'u' ) ); + REQUIRE( ( player_char == 'U' || player_char == 'u' || player_char == 'V' ) ); } for( int y = 0; y < height; ++y ) { @@ -86,6 +94,7 @@ void full_map_test( const std::vector &setup, g->m.ter_set( p, t_floor ); break; case 'U': + case 'V': // Already handled above break; default: @@ -269,6 +278,7 @@ static constexpr int midday = HOURS( 12 ); // '-' - empty, indoors // 'U' - player, outdoors // 'u' - player, indoors +// 'V' - player, with light in inventory // 'L' - light, indoors // '#' - wall // '=' - window frame @@ -395,6 +405,30 @@ TEST_CASE( "vision_wall_obstructs_light", "[shadowcasting][vision]" ) t.test_all(); } +TEST_CASE( "vision_wall_can_be_lit_by_player", "[shadowcasting][vision]" ) +{ + vision_test_case t { + { + " V", + " ", + " ", + "##", + "--", + }, + { + "44", + "44", + "44", + "44", + "66", + }, + midnight, + true + }; + + t.test_all(); +} + TEST_CASE( "vision_see_wall_in_moonlight", "[shadowcasting][vision]" ) { const time_duration till_full_moon = calendar::season_length() / 3;