equal
deleted
inserted
replaced
1648 /* Determine the diagonal direction in which we will exit this tile */ |
1648 /* Determine the diagonal direction in which we will exit this tile */ |
1649 if (!(v->direction & 1) && v->u.rail.track != _state_dir_table[dir]) { |
1649 if (!(v->direction & 1) && v->u.rail.track != _state_dir_table[dir]) { |
1650 dir = ChangeDiagDir(dir, DIAGDIRDIFF_90LEFT); |
1650 dir = ChangeDiagDir(dir, DIAGDIRDIFF_90LEFT); |
1651 } |
1651 } |
1652 /* Calculate next tile */ |
1652 /* Calculate next tile */ |
1653 tile += TileOffsByDir(dir); |
1653 tile += TileOffsByDiagDir(dir); |
1654 |
1654 |
1655 /* Check if the train left a rail/road-crossing */ |
1655 /* Check if the train left a rail/road-crossing */ |
1656 DisableTrainCrossing(tile); |
1656 DisableTrainCrossing(tile); |
1657 } |
1657 } |
1658 |
1658 |
2265 NPFFillWithOrderData(&fstd, v); |
2265 NPFFillWithOrderData(&fstd, v); |
2266 /* The enterdir for the new tile, is the exitdir for the old tile */ |
2266 /* The enterdir for the new tile, is the exitdir for the old tile */ |
2267 trackdir = GetVehicleTrackdir(v); |
2267 trackdir = GetVehicleTrackdir(v); |
2268 assert(trackdir != 0xff); |
2268 assert(trackdir != 0xff); |
2269 |
2269 |
2270 ftd = NPFRouteToStationOrTile(tile - TileOffsByDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes); |
2270 ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes); |
2271 |
2271 |
2272 if (ftd.best_trackdir == 0xff) { |
2272 if (ftd.best_trackdir == 0xff) { |
2273 /* We are already at our target. Just do something */ |
2273 /* We are already at our target. Just do something */ |
2274 //TODO: maybe display error? |
2274 //TODO: maybe display error? |
2275 //TODO: go straight ahead if possible? |
2275 //TODO: go straight ahead if possible? |
2294 /* New train pathfinding */ |
2294 /* New train pathfinding */ |
2295 fd.best_bird_dist = (uint)-1; |
2295 fd.best_bird_dist = (uint)-1; |
2296 fd.best_track_dist = (uint)-1; |
2296 fd.best_track_dist = (uint)-1; |
2297 fd.best_track = 0xFF; |
2297 fd.best_track = 0xFF; |
2298 |
2298 |
2299 NewTrainPathfind(tile - TileOffsByDir(enterdir), v->dest_tile, |
2299 NewTrainPathfind(tile - TileOffsByDiagDir(enterdir), v->dest_tile, |
2300 v->u.rail.compatible_railtypes, enterdir, (NTPEnumProc*)NtpCallbFindStation, &fd); |
2300 v->u.rail.compatible_railtypes, enterdir, (NTPEnumProc*)NtpCallbFindStation, &fd); |
2301 |
2301 |
2302 if (fd.best_track == 0xff) { |
2302 if (fd.best_track == 0xff) { |
2303 // blaha |
2303 // blaha |
2304 best_track = FIND_FIRST_BIT(trackdirbits); |
2304 best_track = FIND_FIRST_BIT(trackdirbits); |
3113 } else if (_m[gp.new_tile].m3 & SignalAlongTrackdir(i)){ |
3113 } else if (_m[gp.new_tile].m3 & SignalAlongTrackdir(i)){ |
3114 v->cur_speed = 0; |
3114 v->cur_speed = 0; |
3115 v->subspeed = 0; |
3115 v->subspeed = 0; |
3116 v->progress = 255-10; |
3116 v->progress = 255-10; |
3117 if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) { |
3117 if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) { |
3118 TileIndex o_tile = gp.new_tile + TileOffsByDir(enterdir); |
3118 TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir); |
3119 VehicleAtSignalData vasd; |
3119 VehicleAtSignalData vasd; |
3120 vasd.tile = o_tile; |
3120 vasd.tile = o_tile; |
3121 vasd.direction = ReverseDir(dir); |
3121 vasd.direction = ReverseDir(dir); |
3122 |
3122 |
3123 /* check if a train is waiting on the other side */ |
3123 /* check if a train is waiting on the other side */ |
3321 dir = DirToDiagDir(v->direction); |
3321 dir = DirToDiagDir(v->direction); |
3322 if (!(v->direction & 1) && v->u.rail.track != _state_dir_table[dir]) { |
3322 if (!(v->direction & 1) && v->u.rail.track != _state_dir_table[dir]) { |
3323 dir = ChangeDiagDir(dir, DIAGDIRDIFF_90LEFT); |
3323 dir = ChangeDiagDir(dir, DIAGDIRDIFF_90LEFT); |
3324 } |
3324 } |
3325 /* Calculate next tile */ |
3325 /* Calculate next tile */ |
3326 tile += TileOffsByDir(dir); |
3326 tile += TileOffsByDiagDir(dir); |
3327 // determine the track status on the next tile. |
3327 // determine the track status on the next tile. |
3328 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _reachable_tracks[dir]; |
3328 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _reachable_tracks[dir]; |
3329 |
3329 |
3330 /* Calc position within the current tile ?? */ |
3330 /* Calc position within the current tile ?? */ |
3331 x = v->x_pos & 0xF; |
3331 x = v->x_pos & 0xF; |