Changeset - r8785:8312063c5ee4
[Not reviewed]
src/ai/default/default.cpp
Show inline comments
 
@@ -15,7 +15,6 @@
 
#include "../../command_func.h"
 
#include "../../town.h"
 
#include "../../industry.h"
 
#include "../../station.h"
 
#include "../../pathfind.h"
 
#include "../../airport.h"
 
#include "../../depot.h"
 
@@ -2690,10 +2689,10 @@ static CommandCost AiDoBuildDefaultRoadB
 
		} else if (p->mode == 1) {
 
			if (_want_road_truck_station) {
 
				// Truck station
 
				ret = DoCommand(c, p->attr, ROADTYPES_ROAD << 2 | RoadStop::TRUCK, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP);
 
				ret = DoCommand(c, p->attr, ROADTYPES_ROAD << 2 | ROADSTOP_TRUCK, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP);
 
			} else {
 
				// Bus station
 
				ret = DoCommand(c, p->attr, ROADTYPES_ROAD << 2 | RoadStop::BUS, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP);
 
				ret = DoCommand(c, p->attr, ROADTYPES_ROAD << 2 | ROADSTOP_BUS, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP);
 
			}
 
clear_town_stuff:;
 

	
src/ai/trolly/build.cpp
Show inline comments
 
@@ -7,7 +7,6 @@
 
#include "../../command_func.h"
 
#include "trolly.h"
 
#include "../../engine.h"
 
#include "../../station.h"
 
#include "../../variables.h"
 
#include "../../bridge.h"
 
#include "../../vehicle_func.h"
 
@@ -44,9 +43,9 @@ CommandCost AiNew_Build_Station(Player *
 
		return AI_DoCommand(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
 

	
 
	if (type == AI_BUS)
 
		return AI_DoCommand(tile, direction, ROADTYPES_ROAD << 2 | RoadStop::BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
 
		return AI_DoCommand(tile, direction, ROADTYPES_ROAD << 2 | ROADSTOP_BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
 

	
 
	return AI_DoCommand(tile, direction, ROADTYPES_ROAD << 2 | RoadStop::TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
 
	return AI_DoCommand(tile, direction, ROADTYPES_ROAD << 2 | ROADSTOP_TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
 
}
 

	
 

	
src/ai/trolly/trolly.cpp
Show inline comments
 
@@ -26,7 +26,7 @@
 
#include "trolly.h"
 
#include "../../town.h"
 
#include "../../industry.h"
 
#include "../../station.h"
 
#include "../../station_base.h"
 
#include "../../engine.h"
 
#include "../../gui.h"
 
#include "../../depot.h"
src/aircraft.h
Show inline comments
 
@@ -6,6 +6,7 @@
 
#define AIRCRAFT_H
 

	
 
#include "station_map.h"
 
#include "station_base.h"
 
#include "vehicle_base.h"
 
#include "engine.h"
 

	
src/aircraft_cmd.cpp
Show inline comments
 
@@ -12,7 +12,6 @@
 
#include "timetable.h"
 
#include "depot.h"
 
#include "engine.h"
 
#include "station.h"
 
#include "news_func.h"
 
#include "aircraft.h"
 
#include "airport.h"
src/airport_gui.cpp
Show inline comments
 
@@ -9,7 +9,6 @@
 
#include "station_gui.h"
 
#include "terraform_gui.h"
 
#include "command_func.h"
 
#include "station.h"
 
#include "airport.h"
 
#include "depot.h"
 
#include "sound_func.h"
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -12,7 +12,6 @@
 
#include "gui.h"
 
#include "articulated_vehicles.h"
 
#include "textbuf_gui.h"
 
#include "station.h"
 
#include "command_func.h"
 
#include "engine.h"
 
#include "player_func.h"
src/cargopacket.cpp
Show inline comments
 
@@ -4,7 +4,7 @@
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "cargopacket.h"
 
#include "saveload.h"
 

	
src/cargopacket.h
Show inline comments
 
@@ -5,6 +5,7 @@
 
#ifndef CARGOPACKET_H
 
#define CARGOPACKET_H
 

	
 
#include "oldpool.h"
 
#include "economy_type.h"
 
#include "tile_type.h"
 
#include "station_type.h"
src/disaster_cmd.cpp
Show inline comments
 
@@ -25,7 +25,7 @@
 
#include "command_func.h"
 
#include "tile_cmd.h"
 
#include "news_func.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "waypoint.h"
 
#include "town.h"
 
#include "industry.h"
src/economy.cpp
Show inline comments
 
@@ -8,7 +8,6 @@
 
#include "landscape.h"
 
#include "player_base.h"
 
#include "player_func.h"
 
#include "station.h"
 
#include "command_func.h"
 
#include "saveload.h"
 
#include "industry.h"
src/industry_cmd.cpp
Show inline comments
 
@@ -36,6 +36,7 @@
 
#include "date_func.h"
 
#include "vehicle_func.h"
 
#include "sound_func.h"
 
#include "station_base.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
src/misc_gui.cpp
Show inline comments
 
@@ -17,7 +17,7 @@
 
#include "textbuf_gui.h"
 
#include "viewport_func.h"
 
#include "gfx_func.h"
 
#include "station.h"
 
#include "station_func.h"
 
#include "command_func.h"
 
#include "player_func.h"
 
#include "player_base.h"
src/network/network_server.cpp
Show inline comments
 
@@ -16,7 +16,7 @@
 
#include "../console.h"
 
#include "../command_func.h"
 
#include "../saveload.h"
 
#include "../station.h"
 
#include "../station_base.h"
 
#include "../variables.h"
 
#include "../genworld.h"
 
#include "../core/alloc_func.hpp"
src/newgrf.cpp
Show inline comments
 
@@ -11,7 +11,6 @@
 
#include "fileio.h"
 
#include "engine.h"
 
#include "spritecache.h"
 
#include "station.h"
 
#include "sprite.h"
 
#include "newgrf.h"
 
#include "variables.h"
src/newgrf.h
Show inline comments
 
@@ -5,11 +5,11 @@
 
#ifndef NEWGRF_H
 
#define NEWGRF_H
 

	
 
#include "station.h"
 
#include "town_type.h"
 
#include "newgrf_config.h"
 
#include "cargotype.h"
 
#include "industry_type.h"
 
#include "newgrf_station.h"
 

	
 
enum GrfLoadingStage {
 
	GLS_FILESCAN,
src/newgrf_engine.cpp
Show inline comments
 
@@ -10,7 +10,7 @@
 
#include "train.h"
 
#include "player_func.h"
 
#include "player_base.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "airport.h"
 
#include "newgrf.h"
 
#include "newgrf_callbacks.h"
src/newgrf_station.cpp
Show inline comments
 
@@ -9,7 +9,7 @@
 
#include "landscape.h"
 
#include "debug.h"
 
#include "sprite.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "station_map.h"
 
#include "newgrf.h"
 
#include "newgrf_callbacks.h"
src/newgrf_station.h
Show inline comments
 
@@ -9,7 +9,10 @@
 
#include "newgrf_callbacks.h"
 
#include "newgrf_cargo.h"
 
#include "tile_type.h"
 
#include "station_type.h"
 
#include "strings_type.h"
 
#include "sprite.h"
 
#include "direction_type.h"
 

	
 
enum StationClassID {
 
	STAT_CLASS_BEGIN = 0,    ///< the lowest valid value
src/npf.cpp
Show inline comments
 
@@ -12,7 +12,7 @@
 
#include "landscape.h"
 
#include "aystar.h"
 
#include "pathfind.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "station_map.h"
 
#include "depot.h"
 
#include "tunnel_map.h"
src/npf.h
Show inline comments
 
@@ -6,7 +6,9 @@
 
#define NPF_H
 

	
 
#include "aystar.h"
 
#include "station.h"
 
#include "station_type.h"
 
#include "rail_type.h"
 
#include "player_type.h"
 
#include "vehicle_type.h"
 
#include "tile_type.h"
 
#include "track_type.h"
src/oldloader.cpp
Show inline comments
 
@@ -7,7 +7,6 @@
 
#include "station_map.h"
 
#include "town.h"
 
#include "industry.h"
 
#include "station.h"
 
#include "player_func.h"
 
#include "player_base.h"
 
#include "engine.h"
src/openttd.cpp
Show inline comments
 
@@ -15,7 +15,6 @@
 
#include "gfxinit.h"
 
#include "gui.h"
 
#include "landscape.h"
 
#include "station.h"
 
#include "station_map.h"
 
#include "town_map.h"
 
#include "tunnel_map.h"
src/order_cmd.cpp
Show inline comments
 
@@ -10,7 +10,6 @@
 
#include "depot.h"
 
#include "waypoint.h"
 
#include "command_func.h"
 
#include "station.h"
 
#include "player_func.h"
 
#include "news_func.h"
 
#include "saveload.h"
src/order_gui.cpp
Show inline comments
 
@@ -8,7 +8,7 @@
 
#include "station_map.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "town.h"
 
#include "command_func.h"
 
#include "viewport_func.h"
src/players.cpp
Show inline comments
 
@@ -8,7 +8,6 @@
 
#include "player_func.h"
 
#include "player_gui.h"
 
#include "town.h"
 
#include "station.h"
 
#include "news_func.h"
 
#include "saveload.h"
 
#include "command_func.h"
 
@@ -34,6 +33,7 @@
 
#include "ai/trolly/trolly.h"
 
#include "road_func.h"
 
#include "rail.h"
 
#include "sprite.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
src/rail_cmd.cpp
Show inline comments
 
@@ -19,7 +19,6 @@
 
#include "pathfind.h"
 
#include "engine.h"
 
#include "town.h"
 
#include "station.h"
 
#include "sprite.h"
 
#include "depot.h"
 
#include "waypoint.h"
src/rail_gui.cpp
Show inline comments
 
@@ -13,7 +13,7 @@
 
#include "viewport_func.h"
 
#include "gfx_func.h"
 
#include "command_func.h"
 
#include "station.h"
 
#include "town_type.h"
 
#include "waypoint.h"
 
#include "debug.h"
 
#include "variables.h"
src/road_gui.cpp
Show inline comments
 
@@ -16,7 +16,6 @@
 
#include "road_cmd.h"
 
#include "road_map.h"
 
#include "station_map.h"
 
#include "station.h"
 
#include "functions.h"
 
#include "window_func.h"
 
#include "vehicle_func.h"
 
@@ -27,7 +26,7 @@
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
static void ShowRVStationPicker(RoadStop::Type rs);
 
static void ShowRVStationPicker(RoadStopType rs);
 
static void ShowRoadDepotPicker();
 

	
 
static bool _remove_button_clicked;
 
@@ -215,18 +214,18 @@ static void PlaceRoadStop(TileIndex tile
 
static void PlaceRoad_BusStation(TileIndex tile)
 
{
 
	if (_remove_button_clicked) {
 
		DoCommandP(tile, 0, RoadStop::BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::BUS]));
 
		DoCommandP(tile, 0, ROADSTOP_BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_BUS]));
 
	} else {
 
		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::BUS, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::BUS]));
 
		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_BUS]));
 
	}
 
}
 

	
 
