Changeset - r15689:f98f51eeeb0c
[Not reviewed]
master
0 6 0
yexo - 14 years ago 2010-08-05 11:59:07
yexo@openttd.org
(svn r20365) -Codechange: allow multiple layouts for one airport statemachine, store the layout number
6 files changed with 44 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/airport_gui.cpp
Show inline comments
 
@@ -12,67 +12,69 @@
 
#include "stdafx.h"
 
#include "window_gui.h"
 
#include "station_gui.h"
 
#include "terraform_gui.h"
 
#include "airport.h"
 
#include "sound_func.h"
 
#include "window_func.h"
 
#include "strings_func.h"
 
#include "viewport_func.h"
 
#include "gfx_func.h"
 
#include "company_func.h"
 
#include "tilehighlight_func.h"
 
#include "company_base.h"
 
#include "station_type.h"
 
#include "newgrf_airport.h"
 
#include "widgets/dropdown_type.h"
 
#include "core/geometry_func.hpp"
 
#include "hotkeys.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
static AirportClassID _selected_airport_class; ///< the currently visible airport class
 
static int _selected_airport_index;            ///< the index of the selected airport in the current class or -1
 
static byte _selected_airport_layout;          ///< selected airport layout number.
 

	
 
static void ShowBuildAirportPicker(Window *parent);
 

	
 

	
 
void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (result.Failed()) return;
 

	
 
	SndPlayTileFx(SND_1F_SPLAT, tile);
 
	if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
 
}
 

	
 
static void PlaceAirport(TileIndex tile)
 
{
 
	if (_selected_airport_index == -1) return;
 
	uint32 p2 = _ctrl_pressed;
 
	SB(p2, 16, 16, INVALID_STATION); // no station to join
 

	
 
	uint32 p1 = GetAirportSpecFromClass(_selected_airport_class, _selected_airport_index)->GetIndex();
 
	p1 |= _selected_airport_layout << 8;
 
	CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_AIRPORT | CMD_MSG(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport, "" };
 
	ShowSelectStationIfNeeded(cmdcont, TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE));
 
}
 

	
 
/** Widget number of the airport build window. */
 
enum AirportToolbarWidgets {
 
	ATW_AIRPORT,
 
	ATW_DEMOLISH,
 
};
 

	
 

	
 
static void BuildAirClick_Airport(Window *w)
 
{
 
	if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT, PlaceAirport)) ShowBuildAirportPicker(w);
 
}
 

	
 
static void BuildAirClick_Demolish(Window *w)
 
{
 
	HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT, PlaceProc_DemolishArea);
 
}
 

	
 

	
 
typedef void OnButtonClick(Window *w);
 
