Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5031: Fix accessibility logic for wagons #5053

Merged
merged 25 commits into from
Dec 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
50fe672
#5031: Handle top ramps when pathfinding to depot
dhthwy Nov 29, 2024
7e6ec6f
#5031: Assign RAMP_TOP a walkability group from an adjacent tile
dhthwy Nov 29, 2024
ec83a70
#5031: Remove debug prints
dhthwy Nov 29, 2024
2b76868
#5031: Fix MSVC build. Missing headers?
dhthwy Nov 29, 2024
d6083da
Merge branch 'develop' into wagonpathfix
dhthwy Nov 29, 2024
3c7a3b2
#5031: make wagon_flood() check it reaches an edge tile for correctly…
dhthwy Nov 30, 2024
8ea4f6a
#5031: Make wagon pathability tests more robust
dhthwy Dec 1, 2024
317b87d
Merge branch 'develop' into wagonpathfix
dhthwy Dec 1, 2024
a0a37f3
Correctly handle wagon accessible tiles for passable buildings
dhthwy Dec 1, 2024
2a1a734
#5031: handle tracks, murky pool and river tiles
dhthwy Dec 2, 2024
d11dd6d
Merge branch 'develop' into wagonpathfix
dhthwy Dec 7, 2024
7c384c9
Revert "#5031: Fix MSVC build. Missing headers?"
dhthwy Dec 7, 2024
464ef96
Revert "#5031: Remove debug prints"
dhthwy Dec 7, 2024
47eb2ed
Revert "#5031: Assign RAMP_TOP a walkability group from an adjacent t…
dhthwy Dec 7, 2024
3acd1eb
Revert "#5031: Handle top ramps when pathfinding to depot"
dhthwy Dec 7, 2024
0063cd7
remove invalidated RAMP_TOP comment
dhthwy Dec 7, 2024
67497ed
#5031: update changelog
dhthwy Dec 7, 2024
10dd5d0
#5031: check the center too. maybe fix errant passable trees/boulders.
dhthwy Dec 8, 2024
7e33948
Merge branch 'develop' into wagonpathfix
dhthwy Dec 8, 2024
22c7ebe
Merge branch 'develop' into wagonpathfix
dhthwy Dec 8, 2024
6c5dc47
Merge branch 'develop' into wagonpathfix
myk002 Dec 9, 2024
d5ac7c6
Merge branch 'develop' into wagonpathfix
dhthwy Dec 9, 2024
e926210
#5031: check if path exists for bottom and right edge tiles too, plus…
dhthwy Dec 9, 2024
ef0b0e4
#5031: resolve some other minor issues
dhthwy Dec 9, 2024
5d24e07
#5031: don't add non-edge tiles to entry_tiles
dhthwy Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#5031: handle tracks, murky pool and river tiles
dhthwy committed Dec 2, 2024

Verified

This commit was signed with the committer’s verified signature.
Sebobo Sebastian Helzle
commit 2a1a7345793c5e56929435071d52e9ab6bd1300c
37 changes: 27 additions & 10 deletions plugins/pathable.cpp
Original file line number Diff line number Diff line change
@@ -235,12 +235,28 @@ static bool is_wagon_dynamic_traversible(df::tiletype_shape shape, const df::coo
return false;
}

static bool is_wagon_tile_traversible(df::tiletype_shape shape) {
// TODO: smoothed boulders are traversible
if (shape == df::tiletype_shape::STAIR_UP || shape == df::tiletype_shape::STAIR_DOWN ||
// NOTE: When i.e. tracks, stairs have a bridge over them, the tile will have
// an occupancy of floored.
static bool is_wagon_tile_traversible(df::tiletype& tt) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

df::tiletype is just an int (an enum), so no need to take a reference

auto shape = tileShape(tt);
auto special = tileSpecial(tt);
auto material = tileMaterial(tt);

// Allow murky pool ramps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe explain why you're calling out murky pools in particular

if (shape == df::tiletype_shape::RAMP_TOP)
return true;
// NOTE: smoothing a boulder turns it into a smoothed floor
else if (shape == df::tiletype_shape::STAIR_UP || shape == df::tiletype_shape::STAIR_DOWN ||
shape == df::tiletype_shape::STAIR_UPDOWN || shape == df::tiletype_shape::BOULDER ||
shape == df::tiletype_shape::EMPTY || shape == df::tiletype_shape::NONE)
return false;
else if (special == df::tiletype_special::TRACK)
return false;
// Fires seem to have their own path group, and group for lava is 0
// According to wiki, the wagon won't path thru pool and river tiles, but ramps are ok
else if (material == df::tiletype_material::POOL || material == df::tiletype_material::RIVER)
return false;

return true;
}

@@ -250,14 +266,13 @@ static bool is_wagon_traversible(FloodCtx & ctx, const df::coord & pos, const df
return false;

auto shape = tileShape(*tt);

auto& occ = *Maps::getTileOccupancy(pos);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while the return value should never ever be NULL if tt is not NULL, it's still common practice to check it before dereferencing it

switch (occ.bits.building) {
case tile_building_occ::Obstacle: // Statue
case tile_building_occ::Obstacle: // Statues, windmills (middle tile)
//FALLTHROUGH
case tile_building_occ::Well:
//FALLTHROUGH
case tile_building_occ::Impassable: // Raised bridge
case tile_building_occ::Impassable: // Raised bridges
return false;

case tile_building_occ::Dynamic:
@@ -272,13 +287,15 @@ static bool is_wagon_traversible(FloodCtx & ctx, const df::coord & pos, const df
case tile_building_occ::Planned:
//FALLTHROUGH
case tile_building_occ::Passable:
// bed, support, rollers, armor/weapon stand, cage (not trap)
// open wall grate/vertical bars, retracted bridge, open floodgate
if (is_wagon_tile_traversible(shape) == false)
// Any tile with no building or a passable building including
// beds, supports, rollers, armor/weapon stands, cages (not traps),
// open wall grate/vertical bars, retracted bridges, open floodgates,
// workshops (tiles with open space are handled by the tile check)
if (is_wagon_tile_traversible(*tt) == false)
return false;
break;
case tile_building_occ::Floored:
// depot, lowered bridge, retracable bridge, forbidden hatch
// depot, lowered bridges or retractable bridges, forbidden hatches
break;
default:
//NOTREACHED