static void PlaceRoad_TruckStation(TileIndex tile)
 
{
 
	if (_remove_button_clicked) {
 
		DoCommandP(tile, 0, RoadStop::TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::TRUCK]));
 
		DoCommandP(tile, 0, ROADSTOP_TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK]));
 
	} else {
 
		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::TRUCK, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::TRUCK]));
 
		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_TRUCK]));
 
	}
 
}
 

	
 
@@ -334,13 +333,13 @@ static void BuildRoadClick_Depot(Window 
 
static void BuildRoadClick_BusStation(Window *w)
 
{
 
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
 
	if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(RoadStop::BUS);
 
	if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(ROADSTOP_BUS);
 
}
 

	
 
static void BuildRoadClick_TruckStation(Window *w)
 
{
 
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
 
	if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(RoadStop::TRUCK);
 
	if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(ROADSTOP_TRUCK);
 
}
 

	
 
/**
 
@@ -942,12 +941,12 @@ static const WindowDesc _rv_station_pick
 
	RoadStationPickerWndProc
 
};
 

	
 
static void ShowRVStationPicker(RoadStop::Type rs)
 
static void ShowRVStationPicker(RoadStopType rs)
 
{
 
	Window *w = AllocateWindowDesc(&_rv_station_picker_desc);
 
	if (w == NULL) return;
 

	
 
	w->window_class = (rs == RoadStop::BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
 
	w->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
 
	w->widget[BRSW_CAPTION].data = _road_type_infos[_cur_roadtype].picker_title[rs];
 
	for (uint i = BRSW_STATION_NE; i < BRSW_LT_OFF; i++) w->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
 
}
src/road_map.cpp
Show inline comments
 
@@ -7,7 +7,6 @@
 
#include "bridge_map.h"
 
#include "tile_cmd.h"
 
#include "road_map.h"
 
#include "station.h"
 
#include "tunnel_map.h"
 
#include "station_map.h"
 
#include "depot.h"
src/roadveh_cmd.cpp
Show inline comments
 
@@ -13,7 +13,7 @@
 
#include "timetable.h"
 
#include "engine.h"
 
#include "command_func.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "news_func.h"
 
#include "pathfind.h"
 
#include "npf.h"
 
@@ -1171,7 +1171,7 @@ static Trackdir RoadFindPathToDest(Vehic
 
			trackdirs = TRACKDIR_BIT_NONE;
 
		} else {
 
			/* Our station */
 
			RoadStop::Type rstype = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK;
 
			RoadStopType rstype = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK;
 

	
 
			if (GetRoadStopType(tile) != rstype) {
 
				/* Wrong station type */
 
@@ -1807,7 +1807,7 @@ again:
 
			_road_veh_data_1[v->u.road.state - RVSB_IN_ROAD_STOP + (_opt.road_side << RVS_DRIVE_SIDE)] == v->u.road.frame) ||
 
			(IsInsideMM(v->u.road.state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
 
			v->current_order.dest == GetStationIndex(v->tile) &&
 
			GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK) &&
 
			GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
 
			v->u.road.frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
 

	
 
		RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
 
@@ -1822,7 +1822,7 @@ again:
 

	
 
			if (IsDriveThroughStopTile(v->tile)) {
 
				TileIndex next_tile = TILE_ADD(v->tile, TileOffsByDir(v->direction));
 
				RoadStop::Type type = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK;
 
				RoadStopType type = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK;
 

	
 
				/* Check if next inline bay is free */
 
				if (IsDriveThroughStopTile(next_tile) && (GetRoadStopType(next_tile) == type)) {
src/saveload.cpp
Show inline comments
 
@@ -16,7 +16,7 @@
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "debug.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "thread.h"
 
#include "town.h"
 
#include "saveload.h"
src/settings_gui.cpp
Show inline comments
 
@@ -27,6 +27,7 @@
 
#include "waypoint.h"
 
#include "widgets/dropdown_type.h"
 
#include "widgets/dropdown_func.h"
 
#include "station_func.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
src/ship_cmd.cpp
Show inline comments
 
@@ -11,7 +11,7 @@
 
#include "command_func.h"
 
#include "pathfind.h"
 
#include "station_map.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "news_func.h"
 
#include "engine.h"
 
#include "player_func.h"
src/station.cpp
Show inline comments
 
@@ -7,7 +7,7 @@
 
#include "bridge_map.h"
 
#include "debug.h"
 
#include "station_map.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "town.h"
 
#include "saveload.h"
 
#include "player_func.h"
 
@@ -100,7 +100,7 @@ Station::~Station()
 
 */
 
RoadStop *Station::GetPrimaryRoadStop(const Vehicle *v) const
 
{
 
	RoadStop *rs = this->GetPrimaryRoadStop(IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK);
 
	RoadStop *rs = this->GetPrimaryRoadStop(IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK);
 

	
 
	for (; rs != NULL; rs = rs->next) {
 
		/* The vehicle cannot go to this roadstop (different roadtype) */
src/station.h
Show inline comments
 
deleted file
src/station_base.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file station_base.h Base classes/functions for stations. */
 

	
 
#ifndef STATION_BASE_H
 
#define STATION_BASE_H
 

	
 
#include "station_type.h"
 
#include "airport.h"
 
#include "oldpool.h"
 
#include "cargopacket.h"
 
#include "cargo_type.h"
 
#include "town_type.h"
 
#include "newgrf_station.h"
 
#include <list>
 

	
 
DECLARE_OLD_POOL(Station, Station, 6, 1000)
 
DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000)
 

	
 
static const byte INITIAL_STATION_RATING = 175;
 

	
 
struct GoodsEntry {
 
	enum AcceptancePickup {
 
		ACCEPTANCE,
 
		PICKUP
 
	};
 

	
 
	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;
 
	CargoList cargo; ///< The cargo packets of cargo waiting in this station
 
};
 

	
 
/** A Stop for a Road Vehicle */
 
struct RoadStop : PoolItem<RoadStop, RoadStopID, &_RoadStop_pool> {
 
	static const int  cDebugCtorLevel =  5;  ///< Debug level on which Contructor / Destructor messages are printed
 
	static const uint LIMIT           = 16;  ///< The maximum amount of roadstops that are allowed at a single station
 
	static const uint MAX_BAY_COUNT   =  2;  ///< The maximum number of loading bays
 

	
 
	TileIndex        xy;                    ///< Position on the map
 
	byte             status;                ///< Current status of the Stop. Like which spot is taken. Access using *Bay and *Busy functions.
 
	byte             num_vehicles;          ///< Number of vehicles currently slotted to this stop
 
	struct RoadStop  *next;                 ///< Next stop of the given type at this station
 

	
 
	RoadStop(TileIndex tile = 0);
 
	virtual ~RoadStop();
 

	
 
	/**
 
	 * Determines whether a road stop exists
 
	 * @return true if and only is the road stop exists
 
	 */
 
	inline bool IsValid() const { return this->xy != 0; }
 

	
 
	/* For accessing status */
 
	bool HasFreeBay() const;
 
	bool IsFreeBay(uint nr) const;
 
	uint AllocateBay();
 
	void AllocateDriveThroughBay(uint nr);
 
	void FreeBay(uint nr);
 
	bool IsEntranceBusy() const;
 
	void SetEntranceBusy(bool busy);
 

	
 
	RoadStop *GetNextRoadStop(const Vehicle *v) const;
 
};
 

	
 
struct StationSpecList {
 
	const StationSpec *spec;
 
	uint32 grfid;      ///< GRF ID of this custom station
 
	uint8  localidx;   ///< Station ID within GRF of station
 
};
 

	
 
/** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */
 
struct StationRect : public Rect {
 
	enum StationRectMode
 
	{
 
		ADD_TEST = 0,
 
		ADD_TRY,
 
		ADD_FORCE
 
	};
 

	
 
	StationRect();
 
	void MakeEmpty();
 
	bool PtInExtendedRect(int x, int y, int distance = 0) const;
 
	bool IsEmpty() const;
 
	bool BeforeAddTile(TileIndex tile, StationRectMode mode);
 
	bool BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode);
 
	bool AfterRemoveTile(Station *st, TileIndex tile);
 
	bool AfterRemoveRect(Station *st, TileIndex tile, int w, int h);
 

	
 
	static bool ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a);
 

	
 
	StationRect& operator = (Rect src);
 
};
 

	
 
struct Station : PoolItem<Station, StationID, &_Station_pool> {
 
public:
 
	RoadStop *GetPrimaryRoadStop(RoadStopType type) const
 
	{
 
		return type == ROADSTOP_BUS ? bus_stops : truck_stops;
 
	}
 

	
 
	RoadStop *GetPrimaryRoadStop(const Vehicle *v) const;
 

	
 
	const AirportFTAClass *Airport() const
 
	{
 
		if (airport_tile == 0) return GetAirport(AT_DUMMY);
 
		return GetAirport(airport_type);
 
	}
 

	
 
	TileIndex xy;
 
	RoadStop *bus_stops;
 
	RoadStop *truck_stops;
 
	TileIndex train_tile;
 
	TileIndex airport_tile;
 
	TileIndex dock_tile;
 
	Town *town;
 
	StringID string_id;     ///< Default name (town area) of station
 
	char *name;             ///< Custom name
 

	
 
	ViewportSign sign;
 

	
 
	uint16 had_vehicle_of_type;
 

	
 
	byte time_since_load;
 
	byte time_since_unload;
 
	byte delete_ctr;
 
	PlayerByte owner;
 
	byte facilities;
 
	byte airport_type;
 

	
 
	/* trainstation width/height */
 
	byte trainst_w, trainst_h;
 

	
 
	/** List of custom stations (StationSpecs) allocated to the station */
 
	uint8 num_specs;
 
	StationSpecList *speclist;
 

	
 
	Date build_date;
 

	
 
	uint64 airport_flags;   ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
 

	
 
	byte last_vehicle_type;
 
	std::list<Vehicle *> loading_vehicles;
 
	GoodsEntry goods[NUM_CARGO];
 

	
 
	uint16 random_bits;
 
	byte waiting_triggers;
 

	
 
	StationRect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions
 

	
 
	static const int cDebugCtorLevel = 5;
 

	
 
	Station(TileIndex tile = 0);
 
	virtual ~Station();
 

	
 
	void AddFacility(byte new_facility_bit, TileIndex facil_xy);
 

	
 
	/**
 
	 * Mark the sign of a station dirty for repaint.
 
	 *
 
	 * @ingroup dirty
 
	 */
 
	void MarkDirty() const;
 

	
 
	/**
 
	 * Marks the tiles of the station as dirty.
 
	 *
 
	 * @ingroup dirty
 
	 */
 
	void MarkTilesDirty(bool cargo_change) const;
 
	bool TileBelongsToRailStation(TileIndex tile) const;
 
	uint GetPlatformLength(TileIndex tile, DiagDirection dir) const;
 
	uint GetPlatformLength(TileIndex tile) const;
 
	bool IsBuoy() const;
 

	
 
	/**
 
	 * Determines whether a station exists
 
	 * @return true if and only is the station exists
 
	 */
 
	inline bool IsValid() const { return this->xy != 0; }
 
};
 

	
 
static inline StationID GetMaxStationIndex()
 
{
 
	/* TODO - This isn't the real content of the function, but
 
	 *  with the new pool-system this will be replaced with one that
 
	 *  _really_ returns the highest index. Now it just returns
 
	 *  the next safe value we are sure about everything is below.
 
	 */
 
	return GetStationPoolSize() - 1;
 
}
 

	
 
static inline uint GetNumStations()
 
{
 
	return GetStationPoolSize();
 
}
 

	
 
static inline bool IsValidStationID(StationID index)
 
{
 
	return index < GetStationPoolSize() && GetStation(index)->IsValid();
 
}
 

	
 
#define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) if (st->IsValid())
 
#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0)
 

	
 

	
 
/* Stuff for ROADSTOPS */
 

	
 
#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) if (rs->IsValid())
 
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
 

	
 
/* End of stuff for ROADSTOPS */
 

	
 
#endif /* STATION_BASE_H */
src/station_cmd.cpp
Show inline comments
 
@@ -11,7 +11,6 @@
 
#include "tile_cmd.h"
 
#include "landscape.h"
 
#include "station_map.h"
 
#include "station.h"
 
#include "viewport_func.h"
 
#include "command_func.h"
 
#include "town.h"
 
@@ -71,7 +70,7 @@ bool IsHangar(TileIndex t)
 
	return false;
 
}
 

	
 
RoadStop* GetRoadStopByTile(TileIndex tile, RoadStop::Type type)
 
RoadStop* GetRoadStopByTile(TileIndex tile, RoadStopType type)
 
{
 
	const Station* st = GetStationByTile(tile);
 

	
 
@@ -82,7 +81,7 @@ RoadStop* GetRoadStopByTile(TileIndex ti
 
}
 

	
 

	
 
static uint GetNumRoadStopsInStation(const Station* st, RoadStop::Type type)
 
static uint GetNumRoadStopsInStation(const Station* st, RoadStopType type)
 
{
 
	uint num = 0;
 

	
 
@@ -1298,7 +1297,7 @@ static CommandCost RemoveRailroadStation
 
}
 

	
 
/**
 
 * @param truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK
 
 * @param truck_station Determines whether a stop is ROADSTOP_BUS or ROADSTOP_TRUCK
 
 * @param st The Station to do the whole procedure for
 
 * @return a pointer to where to link a new RoadStop*
 
 */
 
@@ -1397,7 +1396,7 @@ CommandCost CmdBuildRoadStop(TileIndex t
 
	AutoPtrT<RoadStop> rs_auto_delete(road_stop);
 

	
 
	if (st != NULL &&
 
			GetNumRoadStopsInStation(st, RoadStop::BUS) + GetNumRoadStopsInStation(st, RoadStop::TRUCK) >= RoadStop::LIMIT) {
 
			GetNumRoadStopsInStation(st, ROADSTOP_BUS) + GetNumRoadStopsInStation(st, ROADSTOP_TRUCK) >= RoadStop::LIMIT) {
 
		return_cmd_error(type ? STR_TOO_MANY_TRUCK_STOPS : STR_TOO_MANY_BUS_STOPS);
 
	}
 

	
 
@@ -1442,7 +1441,7 @@ CommandCost CmdBuildRoadStop(TileIndex t
 

	
 
		st->rect.BeforeAddTile(tile, StationRect::ADD_TRY);
 

	
 
		RoadStop::Type rs_type = type ? RoadStop::TRUCK : RoadStop::BUS;
 
		RoadStopType rs_type = type ? ROADSTOP_TRUCK : ROADSTOP_BUS;
 
		if (is_drive_through) {
 
			MakeDriveThroughRoadStop(tile, st->owner, st->index, rs_type, rts, (Axis)p1, town_owned_road);
 
		} else {
 
@@ -1488,10 +1487,10 @@ static CommandCost RemoveRoadStop(Statio
 
	RoadStop *cur_stop;
 
	if (is_truck) { // truck stop
 
		primary_stop = &st->truck_stops;
 
		cur_stop = GetRoadStopByTile(tile, RoadStop::TRUCK);
 
		cur_stop = GetRoadStopByTile(tile, ROADSTOP_TRUCK);
 
	} else {
 
		primary_stop = &st->bus_stops;
 
		cur_stop = GetRoadStopByTile(tile, RoadStop::BUS);
 
		cur_stop = GetRoadStopByTile(tile, ROADSTOP_BUS);
 
	}
 

	
 
	assert(cur_stop != NULL);
 
@@ -2440,7 +2439,7 @@ static VehicleEnterTileStatus VehicleEnt
 
					if (!rs->IsFreeBay(side)) return VETSB_CANNOT_ENTER;
 

	
 
					/* Check if the vehicle is stopping at this road stop */
 
					if (GetRoadStopType(tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK) &&
 
					if (GetRoadStopType(tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
 
							v->current_order.dest == GetStationIndex(tile)) {
 
						SetBit(v->u.road.state, RVS_IS_STOPPING);
 
						rs->AllocateDriveThroughBay(side);
 
@@ -2913,7 +2912,7 @@ static void ChangeTileOwner_Station(Tile
 
	} else {
 
		if (IsDriveThroughStopTile(tile)) {
 
			/* Remove the drive-through road stop */
 
			DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? RoadStop::TRUCK : RoadStop::BUS, DC_EXEC | DC_BANKRUPT, CMD_REMOVE_ROAD_STOP);
 
			DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? ROADSTOP_TRUCK : ROADSTOP_BUS, DC_EXEC | DC_BANKRUPT, CMD_REMOVE_ROAD_STOP);
 
			assert(IsTileType(tile, MP_ROAD));
 
			/* Change owner of tile and all roadtypes */
 
			ChangeTileOwner(tile, old_player, new_player);
src/station_func.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file station_func.h Functions related to stations. */
 

	
 
#ifndef STATION_FUNC_H
 
#define STATION_FUNC_H
 

	
 
#include "station_type.h"
 
#include "sprite.h"
 
#include "road_type.h"
 
#include "tile_type.h"
 
#include "cargo_type.h"
 
#include "vehicle_type.h"
 
#include <set>
 

	
 
void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius);
 

	
 
/** A set of stations (\c const \c Station* ) */
 
typedef std::set<Station*> StationSet;
 

	
 
StationSet FindStationsAroundIndustryTile(TileIndex tile, int w, int h);
 

	
 
void ShowStationViewWindow(StationID station);
 
void UpdateAllStationVirtCoord();
 

	
 
void AfterLoadStations();
 
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad);
 
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad);
 

	
 
const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx);
 
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image);
 

	
 
bool HasStationInUse(StationID station, PlayerID player);
 

	
 
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type);
 
uint GetNumRoadStops(const Station* st, RoadStopType type);
 
RoadStop * AllocateRoadStop();
 

	
 
void ClearSlot(Vehicle *v);
 

	
 
void DeleteOilRig(TileIndex t);
 

	
 
#endif /* STATION_FUNC_H */
src/station_gui.cpp
Show inline comments
 
@@ -8,7 +8,7 @@
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "textbuf_gui.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "player_func.h"
 
#include "economy_func.h"
 
#include "town.h"
 
@@ -17,7 +17,7 @@
 
#include "vehicle_gui.h"
 
#include "cargotype.h"
 
#include "station_gui.h"
 
#include "station.h"
 
#include "station_func.h"
 
#include "strings_func.h"
 
#include "core/alloc_func.hpp"
 
#include "window_func.h"
src/station_map.h
Show inline comments
 
@@ -8,8 +8,10 @@
 
#include "rail_map.h"
 
#include "road_map.h"
 
#include "water_map.h"
 
#include "station.h"
 
#include "station_func.h"
 
#include "station_base.h"
 
#include "rail.h"
 
#include "newgrf_station.h"
 

	
 
typedef byte StationGfx;
 

	
 
@@ -49,10 +51,10 @@ static inline StationType GetStationType
 
	return (StationType)GB(_m[t].m6, 3, 3);
 
}
 

	
 
static inline RoadStop::Type GetRoadStopType(TileIndex t)
 
static inline RoadStopType GetRoadStopType(TileIndex t)
 
{
 
	assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
 
	return GetStationType(t) == STATION_TRUCK ? RoadStop::TRUCK : RoadStop::BUS;
 
	return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
 
}
 

	
 
static inline StationGfx GetStationGfx(TileIndex t)
 
@@ -260,15 +262,15 @@ static inline void MakeRailStation(TileI
 
	SetRailType(t, rt);
 
}
 

	
 
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, DiagDirection d)
 
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d)
 
{
 
	MakeStation(t, o, sid, (rst == RoadStop::BUS ? STATION_BUS : STATION_TRUCK), d);
 
	MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), d);
 
	SetRoadTypes(t, rt);
 
}
 

	
 
