Skip to content

Commit e1eb146

Browse files
committed
Dedupe check for tile passable down in creature flood fill. Also rename map
1 parent 218dc92 commit e1eb146

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/creature_tracker.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -362,41 +362,43 @@ void creature_tracker::flood_fill_zone( const Creature &origin )
362362
return;
363363
}
364364

365-
map &map = get_map();
365+
map &here = get_map();
366366
ff::flood_fill_visit_10_connected( origin.pos_bub(),
367-
[&map]( const tripoint_bub_ms & loc, int direction ) {
367+
[&here]( const tripoint_bub_ms & loc, int direction ) {
368368
if( direction == 0 ) {
369-
return map.inbounds( loc ) && ( map.is_transparent_wo_fields( loc ) ||
370-
map.passable( loc ) );
369+
return here.inbounds( loc ) && ( here.is_transparent_wo_fields( loc ) ||
370+
here.passable( loc ) );
371371
}
372+
373+
auto check_location_passable_down = [loc, &here]( const maptile & mt, const ter_t & ter ) {
374+
return ( ( ter.movecost != 0 && mt.get_furn_t().movecost >= 0 ) ||
375+
here.is_transparent_wo_fields( loc ) ) &&
376+
( ter.has_flag( ter_furn_flag::TFLAG_NO_FLOOR ) ||
377+
ter.has_flag( ter_furn_flag::TFLAG_GOES_DOWN ) );
378+
};
379+
372380
if( direction == 1 ) {
373-
const maptile &up = map.maptile_at( loc );
381+
const maptile &up = here.maptile_at( loc );
374382
const ter_t &up_ter = up.get_ter_t();
375383
if( up_ter.id.is_null() ) {
376384
return false;
377385
}
378-
if( ( ( up_ter.movecost != 0 && up.get_furn_t().movecost >= 0 ) ||
379-
map.is_transparent_wo_fields( loc ) ) &&
380-
( up_ter.has_flag( ter_furn_flag::TFLAG_NO_FLOOR ) ||
381-
up_ter.has_flag( ter_furn_flag::TFLAG_GOES_DOWN ) ) ) {
386+
if( check_location_passable_down( up, up_ter ) ) {
382387
return true;
383388
}
384389
}
385390
if( direction == -1 ) {
386-
const maptile &up = map.maptile_at( loc + tripoint::above );
391+
const maptile &up = here.maptile_at( loc + tripoint::above );
387392
const ter_t &up_ter = up.get_ter_t();
388393
if( up_ter.id.is_null() ) {
389394
return false;
390395
}
391-
const maptile &down = map.maptile_at( loc );
396+
const maptile &down = here.maptile_at( loc );
392397
const ter_t &down_ter = up.get_ter_t();
393398
if( down_ter.id.is_null() ) {
394399
return false;
395400
}
396-
if( ( ( down_ter.movecost != 0 && down.get_furn_t().movecost >= 0 ) ||
397-
map.is_transparent_wo_fields( loc ) ) &&
398-
( up_ter.has_flag( ter_furn_flag::TFLAG_NO_FLOOR ) ||
399-
up_ter.has_flag( ter_furn_flag::TFLAG_GOES_DOWN ) ) ) {
401+
if( check_location_passable_down( down, down_ter ) ) {
400402
return true;
401403
}
402404
}

0 commit comments

Comments
 (0)