static OnButtonClick * const _build_air_button_proc[] = {
 
@@ -176,94 +178,106 @@ static const WindowDesc _air_toolbar_des
 
 * @return newly opened airport toolbar, or NULL if the toolbar could not be opened.
 
 */
 
Window *ShowBuildAirToolbar()
 
{
 
	if (!Company::IsValidID(_local_company)) return NULL;
 

	
 
	DeleteWindowByClass(WC_BUILD_TOOLBAR);
 
	return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
 
}
 

	
 
EventState AirportToolbarGlobalHotkeys(uint16 key, uint16 keycode)
 
{
 
	int num = CheckHotkeyMatch<BuildAirToolbarWindow>(_airtoolbar_hotkeys, keycode, NULL, true);
 
	if (num == -1) return ES_NOT_HANDLED;
 
	Window *w = ShowBuildAirToolbar();
 
	if (w == NULL) return ES_NOT_HANDLED;
 
	return w->OnKeyPress(key, keycode);
 
}
 

	
 
/** Airport widgets in the airport picker window. */
 
enum AirportPickerWidgets {
 
	BAIRW_CLASS_DROPDOWN,
 
	BAIRW_AIRPORT_LIST,
 
	BAIRW_SCROLLBAR,
 
	BAIRW_LAYOUT_NUM,
 
	BAIRW_LAYOUT_DECREASE,
 
	BAIRW_LAYOUT_INCREASE,
 
	BAIRW_BOTTOMPANEL,
 
	BAIRW_COVERAGE_LABEL,
 
	BAIRW_BTN_DONTHILIGHT,
 
	BAIRW_BTN_DOHILIGHT,
 
};
 

	
 
class BuildAirportWindow : public PickerWindowBase {
 
	int line_height;
 

	
 
	/** Build a dropdown list of available airport classes */
 
	static DropDownList *BuildAirportClassDropDown()
 
	{
 
		DropDownList *list = new DropDownList();
 

	
 
		for (uint i = 0; i < GetNumAirportClasses(); i++) {
 
			list->push_back(new DropDownListStringItem(GetAirportClassName((AirportClassID)i), i, false));
 
		}
 

	
 
		return list;
 
	}
 

	
 
public:
 
	BuildAirportWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
 
	{
 
		this->vscroll.SetCapacity(5);
 
		this->vscroll.SetPosition(0);
 
		this->InitNested(desc, TRANSPORT_AIR);
 

	
 
		this->SetWidgetLoweredState(BAIRW_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
 
		this->SetWidgetLoweredState(BAIRW_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
 
		this->OnInvalidateData();
 

	
 
		this->vscroll.SetCount(GetNumAirportsInClass(_selected_airport_class));
 
		this->SelectFirstAvailableAirport(true);
 
	}
 

	
 
	virtual ~BuildAirportWindow()
 
	{
 
		DeleteWindowById(WC_SELECT_STATION, 0);
 
	}
 

	
 
	virtual void SetStringParameters(int widget) const
 
	{
 
		if (widget != BAIRW_CLASS_DROPDOWN) return;
 
		switch (widget) {
 
			case BAIRW_CLASS_DROPDOWN:
 
				SetDParam(0, GetAirportClassName(_selected_airport_class));
 
				break;
 

	
 
		SetDParam(0, GetAirportClassName(_selected_airport_class));
 
			case BAIRW_LAYOUT_NUM:
 
				SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME);
 
				SetDParam(1, _selected_airport_layout + 1);
 
				break;
 

	
 
			default: break;
 
		}
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		switch (widget) {
 
			case BAIRW_CLASS_DROPDOWN: {
 
				Dimension d = {0, 0};
 
				for (uint i = 0; i < GetNumAirportClasses(); i++) {
 
					SetDParam(0, GetAirportClassName((AirportClassID)i));
 
					d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
 
				}
 
				d.width += padding.width;
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 

	
 
			case BAIRW_AIRPORT_LIST: {
 
				for (int i = 0; i < NUM_AIRPORTS; i++) {
 
					const AirportSpec *as = AirportSpec::Get(i);
 
					if (!as->enabled) continue;
 

	
 
					size->width = max(size->width, GetStringBoundingBox(as->name).width);
 
				}
 
@@ -307,89 +321,107 @@ public:
 
			int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
 

	
 
			/* only show the station (airport) noise, if the noise option is activated */
 
			if (_settings_game.economy.station_noise_level) {
 
				/* show the noise of the selected airport */
 
				SetDParam(0, as->noise_level);
 
				DrawString(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_STATION_BUILD_NOISE);
 
				top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
			}
 

	
 
			/* strings such as 'Size' and 'Coverage Area' */
 
			top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
 
			top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
 
		}
 

	
 
		/* Resize background if the text is not equally long as the window. */
 
		if (top > bottom || (top < bottom && panel_nwi->current_y > panel_nwi->smallest_y)) {
 
			ResizeWindow(this, 0, top - bottom);
 
		}
 
	}
 

	
 
	void SelectOtherAirport(int airport_index)
 
	{
 
		_selected_airport_index = airport_index;
 
		_selected_airport_layout = 0;
 

	
 
		this->UpdateSelectSize();
 
		this->SetDirty();
 
	}
 

	
 
	void UpdateSelectSize()
 
	{
 
		if (_selected_airport_index == -1) {
 
			SetTileSelectSize(1, 1);
 
			this->DisableWidget(BAIRW_LAYOUT_DECREASE);
 
			this->DisableWidget(BAIRW_LAYOUT_INCREASE);
 
		} else {
 
			const AirportSpec *as = GetAirportSpecFromClass(_selected_airport_class, _selected_airport_index);
 
			SetTileSelectSize(as->size_x, as->size_y);
 

	
 
			this->SetWidgetDisabledState(BAIRW_LAYOUT_DECREASE, _selected_airport_layout == 0);
 
			this->SetWidgetDisabledState(BAIRW_LAYOUT_INCREASE, _selected_airport_layout + 1 >= as->num_table);
 

	
 
			int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
 
			if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 
		}
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case BAIRW_CLASS_DROPDOWN:
 
				ShowDropDownList(this, BuildAirportClassDropDown(), _selected_airport_class, BAIRW_CLASS_DROPDOWN);
 
				break;
 

	
 
			case BAIRW_AIRPORT_LIST: {
 
				int num_clicked = this->vscroll.GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height;
 
				if (num_clicked >= this->vscroll.GetCount()) break;
 
				const AirportSpec *as = GetAirportSpecFromClass(_selected_airport_class, num_clicked);
 
				if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);
 
				break;
 
			}
 

	
 
			case BAIRW_BTN_DONTHILIGHT: case BAIRW_BTN_DOHILIGHT:
 
				_settings_client.gui.station_show_coverage = (widget != BAIRW_BTN_DONTHILIGHT);
 
				this->SetWidgetLoweredState(BAIRW_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
 
				this->SetWidgetLoweredState(BAIRW_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
 
				this->SetDirty();
 
				SndPlayFx(SND_15_BEEP);
 
				this->UpdateSelectSize();
 
				break;
 

	
 
			case BAIRW_LAYOUT_DECREASE:
 
				_selected_airport_layout--;
 
				this->UpdateSelectSize();
 
				this->SetDirty();
 
				break;
 

	
 
			case BAIRW_LAYOUT_INCREASE:
 
				_selected_airport_layout++;
 
				this->UpdateSelectSize();
 
				this->SetDirty();
 
				break;
 
		}
 
	}
 

	
 
	/**
 
	 * Select the first available airport.
 
	 * @param change_class If true, change the class if no airport in the current
 
	 *   class is available.
 
	 */
 
	void SelectFirstAvailableAirport(bool change_class)
 
	{
 
		/* First try to select an airport in the selected class. */
 
		for (uint i = 0; i < GetNumAirportsInClass(_selected_airport_class); i++) {
 
			const AirportSpec *as = GetAirportSpecFromClass(_selected_airport_class, i);
 
			if (as->IsAvailable()) {
 
				this->SelectOtherAirport(i);
 
				return;
 
			}
 
		}
 
		if (change_class) {
 
			/* If that fails, select the first available airport
 
			 * from a random class. */
 
			for (AirportClassID j = APC_BEGIN; j < APC_MAX; j++) {
 
				for (uint i = 0; i < GetNumAirportsInClass(j); i++) {
 
					const AirportSpec *as = GetAirportSpecFromClass(j, i);
 
@@ -410,48 +442,53 @@ public:
 
		assert(widget == BAIRW_CLASS_DROPDOWN);
 
		_selected_airport_class = (AirportClassID)index;
 
		this->vscroll.SetCount(GetNumAirportsInClass(_selected_airport_class));
 
		this->SelectFirstAvailableAirport(false);
 
	}
 

	
 
	virtual void OnTick()
 
	{
 
		CheckRedrawStationCoverage(this);
 
	}
 
};
 

	
 
static const NWidgetPart _nested_build_airport_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
 
		NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(1, 0), SetPIP(2, 0, 2),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CLASS_LABEL, STR_NULL), SetFill(1, 0),
 
		NWidget(WWT_DROPDOWN, COLOUR_GREY, BAIRW_CLASS_DROPDOWN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NULL),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_MATRIX, COLOUR_GREY, BAIRW_AIRPORT_LIST), SetFill(1, 0), SetDataTip(0x501, STR_NULL),
 
			NWidget(WWT_SCROLLBAR, COLOUR_GREY, BAIRW_SCROLLBAR),
 
		EndContainer(),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, BAIRW_LAYOUT_DECREASE), SetMinimalSize(12, 0),SetDataTip(AWV_DECREASE, STR_NULL),
 
			NWidget(WWT_LABEL, COLOUR_GREY, BAIRW_LAYOUT_NUM), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NULL),
 
			NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, BAIRW_LAYOUT_INCREASE), SetMinimalSize(12, 0), SetDataTip(AWV_INCREASE, STR_NULL),
 
		EndContainer(),
 
	EndContainer(),
 
	/* Bottom panel. */
 
	NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BAIRW_BOTTOMPANEL), SetPIP(2, 2, 2),
 
		NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, BAIRW_BTN_DONTHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
 
											SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, BAIRW_BTN_DOHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
 
											SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
 
			EndContainer(),
 
			NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1), SetFill(1, 0),
 
	EndContainer(),
 
};
 

	
 
