Skip to content

Commit

Permalink
Optimize get_heat_radiation
Browse files Browse the repository at this point in the history
Cache a variable, use the already fetched maptile to check the terrain
at the tile instead of looking up the submap again.
  • Loading branch information
anothersimulacrum committed Aug 13, 2021
1 parent b3c2331 commit 3c03d58
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1273,16 +1273,18 @@ int get_heat_radiation( const tripoint &location, bool direct )
int best_fire = 0;
Character &player_character = get_player_character();
map &here = get_map();
// Convert it to an int id once, instead of 139 times per turn
const field_type_id fd_fire_int = fd_fire.id();
for( const tripoint &dest : here.points_in_radius( location, 6 ) ) {
int heat_intensity = 0;

maptile mt = here.maptile_at( dest );

int ffire = maptile_field_intensity( mt, fd_fire );
int ffire = maptile_field_intensity( mt, fd_fire_int );
if( ffire > 0 ) {
heat_intensity = ffire;
} else {
heat_intensity = here.ter( dest )->heat_radiation;
heat_intensity = mt.get_ter()->heat_radiation;
}
if( heat_intensity == 0 ) {
// No heat source here
Expand Down

0 comments on commit 3c03d58

Please sign in to comment.