From 85740a02832c9c474833f929b4464eba06be66d3 Mon Sep 17 00:00:00 2001 From: yexo Date: Thu, 19 Aug 2010 13:44:41 +0000 Subject: (svn r20559) -Fix [FS#4045]: make sure that all vehicles are build in the most northern depot/hangar tile --- src/aircraft_cmd.cpp | 6 +++++- src/ship_cmd.cpp | 1 + src/vehicle_cmd.cpp | 2 +- src/water_cmd.cpp | 5 +---- src/water_map.h | 13 +++++++++++++ 5 files changed, 21 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index ecba1df29..511df3aeb 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -225,9 +225,13 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height) CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **ret) { const AircraftVehicleInfo *avi = &e->u.air; + const Station *st = Station::GetByTile(tile); /* Prevent building aircraft types at places which can't handle them */ - if (!CanVehicleUseStation(e->index, Station::GetByTile(tile))) return CMD_ERROR; + if (!CanVehicleUseStation(e->index, st)) return CMD_ERROR; + + /* Make sure all aircraft end up in the first tile of the hanger. */ + tile = st->airport.GetHangarTile(st->airport.GetHangarNum(tile)); if (flags & DC_EXEC) { Aircraft *v = new Aircraft(); // aircraft diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index f2becb60f..4475a8e05 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -613,6 +613,7 @@ bool Ship::Tick() */ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **ret) { + tile = GetShipDepotNorthTile(tile); if (flags & DC_EXEC) { int x; int y; diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 45b6e3674..e5b5df6cd 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -137,7 +137,7 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint v->unitnumber = unit_num; v->value = value.GetCost(); - InvalidateWindowData(WC_VEHICLE_DEPOT, tile); + InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); InvalidateWindowClassesData(GetWindowClassForVehicleType(type), 0); SetWindowDirty(WC_COMPANY, _current_company); if (IsLocalCompany()) { diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 3c0e6ee2f..78d190d69 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -172,7 +172,6 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags) } if (flags & DC_EXEC) { - /* Kill the depot, which is registered at the northernmost tile. Use that one */ delete Depot::GetByTile(tile); MakeWaterKeepingClass(tile, GetTileOwner(tile)); @@ -1180,9 +1179,7 @@ static TrackStatus GetTileTrackStatus_Water(TileIndex tile, TransportType mode, static bool ClickTile_Water(TileIndex tile) { if (GetWaterTileType(tile) == WATER_TILE_DEPOT) { - TileIndex tile2 = GetOtherShipDepotTile(tile); - - ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP); + ShowDepotWindow(GetShipDepotNorthTile(tile), VEH_SHIP); return true; } return false; diff --git a/src/water_map.h b/src/water_map.h index 55e2730a5..83c3a055f 100644 --- a/src/water_map.h +++ b/src/water_map.h @@ -197,6 +197,19 @@ static inline DiagDirection GetShipDepotDirection(TileIndex t) return XYNSToDiagDir(GetShipDepotAxis(t), GB(_m[t].m5, 0, 1)); } +/** + * Get the most northern tile of a ship depot. + * @param tile One of the tiles of the ship depot. + * @return The northern tile of the depot. + */ +static TileIndex GetShipDepotNorthTile(TileIndex t) +{ + assert(IsShipDepot(t)); + TileIndex tile2 = GetOtherShipDepotTile(t); + + return t < tile2 ? t : tile2; +} + /** * Is it a water lock tile? * @param t Water tile to query. -- cgit v1.2.3-70-g09d2