From 2edd403656281f774e4a53251395b7b647a1c48b Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 31 Mar 2008 00:06:17 +0000 Subject: [PATCH] (svn r12489) -Codechange: split station.h into station_base.h and station_func.h. --- src/ai/default/default.cpp | 5 ++- src/ai/trolly/build.cpp | 5 ++- src/ai/trolly/trolly.cpp | 2 +- src/aircraft.h | 1 + src/aircraft_cmd.cpp | 1 - src/airport_gui.cpp | 1 - src/build_vehicle_gui.cpp | 1 - src/cargopacket.cpp | 2 +- src/cargopacket.h | 1 + src/disaster_cmd.cpp | 2 +- src/economy.cpp | 1 - src/industry_cmd.cpp | 1 + src/misc_gui.cpp | 2 +- src/network/network_server.cpp | 2 +- src/newgrf.cpp | 1 - src/newgrf.h | 2 +- src/newgrf_engine.cpp | 2 +- src/newgrf_station.cpp | 2 +- src/newgrf_station.h | 3 ++ src/npf.cpp | 2 +- src/npf.h | 4 ++- src/oldloader.cpp | 1 - src/openttd.cpp | 1 - src/order_cmd.cpp | 1 - src/order_gui.cpp | 2 +- src/players.cpp | 2 +- src/rail_cmd.cpp | 1 - src/rail_gui.cpp | 2 +- src/road_gui.cpp | 19 ++++++----- src/road_map.cpp | 1 - src/roadveh_cmd.cpp | 8 ++--- src/saveload.cpp | 2 +- src/settings_gui.cpp | 1 + src/ship_cmd.cpp | 2 +- src/station.cpp | 4 +-- src/{station.h => station_base.h} | 52 +++++-------------------------- src/station_cmd.cpp | 19 ++++++----- src/station_func.h | 43 +++++++++++++++++++++++++ src/station_gui.cpp | 4 +-- src/station_map.h | 16 +++++----- src/station_type.h | 6 ++++ src/strings.cpp | 2 +- src/subsidy_gui.cpp | 2 +- src/town_cmd.cpp | 2 +- src/train_cmd.cpp | 2 +- src/unmovable_cmd.cpp | 1 - src/vehicle.cpp | 1 - src/vehicle_gui.cpp | 1 - src/viewport.cpp | 3 +- src/water_cmd.cpp | 2 ++ src/waypoint.cpp | 2 +- src/yapf/yapf.h | 1 + src/yapf/yapf.hpp | 2 +- 53 files changed, 130 insertions(+), 121 deletions(-) rename src/{station.h => station_base.h} (80%) create mode 100644 src/station_func.h diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index 4708e5f559..62829b4e05 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -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 AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBloc } 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:; diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp index c6bf330e73..109b937aae 100644 --- a/src/ai/trolly/build.cpp +++ b/src/ai/trolly/build.cpp @@ -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 *p, byte type, TileIndex tile, byte lengt 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); } diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp index e06582e747..0d176dc140 100644 --- a/src/ai/trolly/trolly.cpp +++ b/src/ai/trolly/trolly.cpp @@ -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" diff --git a/src/aircraft.h b/src/aircraft.h index 2aa05ace57..0012878b69 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -6,6 +6,7 @@ #define AIRCRAFT_H #include "station_map.h" +#include "station_base.h" #include "vehicle_base.h" #include "engine.h" diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 9421c3b9a0..22e04b0a06 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -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" diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 595eaff8fc..85c839c00f 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -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" diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 8772135eb1..396c855878 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -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" diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp index e97ff866c9..9d5f14b044 100644 --- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -4,7 +4,7 @@ #include "stdafx.h" #include "openttd.h" -#include "station.h" +#include "station_base.h" #include "cargopacket.h" #include "saveload.h" diff --git a/src/cargopacket.h b/src/cargopacket.h index 4b6397b621..cce9a43986 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -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" diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index 12d9f649d8..0482edeaad 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -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" diff --git a/src/economy.cpp b/src/economy.cpp index 70f0d8849f..9a7203af0c 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -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" diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 9dd1077ec0..3886ddc0eb 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -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" diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 375eb27015..b92501d3e1 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -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" diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 29b21fc477..51bc762333 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -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" diff --git a/src/newgrf.cpp b/src/newgrf.cpp index b267d31986..dde16e732a 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -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" diff --git a/src/newgrf.h b/src/newgrf.h index adf43921cc..b0e3b5c043 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -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, diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 9e7d154b9d..d455552c95 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -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" diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 5162f6028a..96654d90b9 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -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" diff --git a/src/newgrf_station.h b/src/newgrf_station.h index 1bd02818f3..ff5d82ab0e 100644 --- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -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 diff --git a/src/npf.cpp b/src/npf.cpp index 14cebac9e0..1432c91897 100644 --- a/src/npf.cpp +++ b/src/npf.cpp @@ -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" diff --git a/src/npf.h b/src/npf.h index 8448c30b5a..ca4580d143 100644 --- a/src/npf.h +++ b/src/npf.h @@ -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" diff --git a/src/oldloader.cpp b/src/oldloader.cpp index 0c985c375e..1d7008c17a 100644 --- a/src/oldloader.cpp +++ b/src/oldloader.cpp @@ -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" diff --git a/src/openttd.cpp b/src/openttd.cpp index 14412d8e48..70e2a1b51a 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -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" diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 2cce9c55a9..3aa87886bb 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -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" diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 7ec38c7c33..8d2fd6b1d4 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -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" diff --git a/src/players.cpp b/src/players.cpp index 18df770bde..85a5ef5d00 100644 --- a/src/players.cpp +++ b/src/players.cpp @@ -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" diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 1292a65230..2828bfafe6 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -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" diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 939cd8fe4d..28c0670c5e 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -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" diff --git a/src/road_gui.cpp b/src/road_gui.cpp index fe5410df15..2d1ccb19d2 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -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, uint32 p2, uint32 cmd) 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 *w) 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_picker_desc = { 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]; } diff --git a/src/road_map.cpp b/src/road_map.cpp index a39fa5fc91..8c17836400 100644 --- a/src/road_map.cpp +++ b/src/road_map.cpp @@ -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" diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 572d04fc97..9be636077f 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -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(Vehicle* v, TileIndex tile, DiagDirection ent 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)) { diff --git a/src/saveload.cpp b/src/saveload.cpp index bf3ed3a234..463782c411 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -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" diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index d7be418ef7..ca2592a198 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -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" diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 84241c7887..d9147c4ce7 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -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" diff --git a/src/station.cpp b/src/station.cpp index 21147c2ef4..f16fb8430f 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -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) */ diff --git a/src/station.h b/src/station_base.h similarity index 80% rename from src/station.h rename to src/station_base.h index 2458e6e560..ffc40a6240 100644 --- a/src/station.h +++ b/src/station_base.h @@ -1,22 +1,18 @@ /* $Id$ */ -/** @file station.h */ +/** @file station_base.h Base classes/functions for stations. */ -#ifndef STATION_H -#define STATION_H +#ifndef STATION_BASE_H +#define STATION_BASE_H #include "station_type.h" #include "airport.h" #include "oldpool.h" -#include "sprite.h" -#include "road_type.h" -#include "newgrf_station.h" #include "cargopacket.h" #include "cargo_type.h" #include "town_type.h" -#include "core/geometry_type.hpp" +#include "newgrf_station.h" #include -#include DECLARE_OLD_POOL(Station, Station, 6, 1000) DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000) @@ -47,12 +43,6 @@ struct GoodsEntry { /** A Stop for a Road Vehicle */ struct RoadStop : PoolItem { - /** Types of RoadStops */ - enum Type { - BUS, ///< A standard stop for buses - TRUCK ///< A standard stop for trucks - }; - 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 @@ -114,9 +104,9 @@ struct StationRect : public Rect { struct Station : PoolItem { public: - RoadStop *GetPrimaryRoadStop(RoadStop::Type type) const + RoadStop *GetPrimaryRoadStop(RoadStopType type) const { - return type == RoadStop::BUS ? bus_stops : truck_stops; + return type == ROADSTOP_BUS ? bus_stops : truck_stops; } RoadStop *GetPrimaryRoadStop(const Vehicle *v) const; @@ -200,16 +190,6 @@ public: inline bool IsValid() const { return this->xy != 0; } }; -void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius); - -/** A set of stations (\c const \c Station* ) */ -typedef std::set StationSet; - -StationSet FindStationsAroundIndustryTile(TileIndex tile, int w, int h); - -void ShowStationViewWindow(StationID station); -void UpdateAllStationVirtCoord(); - static inline StationID GetMaxStationIndex() { /* TODO - This isn't the real content of the function, but @@ -241,22 +221,4 @@ static inline bool IsValidStationID(StationID index) /* End of stuff for ROADSTOPS */ - -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); - -RoadStop * GetRoadStopByTile(TileIndex tile, RoadStop::Type type); -uint GetNumRoadStops(const Station* st, RoadStop::Type type); -RoadStop * AllocateRoadStop(); -void ClearSlot(Vehicle *v); - -bool HasStationInUse(StationID station, PlayerID player); - -void DeleteOilRig(TileIndex t); - -#endif /* STATION_H */ +#endif /* STATION_BASE_H */ diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index aa354cfae7..df9e6cbbca 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -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 tile, RoadStop::Type type) } -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(Station *st, TileIndex tile, uint32 fla } /** - * @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 tile, uint32 flags, uint32 p1, uint32 p2) AutoPtrT 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 tile, uint32 flags, uint32 p1, uint32 p2) 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(Station *st, uint32 flags, TileIndex tile) 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 VehicleEnter_Station(Vehicle *v, TileIndex tile, i 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(TileIndex tile, PlayerID old_player, PlayerI } 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); diff --git a/src/station_func.h b/src/station_func.h new file mode 100644 index 0000000000..2db114279d --- /dev/null +++ b/src/station_func.h @@ -0,0 +1,43 @@ +/* $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 + +void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius); + +/** A set of stations (\c const \c Station* ) */ +typedef std::set 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 */ diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 8a4f7a6f50..ab35ea2ff6 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -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" diff --git a/src/station_map.h b/src/station_map.h index f2a2f86dd7..826fb4e3d6 100644 --- a/src/station_map.h +++ b/src/station_map.h @@ -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(TileIndex t) 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(TileIndex t, Owner o, StationID sid, Axis a, 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); } diff --git a/src/station_type.h b/src/station_type.h index 17ed0ff46c..d88972021e 100644 --- a/src/station_type.h +++ b/src/station_type.h @@ -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, diff --git a/src/strings.cpp b/src/strings.cpp index aa62e30d7b..b2d0d0b826 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -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" diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 239f6a4305..0fffa303b9 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -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" diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index acde0e3c42..46745c210d 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -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" diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 5bbb287438..9700048a98 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -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" diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp index 1e6aac635b..6dc87ad088 100644 --- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -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" diff --git a/src/vehicle.cpp b/src/vehicle.cpp index bf39056806..6d2d189888 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -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" diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 4730cb7044..e217ecd0b8 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -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" diff --git a/src/viewport.cpp b/src/viewport.cpp index ad9141b89b..96e8dff887 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -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" diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 678c94b14b..5d83763473 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -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" diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 16e2781237..f69334012a 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -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" diff --git a/src/yapf/yapf.h b/src/yapf/yapf.h index 40851eb42a..f11ef2a40d 100644 --- a/src/yapf/yapf.h +++ b/src/yapf/yapf.h @@ -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 diff --git a/src/yapf/yapf.hpp b/src/yapf/yapf.hpp index b98dfdf4bd..97f104e49d 100644 --- a/src/yapf/yapf.hpp +++ b/src/yapf/yapf.hpp @@ -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"