Changeset - r26175:78b5290227af
[Not reviewed]
master
0 1 0
frosch - 2 years ago 2022-02-08 22:08:03
frosch@openttd.org
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.
1 file changed with 8 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/vehicle_gui.cpp
Show inline comments
 
@@ -3186,6 +3186,7 @@ void SetMouseCursorVehicle(const Vehicle
 
	int total_width = 0;
 
	int y_offset = 0;
 
	bool rotor_seq = false; // Whether to draw the rotor of the vehicle in this step.
 
	bool is_ground_vehicle = v->IsGroundVehicle();
 

	
 
	while (v != nullptr) {
 
		if (total_width >= ScaleGUITrad(2 * (int)VEHICLEINFO_FULL_VEHICLE_WIDTH)) break;
 
@@ -3221,10 +3222,13 @@ void SetMouseCursorVehicle(const Vehicle
 
		}
 
	}
 

	
 
	int offs = (ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2;
 
	if (rtl) offs = -offs;
 
	for (uint i = 0; i < _cursor.sprite_count; ++i) {
 
		_cursor.sprite_pos[i].x += offs;
 
	if (is_ground_vehicle) {
 
		/* Center trains and road vehicles on the front vehicle */
 
		int offs = (ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2;
 
		if (rtl) offs = -offs;
 
		for (uint i = 0; i < _cursor.sprite_count; ++i) {
 
			_cursor.sprite_pos[i].x += offs;
 
		}
 
	}
 

	
 
	UpdateCursorSize();
0 comments (0 inline, 0 general)