static const WindowDesc _build_airport_desc(
 
	WDP_AUTO, 0, 0,
 
	WC_BUILD_STATION, WC_BUILD_TOOLBAR,
 
	WDF_CONSTRUCTION,
 
	_nested_build_airport_widgets, lengthof(_nested_build_airport_widgets)
 
);
src/lang/english.txt
Show inline comments
 
@@ -2004,48 +2004,49 @@ STR_WATERWAYS_TOOLBAR_CAPTION_SE        
 
STR_WATERWAYS_TOOLBAR_BUILD_CANALS_TOOLTIP                      :{BLACK}Build canals.
 
STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP                       :{BLACK}Build locks
 
STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP                       :{BLACK}Build ship depot (for buying and servicing ships)
 
STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP                        :{BLACK}Build ship dock. Ctrl enables joining stations
 
STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP                              :{BLACK}Place a buoy which can be used as a waypoint
 
STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP                    :{BLACK}Build aqueduct
 
STR_WATERWAYS_TOOLBAR_CREATE_LAKE_TOOLTIP                       :{BLACK}Define water area.{}Make a canal, unless Ctrl is held down at sea level, when it will flood the surroundings instead
 
STR_WATERWAYS_TOOLBAR_CREATE_RIVER_TOOLTIP                      :{BLACK}Place rivers.
 

	
 
