Index: src/airport.h =================================================================== --- src/airport.h 2008-05-24 04:54:47.000000000 +0200 +++ src/airport.h 2008-05-25 17:48:47.000000000 +0200 @@ -113,7 +113,9 @@ OUT_WAY_block2 = 1ULL << 31, /* end of new blocks */ - NOTHING_block = 1ULL << 30; + NOTHING_block = 1ULL << 30, + + AIRPORT_CLOSED_block = 1ULL << 32; struct AirportMovingData { int16 x; Index: src/aircraft_cmd.cpp =================================================================== --- src/aircraft_cmd.cpp 2008-05-29 17:13:28.000000000 +0200 +++ src/aircraft_cmd.cpp 2008-06-03 21:00:16.000000000 +0200 @@ -1664,6 +1664,7 @@ /* runway busy or not allowed to use this airstation, circle */ if (apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES) && + !HASBITS(st->airport_flags, AIRPORT_CLOSED_block) && st->airport_tile != 0 && (st->owner == OWNER_NONE || st->owner == v->owner)) { // {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41}, Index: src/command_type.h =================================================================== --- src/command_type.h 2008-05-26 02:31:36.000000000 +0200 +++ src/command_type.h 2008-06-03 21:00:16.000000000 +0200 @@ -288,6 +288,8 @@ CMD_CHANGE_TIMETABLE, ///< change the timetable for a vehicle CMD_SET_VEHICLE_ON_TIME, ///< set the vehicle on time feature (timetable) CMD_AUTOFILL_TIMETABLE, ///< autofill the timetable + + CMD_OPEN_CLOSE_AIRPORT, ///< open/close an airport }; /** Index: src/command.cpp =================================================================== --- src/command.cpp 2008-05-26 02:31:36.000000000 +0200 +++ src/command.cpp 2008-06-03 21:00:16.000000000 +0200 @@ -195,6 +195,8 @@ DEF_COMMAND(CmdChangeTimetable); DEF_COMMAND(CmdSetVehicleOnTime); DEF_COMMAND(CmdAutofillTimetable); + +DEF_COMMAND(CmdOpenCloseAirport); #undef DEF_COMMAND /** @@ -341,6 +343,8 @@ {CmdChangeTimetable, 0}, /* CMD_CHANGE_TIMETABLE */ {CmdSetVehicleOnTime, 0}, /* CMD_SET_VEHICLE_ON_TIME */ {CmdAutofillTimetable, 0}, /* CMD_AUTOFILL_TIMETABLE */ + + {CmdOpenCloseAirport, 0}, /* CMD_OPEN_CLOSE_AIRPORT */ }; /*! Index: src/station_gui.h =================================================================== --- src/station_gui.h 2008-05-18 18:51:44.000000000 +0200 +++ src/station_gui.h 2008-05-25 17:56:02.000000000 +0200 @@ -46,6 +46,7 @@ SVW_PLANES, ///< List of scheduled planes button SVW_SHIPS, ///< List of scheduled ships button SVW_RESIZE, ///< Resize button + SVW_CLOSEAIRPORT, ///< Close airport button }; enum StationCoverageType { Index: src/station_cmd.cpp =================================================================== --- src/station_cmd.cpp 2008-05-29 17:13:28.000000000 +0200 +++ src/station_cmd.cpp 2008-06-03 21:00:16.000000000 +0200 @@ -1878,6 +1878,7 @@ UpdateStationAcceptance(st, false); InvalidateWindowData(WC_STATION_LIST, st->owner, 0); InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES); + InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_CLOSEAIRPORT); if (_settings_game.economy.station_noise_level) { InvalidateWindow(WC_TOWN_VIEW, st->town->index); @@ -1933,8 +1934,10 @@ st->airport_tile = 0; st->facilities &= ~FACIL_AIRPORT; + st->airport_flags = 0; InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES); + InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_CLOSEAIRPORT); if (_settings_game.economy.station_noise_level) { InvalidateWindow(WC_TOWN_VIEW, st->town->index); @@ -1947,6 +1950,32 @@ return cost; } +/** Open/close an airport. + * @param tile unused + * @param flags type of operation + * @param p1 station ID of the airport + * @param p2 new status (0 open, 1 closed) + */ +CommandCost CmdOpenCloseAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) +{ + if (!IsValidStationID(p1)) return CMD_ERROR; + Station *st = GetStation(p1); + + if (!(st->facilities & FACIL_AIRPORT)) return CMD_ERROR; + if (!CheckOwnership(st->owner)) return CMD_ERROR; + + if (flags & DC_EXEC) { + if (p2) { + SETBITS(st->airport_flags, AIRPORT_CLOSED_block); + } else { + CLRBITS(st->airport_flags, AIRPORT_CLOSED_block); + } + InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_CLOSEAIRPORT); + } + + return CommandCost(); +} + /** Build a buoy. * @param tile tile where to place the bouy * @param flags operation to perform Index: src/station_gui.cpp =================================================================== --- src/station_gui.cpp 2008-05-28 00:02:26.000000000 +0200 +++ src/station_gui.cpp 2008-06-03 21:00:16.000000000 +0200 @@ -615,14 +615,15 @@ { WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 236, 14, 65, 0x0, STR_NULL}, // SVW_WAITING { WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_PANEL, RESIZE_RTB, COLOUR_GREY, 0, 248, 66, 97, 0x0, STR_NULL}, // SVW_ACCEPTLIST / SVW_RATINGLIST -{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 0, 59, 98, 109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION -{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 60, 120, 98, 109, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS}, // SVW_RATINGS / SVW_ACCEPTS -{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_GREY, 121, 180, 98, 109, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, // SVW_RENAME -{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 181, 194, 98, 109, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, // SVW_TRAINS -{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 195, 208, 98, 109, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, // SVW_ROADVEHS -{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 209, 222, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, // SVW_PLANES -{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 223, 236, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, // SVW_SHIPS -{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 237, 248, 98, 109, 0x0, STR_RESIZE_BUTTON}, +{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 0, 59, 110, 121, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION +{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 60, 120, 110, 121, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS}, // SVW_RATINGS / SVW_ACCEPTS +{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_GREY, 121, 180, 110, 121, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, // SVW_RENAME +{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 181, 194, 110, 121, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, // SVW_TRAINS +{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 195, 208, 110, 121, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, // SVW_ROADVEHS +{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 209, 222, 110, 121, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, // SVW_PLANES +{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 223, 236, 110, 121, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, // SVW_SHIPS +{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 237, 248, 110, 121, 0x0, STR_RESIZE_BUTTON}, +{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_GREY, 0, 248, 98, 109, STR_CLOSE_AIRPORT, STR_CLOSE_AIRPORT_TIP}, // SVW_CLOSEAIRPORT { WIDGETS_END}, }; @@ -760,6 +761,13 @@ this->SetWidgetDisabledState(SVW_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP)); this->SetWidgetDisabledState(SVW_PLANES, !(st->facilities & FACIL_AIRPORT)); this->SetWidgetDisabledState(SVW_SHIPS, !(st->facilities & FACIL_DOCK)); + if (st->facilities & FACIL_AIRPORT) { + this->SetWidgetDisabledState(SVW_CLOSEAIRPORT, st->owner != _local_company); + this->SetWidgetLoweredState(SVW_CLOSEAIRPORT, HASBITS(st->airport_flags, AIRPORT_CLOSED_block)); + } else { + this->DisableWidget(SVW_CLOSEAIRPORT); + this->RaiseWidget(SVW_CLOSEAIRPORT); + } SetDParam(0, st->index); SetDParam(1, st->facilities); @@ -942,6 +950,12 @@ ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number); break; } + + case SVW_CLOSEAIRPORT: { // Open/close airport + const Station *st = GetStation(this->window_number); + DoCommandP(0, st->index, HASBITS(st->airport_flags, AIRPORT_CLOSED_block) ? 0 : 1, NULL, CMD_OPEN_CLOSE_AIRPORT | CMD_MSG(STR_CLOSE_AIRPORT_ERROR)); + break; + } } } @@ -962,7 +976,7 @@ static const WindowDesc _station_view_desc = { - WDP_AUTO, WDP_AUTO, 249, 110, 249, 110, + WDP_AUTO, WDP_AUTO, 249, 122, 249, 122, WC_STATION_VIEW, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, _station_view_widgets, Index: src/lang/english.txt =================================================================== --- src/lang/english.txt 2008-05-28 18:45:00.000000000 +0200 +++ src/lang/english.txt 2008-06-03 21:00:16.000000000 +0200 @@ -3294,6 +3294,10 @@ STR_SCHEDULED_AIRCRAFT_TIP :{BLACK}Show all aircraft which have this station on their schedule STR_SCHEDULED_SHIPS_TIP :{BLACK}Show all ships which have this station on their schedule +STR_CLOSE_AIRPORT :{BLACK}Close airport +STR_CLOSE_AIRPORT_TIP :{BLACK}Prevent aircraft from landing on this airport +STR_CLOSE_AIRPORT_ERROR :{WHITE}Cannot open/close airport... + STR_VEH_WITH_SHARED_ORDERS_LIST :{WHITE}Shared orders of {COMMA} Vehicle{P "" s} STR_VEH_WITH_SHARED_ORDERS_LIST_TIP :{BLACK}Show all vehicles that share this schedule