* Assign a vehicle window a new vehicle * @param window_class WindowClass to search for * @param from_index the old vehicle ID * @param to_index the new vehicle ID */
| 1564 | * @param to_index the new vehicle ID |
| 1565 | */ |
| 1566 | static inline void ChangeVehicleWindow(WindowClass window_class, VehicleID from_index, VehicleID to_index) |
| 1567 | { |
| 1568 | Window *w = FindWindowById(window_class, from_index); |
| 1569 | if (w != nullptr) { |
| 1570 | /* Update window_number */ |
| 1571 | w->window_number = to_index; |
| 1572 | if (w->viewport != nullptr) w->viewport->follow_vehicle = to_index; |
| 1573 | |
| 1574 | /* Update vehicle drag data */ |
| 1575 | if (_thd.window_class == window_class && _thd.window_number == from_index) { |
| 1576 | _thd.window_number = to_index; |
| 1577 | } |
| 1578 | |
| 1579 | /* Notify the window. */ |
| 1580 | w->InvalidateData(VIWD_AUTOREPLACE, false); |
| 1581 | } |
| 1582 | } |
| 1583 | |
| 1584 | /** |
| 1585 | * Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows. |
no test coverage detected