# Ship depot construction window
 
STR_DEPOT_BUILD_SHIP_CAPTION                                    :{WHITE}Ship Depot Orientation
 
STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP                        :{BLACK}Select ship depot orientation
 

	
 
# Dock construction window
 
STR_STATION_BUILD_DOCK_CAPTION                                  :{WHITE}Dock
 

	
 
# Airport toolbar
 
STR_TOOLBAR_AIRCRAFT_CAPTION                                    :{WHITE}Airports
 
STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP                      :{BLACK}Build airport. Ctrl enables joining stations
 

	
 
# Airport construction window
 
STR_STATION_BUILD_AIRPORT_CAPTION                               :{WHITE}Airport Selection
 
STR_STATION_BUILD_AIRPORT_TOOLTIP                               :{BLACK}Select size/type of airport
 
STR_STATION_BUILD_AIRPORT_CLASS_LABEL                           :{BLACK}Airport class
 
STR_STATION_BUILD_AIRPORT_LAYOUT_NAME                           :{BLACK}Layout {NUM}
 

	
 
STR_AIRPORT_SMALL                                               :Small
 
STR_AIRPORT_CITY                                                :City
 
STR_AIRPORT_METRO                                               :Metropolitan
 
STR_AIRPORT_INTERNATIONAL                                       :International
 
STR_AIRPORT_COMMUTER                                            :Commuter
 
STR_AIRPORT_INTERCONTINENTAL                                    :Intercontinental
 
STR_AIRPORT_HELIPORT                                            :Heliport
 
STR_AIRPORT_HELIDEPOT                                           :Helidepot
 
STR_AIRPORT_HELISTATION                                         :Helistation
 

	
 
STR_AIRPORT_CLASS_SMALL                                         :Small airports
 
STR_AIRPORT_CLASS_LARGE                                         :Large airports
 
STR_AIRPORT_CLASS_HUB                                           :Hub airports
 
STR_AIRPORT_CLASS_HELIPORTS                                     :Helicopter airports
 

	
 
STR_STATION_BUILD_NOISE                                         :{BLACK}Noise generated: {GOLD}{COMMA}
 

	
 
# Landscaping toolbar
 
STR_LANDSCAPING_TOOLBAR                                         :{WHITE}Landscaping
 
STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND                  :{BLACK}Lower a corner of land
 
STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND                  :{BLACK}Raise a corner of land
 
STR_LANDSCAPING_LEVEL_LAND_TOOLTIP                              :{BLACK}Level land
 
STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND                           :{BLACK}Purchase land for future use
src/newgrf_airport.cpp
Show inline comments
 
@@ -305,34 +305,34 @@ static void NewAirportResolver(ResolverO
 
	res->ResolveReal   = AirportResolveReal;
 

	
 
	res->psa                  = NULL;
 
	res->u.airport.st         = st;
 
	res->u.airport.airport_id = airport_id;
 
	res->u.airport.layout     = layout;
 
	res->u.airport.tile       = tile;
 

	
 
	res->callback        = CBID_NO_CALLBACK;
 
	res->callback_param1 = 0;
 
	res->callback_param2 = 0;
 
	res->last_value      = 0;
 
	res->trigger         = 0;
 
	res->reseed          = 0;
 
	res->count           = 0;
 

	
 
	const AirportSpec *as = AirportSpec::Get(airport_id);
 
	res->grffile = (as != NULL ? as->grf_prop.grffile : NULL);
 
}
 

	
 
