src/pathfind.cpp
changeset 8976 1fd3a02c3432
parent 8894 1e5b2d4380b8
child 9107 3e57b96e98f2
--- a/src/pathfind.cpp	Mon Feb 04 11:28:12 2008 +0000
+++ b/src/pathfind.cpp	Mon Feb 04 14:08:02 2008 +0000
@@ -287,7 +287,8 @@
 				tpf->the_dir = (Trackdir)((_otherdir_mask[direction] & (byte)(1 << i)) ? (i + 8) : i);
 				RememberData rd = tpf->rd;
 
-				if (TPFSetTileBit(tpf, tile, tpf->the_dir) &&
+				/* make sure we are not leaving from invalid side */
+				if (TPFSetTileBit(tpf, tile, tpf->the_dir) && CanAccessTileInDir(tile, TrackdirToExitdir(tpf->the_dir), tpf->tracktype) &&
 						!tpf->enum_proc(tile, tpf->userdata, tpf->the_dir, tpf->rd.cur_length, &tpf->rd.pft_var6) ) {
 					TPFMode1(tpf, tile, _tpf_new_direction[tpf->the_dir]);
 				}