diff options
author | yexo <yexo@openttd.org> | 2010-08-19 13:44:41 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-08-19 13:44:41 +0000 |
commit | 85740a02832c9c474833f929b4464eba06be66d3 (patch) | |
tree | 9e10d3039ec55bce24ceebffd0c4c949be1f45ee /src | |
parent | 16be24e13acf17a3292b490196d301b5b1aa1056 (diff) | |
download | openttd-85740a02832c9c474833f929b4464eba06be66d3.tar.xz |
(svn r20559) -Fix [FS#4045]: make sure that all vehicles are build in the most northern depot/hangar tile
Diffstat (limited to 'src')
-rw-r--r-- | src/aircraft_cmd.cpp | 6 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 1 | ||||
-rw-r--r-- | src/vehicle_cmd.cpp | 2 | ||||
-rw-r--r-- | src/water_cmd.cpp | 5 | ||||
-rw-r--r-- | src/water_map.h | 13 |
5 files changed, 21 insertions, 6 deletions
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 @@ -198,6 +198,19 @@ static inline DiagDirection GetShipDepotDirection(TileIndex t) } /** + * 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. * @return \c true if it is a water lock tile. |