diff options
author | michi_cc <michi_cc@openttd.org> | 2012-04-17 19:43:18 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2012-04-17 19:43:18 +0000 |
commit | aa47d6c7f2b18d5277ed8d1e47f078e6d73bc6b9 (patch) | |
tree | c9dfb4e1826ddbef58cc31872029e49d18c9d9bd /src/station_cmd.cpp | |
parent | af6a33bd1c191f1fcb60f85d8c2c38eca6db4cc5 (diff) | |
download | openttd-aa47d6c7f2b18d5277ed8d1e47f078e6d73bc6b9.tar.xz |
(svn r24127) -Feature [FS#1497]: Allow closing airports for incoming aircraft. (Based on patch by cirdan)
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 64b83e8e2..c0774556f 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2263,7 +2263,7 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint st->RecomputeIndustriesNear(); InvalidateWindowData(WC_SELECT_STATION, 0, 0); InvalidateWindowData(WC_STATION_LIST, st->owner, 0); - SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_PLANES); + InvalidateWindowData(WC_STATION_VIEW, st->index); if (_settings_game.economy.station_noise_level) { SetWindowDirty(WC_TOWN_VIEW, st->town->index); @@ -2339,7 +2339,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags) st->airport.Clear(); st->facilities &= ~FACIL_AIRPORT; - SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_PLANES); + InvalidateWindowData(WC_STATION_VIEW, st->index); if (_settings_game.economy.station_noise_level) { SetWindowDirty(WC_TOWN_VIEW, st->town->index); @@ -2358,6 +2358,32 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags) } /** + * Open/close an airport to incoming aircraft. + * @param tile Unused. + * @param flags Operation to perform. + * @param p1 Station ID of the airport. + * @param p2 Unused. + * @param text unused + * @return the cost of this operation or an error + */ +CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +{ + if (!Station::IsValidID(p1)) return CMD_ERROR; + Station *st = Station::Get(p1); + + if (!(st->facilities & FACIL_AIRPORT)) return CMD_ERROR; + + CommandCost ret = CheckOwnership(st->owner); + if (ret.Failed()) return ret; + + if (flags & DC_EXEC) { + st->airport.flags ^= AIRPORT_CLOSED_block; + SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_CLOSE_AIRPORT); + } + return CommandCost(); +} + +/** * Tests whether the company's vehicles have this station in orders * @param station station ID * @param include_company If true only check vehicles of \a company, if false only check vehicles of other companies |