equal
deleted
inserted
replaced
537 offs = link->next; |
537 offs = link->next; |
538 assert(offs != 0xffff); |
538 assert(offs != 0xffff); |
539 } |
539 } |
540 } |
540 } |
541 |
541 |
542 |
|
543 static const uint16 _is_upwards_slope[15] = { |
|
544 0, ///< no tileh |
|
545 (1 << TRACKDIR_X_SW) | (1 << TRACKDIR_Y_NW), ///< 1 |
|
546 (1 << TRACKDIR_X_SW) | (1 << TRACKDIR_Y_SE), ///< 2 |
|
547 (1 << TRACKDIR_X_SW), ///< 3 |
|
548 (1 << TRACKDIR_X_NE) | (1 << TRACKDIR_Y_SE), ///< 4 |
|
549 0, ///< 5 |
|
550 (1 << TRACKDIR_Y_SE), ///< 6 |
|
551 0, ///< 7 |
|
552 (1 << TRACKDIR_X_NE) | (1 << TRACKDIR_Y_NW), ///< 8, |
|
553 (1 << TRACKDIR_Y_NW), ///< 9 |
|
554 0, ///< 10 |
|
555 0, ///< 11, |
|
556 (1 << TRACKDIR_X_NE), ///< 12 |
|
557 0, ///< 13 |
|
558 0, ///< 14 |
|
559 }; |
|
560 |
542 |
561 static uint DistanceMoo(TileIndex t0, TileIndex t1) |
543 static uint DistanceMoo(TileIndex t0, TileIndex t1) |
562 { |
544 { |
563 const uint dx = Delta(TileX(t0), TileX(t1)); |
545 const uint dx = Delta(TileX(t0), TileX(t1)); |
564 const uint dy = Delta(TileY(t0), TileY(t1)); |
546 const uint dy = Delta(TileY(t0), TileY(t1)); |
725 track = _new_trackdir[FIND_FIRST_BIT(bits)][direction]; |
707 track = _new_trackdir[FIND_FIRST_BIT(bits)][direction]; |
726 assert(track != INVALID_TRACKDIR); |
708 assert(track != INVALID_TRACKDIR); |
727 |
709 |
728 si.cur_length += _length_of_track[track]; |
710 si.cur_length += _length_of_track[track]; |
729 |
711 |
730 /* Check if this rail is an upwards slope. If it is, then add a penalty. |
712 /* Check if this rail is an upwards slope. If it is, then add a penalty. */ |
731 * Small optimization here.. if (track&7)>1 then it can't be a slope so we avoid calling GetTileSlope */ |
713 if (IsDiagonalTrackdir(track) && IsUphillTrackdir(GetTileSlope(tile, NULL), track)) { |
732 if ((track & 7) <= 1 && (_is_upwards_slope[GetTileSlope(tile, NULL)] & (1 << track)) ) { |
|
733 // upwards slope. add some penalty. |
714 // upwards slope. add some penalty. |
734 si.cur_length += 4 * DIAG_FACTOR; |
715 si.cur_length += 4 * DIAG_FACTOR; |
735 } |
716 } |
736 |
717 |
737 /* railway tile with signals..? */ |
718 /* railway tile with signals..? */ |