Skip to content

Commit

Permalink
Move checking for size passability into its own condition block
Browse files Browse the repository at this point in the history
  • Loading branch information
harakka committed Nov 3, 2024
1 parent 43d1363 commit 5dc278a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/pathfinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,19 @@ int map::cost_to_pass( const tripoint_bub_ms &cur, const tripoint_bub_ms &p,
return climb_cost;
}

// If it's a door and we can open it from the tile we're on, cool.
// The open version of terrain/furniture also needs to be passable for our size.
// If terrain/furniture is openable but we can't fit through the open version, ignore the tile
if( allow_open_doors &&
( ( terrain.open &&
( terrain.open->has_flag( ter_furn_flag::TFLAG_SMALL_PASSAGE ) ? settings.size <
creature_size::large : true ) ) ||
( furniture.open &&
( furniture.open->has_flag( ter_furn_flag::TFLAG_SMALL_PASSAGE ) ? settings.size <
creature_size::large : true ) ) ) &&
( ( terrain.open && terrain.open->has_flag( ter_furn_flag::TFLAG_SMALL_PASSAGE ) ) ||
( furniture.open && furniture.open->has_flag( ter_furn_flag::TFLAG_SMALL_PASSAGE ) ) ||
// Windows with curtains need to be opened twice
( terrain.open->open && terrain.open->open->has_flag( ter_furn_flag::TFLAG_SMALL_PASSAGE ) ) ) &&
settings.size > creature_size::medium
) {
return PF_IMPASSABLE;
}

// If it's a door and we can open it from the tile we're on, cool.
if( allow_open_doors && ( terrain.open || furniture.open ) &&
( ( !terrain.has_flag( ter_furn_flag::TFLAG_OPENCLOSE_INSIDE ) &&
!furniture.has_flag( ter_furn_flag::TFLAG_OPENCLOSE_INSIDE ) ) ||
!is_outside( cur ) ) ) {
Expand Down

0 comments on commit 5dc278a

Please sign in to comment.