* Check if the direction of start and end tile should be swapped based on * the dragging-style. Default directions are: * in the case of a line (HT_RAIL, HT_LINE): DIR_NE, DIR_NW, DIR_N, DIR_E * in the case of a rect (HT_RECT, HT_POINT): DIR_S, DIR_E * For example dragging a rectangle area from south to north should be swapped to * north-south (DIR_S) to obtain the same results with less cod
| 2923 | * @return boolean value which when true means start/end should be swapped |
| 2924 | */ |
| 2925 | static bool SwapDirection(HighLightStyle style, TileIndex start_tile, TileIndex end_tile) |
| 2926 | { |
| 2927 | uint start_x = TileX(start_tile); |
| 2928 | uint start_y = TileY(start_tile); |
| 2929 | uint end_x = TileX(end_tile); |
| 2930 | uint end_y = TileY(end_tile); |
| 2931 | |
| 2932 | switch (style & HT_DRAG_MASK) { |
| 2933 | case HT_RAIL: |
| 2934 | case HT_LINE: return (end_x > start_x || (end_x == start_x && end_y > start_y)); |
| 2935 | |
| 2936 | case HT_RECT: |
| 2937 | case HT_POINT: return (end_x != start_x && end_y < start_y); |
| 2938 | default: NOT_REACHED(); |
| 2939 | } |
| 2940 | |
| 2941 | return false; |
| 2942 | } |
| 2943 | |
| 2944 | /** |
| 2945 | * Calculates height difference between one tile and another. |
no test coverage detected