@@ -173,11 +173,14 @@ static bool get_pathability_groups(color_ostream &out, unordered_set<uint16_t> *
173173static bool get_entry_tiles (unordered_set<df::coord> * entry_tiles, const unordered_set<uint16_t > & depot_pathability_groups) {
174174 auto & edge = plotinfo->map_edge ;
175175 size_t num_edge_tiles = edge.surface_x .size ();
176+ uint32_t max_x, max_y, max_z;
177+ Maps::getTileSize (max_x, max_y, max_z);
176178 bool found = false ;
177179 for (size_t idx = 0 ; idx < num_edge_tiles; ++idx) {
178180 df::coord pos (edge.surface_x [idx], edge.surface_y [idx], edge.surface_z [idx]);
179181 auto wgroup = Maps::getWalkableGroup (pos);
180- if (depot_pathability_groups.contains (wgroup)) {
182+ if (depot_pathability_groups.contains (wgroup) &&
183+ (pos.x == 0 || pos.y == 0 || pos.x == (int16_t )max_x || pos.y == (int16_t )max_y)) {
181184 found = true ;
182185 if (!entry_tiles)
183186 break ;
@@ -372,22 +375,14 @@ static bool wagon_flood(color_ostream &out, unordered_set<df::coord> * wagon_pat
372375 ctx.seen .emplace (depot_pos);
373376 ctx.search_edge .emplace (depot_pos);
374377
375- auto & edge = plotinfo->map_edge ;
376- size_t num_edge_tiles = edge.surface_x .size ();
377- int max_edge_x = edge.surface_x [num_edge_tiles - 1 ];
378- int max_edge_y = edge.surface_y [num_edge_tiles - 1 ];
379-
380378 while (!ctx.search_edge .empty ()) {
381379 df::coord pos = ctx.search_edge .top ();
382380 ctx.search_edge .pop ();
383381
384382 TRACE (log,out).print (" checking tile: (%d, %d, %d); pathability group: %d\n " , pos.x , pos.y , pos.z ,
385383 Maps::getWalkableGroup (pos));
386384
387- // Ensure our wagon flood end points lands on an edge tile.
388- // When there is no path to the depot search_edge will not
389- // contain any edge tiles.
390- if ((pos.x == 0 || pos.y == 0 || pos.x == max_edge_x || pos.y == max_edge_y) && entry_tiles.contains (pos)) {
385+ if (entry_tiles.contains (pos)) {
391386 found = true ;
392387 if (!wagon_path)
393388 break ;
0 commit comments