| 1787 | }; |
| 1788 | |
| 1789 | Direction GetDirectionTowards(const Vehicle *v, int x, int y) |
| 1790 | { |
| 1791 | int i = 0; |
| 1792 | |
| 1793 | if (y >= v->y_pos) { |
| 1794 | if (y != v->y_pos) i += 3; |
| 1795 | i += 3; |
| 1796 | } |
| 1797 | |
| 1798 | if (x >= v->x_pos) { |
| 1799 | if (x != v->x_pos) i++; |
| 1800 | i++; |
| 1801 | } |
| 1802 | |
| 1803 | Direction dir = v->direction; |
| 1804 | |
| 1805 | DirDiff dirdiff = DirDifference(_new_direction_table[i], dir); |
| 1806 | if (dirdiff == DIRDIFF_SAME) return dir; |
| 1807 | return ChangeDir(dir, dirdiff > DIRDIFF_REVERSE ? DIRDIFF_45LEFT : DIRDIFF_45RIGHT); |
| 1808 | } |
| 1809 | |
| 1810 | /** |
| 1811 | * Call the tile callback function for a vehicle entering a tile |
no test coverage detected