static inline void MakeDriveThroughRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, Axis a, bool on_town_road)
 
static inline void MakeDriveThroughRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, Axis a, bool on_town_road)
 
{
 
	MakeStation(t, o, sid, (rst == RoadStop::BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
 
	MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
 
	SB(_m[t].m6, 2, 1, on_town_road);
 
	SetRoadTypes(t, rt);
 
}
src/station_type.h
Show inline comments
 
@@ -23,6 +23,12 @@ enum StationType {
 
	STATION_BUOY
 
};
 

	
 
/** Types of RoadStops */
 
enum RoadStopType {
 
	ROADSTOP_BUS,    ///< A standard stop for buses
 
	ROADSTOP_TRUCK   ///< A standard stop for trucks
 
};
 

	
 
enum {
 
	FACIL_TRAIN      = 0x01,
 
	FACIL_TRUCK_STOP = 0x02,
src/strings.cpp
Show inline comments
 
@@ -6,7 +6,7 @@
 
#include "openttd.h"
 
#include "currency.h"
 
#include "namegen_func.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "town.h"
 
#include "screenshot.h"
 
#include "waypoint.h"
src/subsidy_gui.cpp
Show inline comments
 
@@ -4,7 +4,7 @@
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "industry.h"
 
#include "town.h"
 
#include "economy_func.h"
src/town_cmd.cpp
Show inline comments
 
@@ -15,7 +15,7 @@
 
#include "town.h"
 
#include "command_func.h"
 
#include "industry.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "player_base.h"
 
#include "news_func.h"
 
#include "saveload.h"
src/train_cmd.cpp
Show inline comments
 
@@ -16,7 +16,7 @@
 
#include "command_func.h"
 
#include "pathfind.h"
 
#include "npf.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "news_func.h"
 
#include "engine.h"
 
#include "player_func.h"
src/unmovable_cmd.cpp
Show inline comments
 
@@ -11,7 +11,6 @@
 
#include "player_func.h"
 
#include "player_base.h"
 
#include "gui.h"
 
#include "station.h"
 
#include "town.h"
 
#include "sprite.h"
 
#include "bridge_map.h"
src/vehicle.cpp
Show inline comments
 
@@ -21,7 +21,6 @@
 
#include "debug.h"
 
#include "vehicle_gui.h"
 
#include "depot.h"
 
#include "station.h"
 
#include "rail_type.h"
 
#include "train.h"
 
#include "aircraft.h"
src/vehicle_gui.cpp
Show inline comments
 
@@ -6,7 +6,6 @@
 
#include "openttd.h"
 
#include "debug.h"
 
#include "player_func.h"
 
#include "station.h"
 
#include "engine.h"
 
#include "gui.h"
 
#include "window_gui.h"
src/viewport.cpp
Show inline comments
 
@@ -10,7 +10,7 @@
 
#include "spritecache.h"
 
#include "landscape.h"
 
#include "viewport_func.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "town.h"
 
#include "signs.h"
 
#include "waypoint.h"
 
@@ -25,6 +25,7 @@
 
#include "vehicle_func.h"
 
#include "player_func.h"
 
#include "settings_type.h"
 
#include "station_func.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
src/water_cmd.cpp
Show inline comments
 
@@ -35,6 +35,8 @@
 
#include "settings_type.h"
 
#include "clear_map.h"
 
#include "tree_map.h"
 
#include "station_base.h"
 
#include "airport.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
src/waypoint.cpp
Show inline comments
 
@@ -12,7 +12,7 @@
 
#include "rail.h"
 
#include "bridge_map.h"
 
#include "saveload.h"
 
#include "station.h"
 
#include "station_base.h"
 
#include "town.h"
 
#include "waypoint.h"
 
#include "variables.h"
src/yapf/yapf.h
Show inline comments
 
@@ -7,6 +7,7 @@
 

	
 
#include "../debug.h"
 
#include "../depot_type.h"
 
#include "../direction_type.h"
 

	
 
/** Finds the best path for given ship.
 
 * @param v        the ship that needs to find a path
src/yapf/yapf.hpp
Show inline comments
 
@@ -14,7 +14,7 @@
 
#include "../bridge_map.h"
 
#include "../tunnelbridge_map.h"
 
#include "../bridge.h"
 
#include "../station.h"
 
#include "../station_base.h"
 
#include "../station_map.h"
 
#include "../tile_cmd.h"
 
#include "../landscape.h"
0 comments (0 inline, 0 general)