uint16 GetAirportCallback(CallbackID callback, uint32 param1, uint32 param2, Station *st, TileIndex tile)
 
{
 
	ResolverObject object;
 

	
 
	NewAirportResolver(&object, tile, st, st->airport.type, 0);
 
	NewAirportResolver(&object, tile, st, st->airport.type, st->airport.layout);
 
	object.callback = callback;
 
	object.callback_param1 = param1;
 
	object.callback_param2 = param2;
 

	
 
	const SpriteGroup *group = SpriteGroup::Resolve(st->airport.GetSpec()->grf_prop.spritegroup, &object);
 
	if (group == NULL) return CALLBACK_FAILED;
 

	
 
	return group->GetCallbackResult();
 
}
src/saveload/station_sl.cpp
Show inline comments
 
@@ -314,48 +314,49 @@ static const SaveLoad _base_station_desc
 

	
 
	/* Used by newstations for graphic variations */
 
	      SLE_VAR(BaseStation, random_bits,            SLE_UINT16),
 
	      SLE_VAR(BaseStation, waiting_triggers,       SLE_UINT8),
 
	      SLE_VAR(BaseStation, num_specs,              SLE_UINT8),
 

	
 
	      SLE_END()
 
};
 

	
 
static const SaveLoad _station_desc[] = {
 
	SLE_WRITEBYTE(Station, facilities,                 FACIL_NONE),
 
	SLE_ST_INCLUDE(),
 

	
 
	      SLE_VAR(Station, train_station.tile,         SLE_UINT32),
 
	      SLE_VAR(Station, train_station.w,            SLE_FILE_U8 | SLE_VAR_U16),
 
	      SLE_VAR(Station, train_station.h,            SLE_FILE_U8 | SLE_VAR_U16),
 

	
 
	      SLE_REF(Station, bus_stops,                  REF_ROADSTOPS),
 
	      SLE_REF(Station, truck_stops,                REF_ROADSTOPS),
 
	      SLE_VAR(Station, dock_tile,                  SLE_UINT32),
 
	      SLE_VAR(Station, airport.tile,               SLE_UINT32),
 
	  SLE_CONDVAR(Station, airport.w,                  SLE_FILE_U8 | SLE_VAR_U16, 140, SL_MAX_VERSION),
 
	  SLE_CONDVAR(Station, airport.h,                  SLE_FILE_U8 | SLE_VAR_U16, 140, SL_MAX_VERSION),
 
	      SLE_VAR(Station, airport.type,               SLE_UINT8),
 
	  SLE_CONDVAR(Station, airport.layout,             SLE_UINT8,                 145, SL_MAX_VERSION),
 
	      SLE_VAR(Station, airport.flags,              SLE_UINT64),
 

	
 
	      SLE_VAR(Station, indtype,                    SLE_UINT8),
 

	
 
	      SLE_VAR(Station, time_since_load,            SLE_UINT8),
 
	      SLE_VAR(Station, time_since_unload,          SLE_UINT8),
 
	      SLE_VAR(Station, last_vehicle_type,          SLE_UINT8),
 
	      SLE_VAR(Station, had_vehicle_of_type,        SLE_UINT8),
 
	      SLE_LST(Station, loading_vehicles,           REF_VEHICLE),
 
	  SLE_CONDVAR(Station, always_accepted,            SLE_UINT32, 127, SL_MAX_VERSION),
 

	
 
	      SLE_END()
 
};
 

	
 
static const SaveLoad _waypoint_desc[] = {
 
	SLE_WRITEBYTE(Waypoint, facilities,                FACIL_WAYPOINT),
 
	SLE_ST_INCLUDE(),
 

	
 
	      SLE_VAR(Waypoint, town_cn,                   SLE_UINT16),
 

	
 
	  SLE_CONDVAR(Waypoint, train_station.tile,        SLE_UINT32,                  124, SL_MAX_VERSION),
 
	  SLE_CONDVAR(Waypoint, train_station.w,           SLE_FILE_U8 | SLE_VAR_U16,   124, SL_MAX_VERSION),
 
	  SLE_CONDVAR(Waypoint, train_station.h,           SLE_FILE_U8 | SLE_VAR_U16,   124, SL_MAX_VERSION),
 

	
src/station_base.h
Show inline comments
 
@@ -30,48 +30,49 @@ struct GoodsEntry {
 
	};
 

	
 
	GoodsEntry() :
 
		acceptance_pickup(0),
 
		days_since_pickup(255),
 
		rating(INITIAL_STATION_RATING),
 
		last_speed(0),
 
		last_age(255)
 
	{}
 

	
 
	byte acceptance_pickup;
 
	byte days_since_pickup;
 
	byte rating;
 
	byte last_speed;
 
	byte last_age;
 
	StationCargoList cargo; ///< The cargo packets of cargo waiting in this station
 
};
 

	
 
