changeset 7179 | 3e123c2b7c93 |
parent 7140 | 422457e07b54 |
child 7231 | 1fbf0b9881e9 |
7178:117401da853a | 7179:3e123c2b7c93 |
---|---|
1935 Vehicle* last = GetLastVehicleInChain(v); |
1935 Vehicle* last = GetLastVehicleInChain(v); |
1936 Trackdir trackdir = GetVehicleTrackdir(v); |
1936 Trackdir trackdir = GetVehicleTrackdir(v); |
1937 Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last)); |
1937 Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last)); |
1938 |
1938 |
1939 assert(trackdir != INVALID_TRACKDIR); |
1939 assert(trackdir != INVALID_TRACKDIR); |
1940 NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY); |
1940 NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY); |
1941 if (ftd.best_bird_dist == 0) { |
1941 if (ftd.best_bird_dist == 0) { |
1942 /* Found target */ |
1942 /* Found target */ |
1943 tfdd.tile = ftd.node.tile; |
1943 tfdd.tile = ftd.node.tile; |
1944 /* Our caller expects a number of tiles, so we just approximate that |
1944 /* Our caller expects a number of tiles, so we just approximate that |
1945 * number by this. It might not be completely what we want, but it will |
1945 * number by this. It might not be completely what we want, but it will |
2300 NPFFillWithOrderData(&fstd, v); |
2300 NPFFillWithOrderData(&fstd, v); |
2301 /* The enterdir for the new tile, is the exitdir for the old tile */ |
2301 /* The enterdir for the new tile, is the exitdir for the old tile */ |
2302 Trackdir trackdir = GetVehicleTrackdir(v); |
2302 Trackdir trackdir = GetVehicleTrackdir(v); |
2303 assert(trackdir != 0xff); |
2303 assert(trackdir != 0xff); |
2304 |
2304 |
2305 NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes); |
2305 NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes); |
2306 |
2306 |
2307 if (ftd.best_trackdir == 0xff) { |
2307 if (ftd.best_trackdir == 0xff) { |
2308 /* We are already at our target. Just do something |
2308 /* We are already at our target. Just do something |
2309 * @todo maybe display error? |
2309 * @todo maybe display error? |
2310 * @todo: go straight ahead if possible? */ |
2310 * @todo: go straight ahead if possible? */ |
2410 trackdir = GetVehicleTrackdir(v); |
2410 trackdir = GetVehicleTrackdir(v); |
2411 trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last)); |
2411 trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last)); |
2412 assert(trackdir != 0xff); |
2412 assert(trackdir != 0xff); |
2413 assert(trackdir_rev != 0xff); |
2413 assert(trackdir_rev != 0xff); |
2414 |
2414 |
2415 ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, last->tile, trackdir_rev, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes); |
2415 ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, last->tile, trackdir_rev, &fstd, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes); |
2416 if (ftd.best_bird_dist != 0) { |
2416 if (ftd.best_bird_dist != 0) { |
2417 /* We didn't find anything, just keep on going straight ahead */ |
2417 /* We didn't find anything, just keep on going straight ahead */ |
2418 reverse_best = false; |
2418 reverse_best = false; |
2419 } else { |
2419 } else { |
2420 if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) { |
2420 if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) { |
2918 DiagDirection enterdir = DirToDiagDir(dir); |
2918 DiagDirection enterdir = DirToDiagDir(dir); |
2919 assert(IsValidDiagDirection(enterdir)); |
2919 assert(IsValidDiagDirection(enterdir)); |
2920 |
2920 |
2921 /* Get the status of the tracks in the new tile and mask |
2921 /* Get the status of the tracks in the new tile and mask |
2922 * away the bits that aren't reachable. */ |
2922 * away the bits that aren't reachable. */ |
2923 uint32 ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL) & _reachable_tracks[enterdir]; |
2923 uint32 ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL, 0) & _reachable_tracks[enterdir]; |
2924 |
2924 |
2925 /* Combine the from & to directions. |
2925 /* Combine the from & to directions. |
2926 * Now, the lower byte contains the track status, and the byte at bit 16 contains |
2926 * Now, the lower byte contains the track status, and the byte at bit 16 contains |
2927 * the signal status. */ |
2927 * the signal status. */ |
2928 uint32 tracks = ts | (ts >> 8); |
2928 uint32 tracks = ts | (ts >> 8); |
3263 dir = ChangeDiagDir(dir, DIAGDIRDIFF_90LEFT); |
3263 dir = ChangeDiagDir(dir, DIAGDIRDIFF_90LEFT); |
3264 } |
3264 } |
3265 /* Calculate next tile */ |
3265 /* Calculate next tile */ |
3266 tile += TileOffsByDiagDir(dir); |
3266 tile += TileOffsByDiagDir(dir); |
3267 // determine the track status on the next tile. |
3267 // determine the track status on the next tile. |
3268 uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _reachable_tracks[dir]; |
3268 uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _reachable_tracks[dir]; |
3269 |
3269 |
3270 /* Calc position within the current tile ?? */ |
3270 /* Calc position within the current tile ?? */ |
3271 uint x = v->x_pos & 0xF; |
3271 uint x = v->x_pos & 0xF; |
3272 uint y = v->y_pos & 0xF; |
3272 uint y = v->y_pos & 0xF; |
3273 |
3273 |