returns true if a continuous 3-wide path can be found to an entry tile assumes: - wagons can only move in orthogonal directions - if three adjacent tiles are in the same pathability group, then they are traversible by a wagon - a wagon needs a single ramp to move elevations as long as the adjacent tiles are walkable TODO: cannot traverse doors, up stairs, or up/down stairs
| 369 | // - a wagon needs a single ramp to move elevations as long as the adjacent tiles are walkable |
| 370 | // TODO: cannot traverse doors, up stairs, or up/down stairs |
| 371 | static bool wagon_flood(color_ostream &out, unordered_set<df::coord> * wagon_path, const df::coord & depot_pos, |
| 372 | const unordered_set<df::coord> & entry_tiles) |
| 373 | { |
| 374 | unordered_set<df::coord> temp_wagon_path; |
| 375 | FloodCtx ctx(Maps::getWalkableGroup(depot_pos), wagon_path ? *wagon_path : temp_wagon_path, entry_tiles); |
| 376 | |
| 377 | if (!ctx.wgroup) |
| 378 | return false; |
| 379 | |
| 380 | bool found = false; |
| 381 | ctx.wagon_path.emplace(depot_pos); |
| 382 | ctx.seen.emplace(depot_pos); |
| 383 | ctx.search_edge.emplace(depot_pos); |
| 384 | |
| 385 | while (!ctx.search_edge.empty()) { |
| 386 | df::coord pos = ctx.search_edge.top(); |
| 387 | ctx.search_edge.pop(); |
| 388 | |
| 389 | TRACE(log,out).print("checking tile: ({}, {}, {}); pathability group: {}\n", pos.x, pos.y, pos.z, |
| 390 | Maps::getWalkableGroup(pos)); |
| 391 | |
| 392 | if (entry_tiles.contains(pos)) { |
| 393 | found = true; |
| 394 | if (!wagon_path) |
| 395 | break; |
| 396 | continue; |
| 397 | } |
| 398 | |
| 399 | check_wagon_tile(ctx, pos+df::coord( 0, -1, 0)); |
| 400 | check_wagon_tile(ctx, pos+df::coord( 0, 1, 0)); |
| 401 | check_wagon_tile(ctx, pos+df::coord(-1, 0, 0)); |
| 402 | check_wagon_tile(ctx, pos+df::coord( 1, 0, 0)); |
| 403 | } |
| 404 | |
| 405 | return found; |
| 406 | } |
| 407 | |
| 408 | static unordered_set<df::coord> wagon_path; |
| 409 | static unordered_set<df::coord> entry_tiles; |
no test coverage detected