/** All airport-related information. Only valid if tile != INVALID_TILE. */
 
struct Airport : public TileArea {
 
	Airport() : TileArea(INVALID_TILE, 0, 0) {}
 

	
 
	uint64 flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
 
	byte type;    ///< Type of this airport, @see AirportTypes.
 
	byte layout;  ///< Airport layout number.
 

	
 
	/**
 
	 * Get the AirportSpec that from the airport type of this airport. If there
 
	 * is no airport (\c tile == INVALID_TILE) then return the dummy AirportSpec.
 
	 * @return The AirportSpec for this airport.
 
	 */
 
	const AirportSpec *GetSpec() const
 
	{
 
		if (this->tile == INVALID_TILE) return &AirportSpec::dummy;
 
		return AirportSpec::Get(this->type);
 
	}
 

	
 
	/**
 
	 * Get the finite-state machine for this airport or the finite-state machine
 
	 * for the dummy airport in case this isn't an airport.
 
	 * @pre this->type < NEW_AIRPORT_OFFSET.
 
	 * @return The state machine for this airport.
 
	 */
 
	const AirportFTAClass *GetFTA() const
 
	{
 
		return this->GetSpec()->fsm;
 
	}
 

	
 
	/** Check if this airport has at least one hangar. */
src/station_cmd.cpp
Show inline comments
 
@@ -2193,48 +2193,49 @@ CommandCost CmdBuildAirport(TileIndex ti
 

	
 
		if (flags & DC_EXEC) {
 
			st = new Station(tile);
 

	
 
			st->town = t;
 
			st->string_id = GenerateStationName(st, tile, !(GetAirport(airport_type)->flags & AirportFTAClass::AIRPLANES) ? STATIONNAMING_HELIPORT : STATIONNAMING_AIRPORT);
 

	
 
			if (Company::IsValidID(_current_company)) {
 
				SetBit(st->town->have_ratings, _current_company);
 
			}
 
		}
 
	}
 

	
 
	const AirportTileTable *it = as->table[layout];
 
	do {
 
		cost.AddCost(_price[PR_BUILD_STATION_AIRPORT]);
 
	} while ((++it)->ti.x != -0x80);
 

	
 
	if (flags & DC_EXEC) {
 
		/* Always add the noise, so there will be no need to recalculate when option toggles */
 
		nearest->noise_reached += newnoise_level;
 

	
 
		st->AddFacility(FACIL_AIRPORT, tile);
 
		st->airport.type = airport_type;
 
		st->airport.layout = layout;
 
		st->airport.flags = 0;
 

	
 
		st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
 

	
 
		it = as->table[layout];
 
		do {
 
			TileIndex cur_tile = tile + ToTileIndexDiff(it->ti);
 
			MakeAirport(cur_tile, st->owner, st->index, it->gfx);
 
			SetStationTileRandomBits(cur_tile, GB(Random(), 0, 4));
 
			st->airport.Add(cur_tile);
 

	
 
			if (AirportTileSpec::Get(GetTranslatedAirportTileID(it->gfx))->animation_info != 0xFFFF) AddAnimatedTile(cur_tile);
 
		} while ((++it)->ti.x != -0x80);
 

	
 
		/* Only call the animation trigger after all tiles have been built */
 
		it = as->table[layout];
 
		do {
 
			TileIndex cur_tile = tile + ToTileIndexDiff(it->ti);
 
			AirportTileAnimationTrigger(st, cur_tile, AAT_BUILT);
 
		} while ((++it)->ti.x != -0x80);
 

	
 
		/* if airport was demolished while planes were en-route to it, the
 
		 * positions can no longer be the same (v->u.air.pos), since different
 
		 * airports have different indexes. So update all planes en-route to this
0 comments (0 inline, 0 general)