diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 4b040882e3..290080fc98 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -480,13 +480,14 @@ struct DepotWindow : Window { this->sel = INVALID_VEHICLE; TrainDepotMoveVehicle(v, sel, gdvp.head); } else if (v != NULL) { - int image = v->GetImage(_current_text_dir == TD_RTL ? DIR_E : DIR_W, EIT_IN_DEPOT); + bool rtl = _current_text_dir == TD_RTL; + int image = v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DEPOT); SetObjectToPlaceWnd(image, GetVehiclePalette(v), HT_DRAG, this); this->sel = v->index; this->SetDirty(); - _cursor.short_vehicle_offset = v->IsGroundVehicle() ? 16 - v->GetGroundVehicleCache()->cached_veh_length * 2 : 0; + _cursor.short_vehicle_offset = v->IsGroundVehicle() ? (16 - v->GetGroundVehicleCache()->cached_veh_length * 2) * (rtl ? -1 : 1) : 0; _cursor.vehchain = _ctrl_pressed; } break; diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp index d2ba554e76..8b55cabb4b 100644 --- a/src/script/api/script_order.cpp +++ b/src/script/api/script_order.cpp @@ -659,8 +659,8 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance) /* static */ uint ScriptOrder::GetOrderDistance(ScriptVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile) { if (vehicle_type == ScriptVehicle::VT_AIR) { - if (ScriptTile::IsStationTile(origin_tile) && ::Station::Get(origin_tile)->airport.tile != INVALID_TILE) origin_tile = ::Station::Get(origin_tile)->airport.tile; - if (ScriptTile::IsStationTile(dest_tile) && ::Station::Get(dest_tile)->airport.tile != INVALID_TILE) dest_tile = ::Station::Get(dest_tile)->airport.tile; + if (ScriptTile::IsStationTile(origin_tile) && ::Station::GetByTile(origin_tile)->airport.tile != INVALID_TILE) origin_tile = ::Station::GetByTile(origin_tile)->airport.tile; + if (ScriptTile::IsStationTile(dest_tile) && ::Station::GetByTile(dest_tile)->airport.tile != INVALID_TILE) dest_tile = ::Station::GetByTile(dest_tile)->airport.tile; return ScriptMap::DistanceSquare(origin_tile, dest_tile); } else { diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 64b83e8e24..d4acee4fe9 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2165,11 +2165,13 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint /* Check if local auth would allow a new airport */ StringID authority_refuse_message = STR_NULL; + Town *authority_refuse_town = NULL; if (_settings_game.economy.station_noise_level) { /* do not allow to build a new airport if this raise the town noise over the maximum allowed by town */ if ((nearest->noise_reached + newnoise_level) > nearest->MaxTownNoise()) { authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE; + authority_refuse_town = nearest; } } else { uint num = 0; @@ -2179,11 +2181,12 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint } if (num >= 2) { authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT; + authority_refuse_town = t; } } if (authority_refuse_message != STR_NULL) { - SetDParam(0, t->index); + SetDParam(0, authority_refuse_town->index); return_cmd_error(authority_refuse_message); } diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 5d5fe3ab7d..7888b0d658 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -61,8 +61,10 @@ static int HighlightDragPosition(int px, int max_width, VehicleID selection) bool rtl = _current_text_dir == TD_RTL; assert(selection != INVALID_VEHICLE); - Point offset; - int dragged_width = Train::Get(selection)->GetDisplayImageWidth(&offset) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; + int dragged_width = WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; + for (Train *t = Train::Get(selection); t != NULL; t = t->HasArticulatedPart() ? t->GetNextArticulatedPart() : NULL) { + dragged_width += t->GetDisplayImageWidth(NULL); + } int drag_hlight_left = rtl ? max(px -dragged_width, 0) : px; int drag_hlight_right = rtl ? px : min(px + dragged_width, max_width);