1
0
Fork 0

Fix #9811, 9156d7b: Use the NewGRF-defined vehicle center when dragging ships and aircraft. (#9812)

The alignment using the total-width of the vehicle-chain was meant for articulated trains and road vehicles only.
pull/9844/head
frosch 2022-02-08 23:08:03 +01:00 committed by Patric Stout
parent 45a1036177
commit 6f6bc66997
1 changed files with 8 additions and 4 deletions

View File

@ -3183,6 +3183,7 @@ void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
int total_width = 0; int total_width = 0;
int y_offset = 0; int y_offset = 0;
bool rotor_seq = false; // Whether to draw the rotor of the vehicle in this step. bool rotor_seq = false; // Whether to draw the rotor of the vehicle in this step.
bool is_ground_vehicle = v->IsGroundVehicle();
while (v != nullptr) { while (v != nullptr) {
if (total_width >= ScaleGUITrad(2 * (int)VEHICLEINFO_FULL_VEHICLE_WIDTH)) break; if (total_width >= ScaleGUITrad(2 * (int)VEHICLEINFO_FULL_VEHICLE_WIDTH)) break;
@ -3218,10 +3219,13 @@ void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
} }
} }
int offs = (ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2; if (is_ground_vehicle) {
if (rtl) offs = -offs; /* Center trains and road vehicles on the front vehicle */
for (uint i = 0; i < _cursor.sprite_count; ++i) { int offs = (ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2;
_cursor.sprite_pos[i].x += offs; if (rtl) offs = -offs;
for (uint i = 0; i < _cursor.sprite_count; ++i) {
_cursor.sprite_pos[i].x += offs;
}
} }
UpdateCursorSize(); UpdateCursorSize();