2009-01-12 17:11:45 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
/** @file script_road.hpp Everything to query and build roads. */
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#ifndef SCRIPT_ROAD_HPP
|
|
|
|
#define SCRIPT_ROAD_HPP
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#include "script_tile.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class that handles all road related functions.
|
2011-12-19 20:57:23 +00:00
|
|
|
* @api ai game
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
class ScriptRoad : public ScriptObject {
|
2009-01-12 17:11:45 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* All road related error messages.
|
|
|
|
*/
|
|
|
|
enum ErrorMessages {
|
|
|
|
/** Base for road building / maintaining errors */
|
2011-11-29 23:15:35 +00:00
|
|
|
ERR_ROAD_BASE = ScriptError::ERR_CAT_ROAD << ScriptError::ERR_CAT_BIT_SIZE,
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/** Road works are in progress */
|
2009-08-05 17:59:21 +00:00
|
|
|
ERR_ROAD_WORKS_IN_PROGRESS, // [STR_ERROR_ROAD_WORKS_IN_PROGRESS]
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/** Drive through is in the wrong direction */
|
2009-08-05 17:59:21 +00:00
|
|
|
ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION, // [STR_ERROR_DRIVE_THROUGH_DIRECTION]
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/** Drive through roads can't be build on town owned roads */
|
2009-08-05 17:59:21 +00:00
|
|
|
ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD, // [STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD]
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** One way roads can't have junctions */
|
2009-04-21 23:40:56 +00:00
|
|
|
ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS, // [STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION]
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Types of road known to the game.
|
|
|
|
*/
|
|
|
|
enum RoadType {
|
2011-12-15 18:40:15 +00:00
|
|
|
/* Note: these values represent part of the in-game RoadType enum */
|
|
|
|
ROADTYPE_ROAD = ::ROADTYPE_ROAD, ///< Build road objects.
|
|
|
|
ROADTYPE_TRAM = ::ROADTYPE_TRAM, ///< Build tram objects.
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-12-15 18:40:15 +00:00
|
|
|
/* Custom added value, only valid for this API */
|
|
|
|
ROADTYPE_INVALID = -1, ///< Invalid RoadType.
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
2009-02-14 22:06:11 +00:00
|
|
|
/**
|
2009-02-19 09:01:34 +00:00
|
|
|
* Type of road station.
|
2009-02-14 22:06:11 +00:00
|
|
|
*/
|
|
|
|
enum RoadVehicleType {
|
2010-08-01 19:36:36 +00:00
|
|
|
ROADVEHTYPE_BUS, ///< Build objects useable for busses and passenger trams
|
|
|
|
ROADVEHTYPE_TRUCK, ///< Build objects useable for trucks and cargo trams
|
2009-02-14 22:06:11 +00:00
|
|
|
};
|
|
|
|
|
2010-01-29 23:56:42 +00:00
|
|
|
/**
|
|
|
|
* Types of road-related objects in the game.
|
|
|
|
*/
|
|
|
|
enum BuildType {
|
2010-08-01 19:36:36 +00:00
|
|
|
BT_ROAD, ///< Build a piece of road
|
|
|
|
BT_DEPOT, ///< Build a road depot
|
|
|
|
BT_BUS_STOP, ///< Build a bus stop
|
|
|
|
BT_TRUCK_STOP, ///< Build a truck stop
|
2010-01-29 23:56:42 +00:00
|
|
|
};
|
|
|
|
|
2009-03-26 19:45:45 +00:00
|
|
|
/**
|
|
|
|
* Determines whether a busstop or a truckstop is needed to transport a certain cargo.
|
|
|
|
* @param cargo_type The cargo to test.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptCargo::IsValidCargo(cargo_type).
|
2009-03-26 19:45:45 +00:00
|
|
|
* @return The road vehicle type needed to transport the cargo.
|
|
|
|
*/
|
|
|
|
static RoadVehicleType GetRoadVehicleTypeForCargo(CargoID cargo_type);
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Checks whether the given tile is actually a tile with road that can be
|
|
|
|
* used to traverse a tile. This excludes road depots and 'normal' road
|
|
|
|
* stations, but includes drive through stations.
|
|
|
|
* @param tile The tile to check.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return True if and only if the tile has road.
|
|
|
|
*/
|
|
|
|
static bool IsRoadTile(TileIndex tile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the given tile is actually a tile with a road depot.
|
|
|
|
* @param tile The tile to check.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return True if and only if the tile has a road depot.
|
|
|
|
*/
|
|
|
|
static bool IsRoadDepotTile(TileIndex tile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the given tile is actually a tile with a road station.
|
|
|
|
* @param tile The tile to check.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return True if and only if the tile has a road station.
|
|
|
|
*/
|
|
|
|
static bool IsRoadStationTile(TileIndex tile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the given tile is actually a tile with a drive through
|
|
|
|
* road station.
|
|
|
|
* @param tile The tile to check.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return True if and only if the tile has a drive through road station.
|
|
|
|
*/
|
|
|
|
static bool IsDriveThroughRoadStationTile(TileIndex tile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a given RoadType is available.
|
|
|
|
* @param road_type The RoadType to check for.
|
2011-12-19 21:05:36 +00:00
|
|
|
* @game @pre Valid ScriptCompanyMode active in scope.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return True if this RoadType can be used.
|
|
|
|
*/
|
|
|
|
static bool IsRoadTypeAvailable(RoadType road_type);
|
|
|
|
|
|
|
|
/**
|
2011-11-29 23:15:35 +00:00
|
|
|
* Get the current RoadType set for all ScriptRoad functions.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return The RoadType currently set.
|
|
|
|
*/
|
|
|
|
static RoadType GetCurrentRoadType();
|
|
|
|
|
|
|
|
/**
|
2011-11-29 23:15:35 +00:00
|
|
|
* Set the RoadType for all further ScriptRoad functions.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @param road_type The RoadType to set.
|
|
|
|
*/
|
|
|
|
static void SetCurrentRoadType(RoadType road_type);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a given tile has RoadType.
|
|
|
|
* @param tile The tile to check.
|
|
|
|
* @param road_type The RoadType to check for.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre IsRoadTypeAvailable(road_type).
|
|
|
|
* @return True if the tile contains a RoadType object.
|
|
|
|
*/
|
|
|
|
static bool HasRoadType(TileIndex tile, RoadType road_type);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the given tiles are directly connected, i.e. whether
|
|
|
|
* a road vehicle can travel from the center of the first tile to the
|
2013-01-08 22:46:42 +00:00
|
|
|
* center of the second tile.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @param tile_from The source tile.
|
|
|
|
* @param tile_to The destination tile.
|
2009-08-16 10:33:36 +00:00
|
|
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(tile_from).
|
|
|
|
* @pre ScriptMap::IsValidTile(tile_to).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre 'tile_from' and 'tile_to' are directly neighbouring tiles.
|
|
|
|
* @return True if and only if a road vehicle can go from tile_from to tile_to.
|
|
|
|
*/
|
|
|
|
static bool AreRoadTilesConnected(TileIndex tile_from, TileIndex tile_to);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup function for building road parts independend on whether the
|
|
|
|
* "building on slopes" setting is enabled or not.
|
|
|
|
* This implementation can be used for abstract reasoning about a tile as
|
|
|
|
* it needs the slope and existing road parts of the tile as information.
|
|
|
|
* @param slope The slope of the tile to examine.
|
|
|
|
* @param existing An array with the existing neighbours in the same format
|
2011-11-29 23:15:35 +00:00
|
|
|
* as "start" and "end", e.g. ScriptMap.GetTileIndex(0, 1).
|
2009-01-12 17:11:45 +00:00
|
|
|
* As a result of this all values of the existing array
|
|
|
|
* must be of type integer.
|
|
|
|
* @param start The tile from where the 'tile to be considered' will be
|
|
|
|
* entered. This is a relative tile, so valid parameters are:
|
2011-11-29 23:15:35 +00:00
|
|
|
* ScriptMap.GetTileIndex(0, 1), ScriptMap.GetTileIndex(0, -1),
|
|
|
|
* ScriptMap.GetTileIndex(1, 0) and ScriptMap.GetTileIndex(-1, 0).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @param end The tile from where the 'tile to be considered' will be
|
|
|
|
* exited. This is a relative tile, sovalid parameters are:
|
2011-11-29 23:15:35 +00:00
|
|
|
* ScriptMap.GetTileIndex(0, 1), ScriptMap.GetTileIndex(0, -1),
|
|
|
|
* ScriptMap.GetTileIndex(1, 0) and ScriptMap.GetTileIndex(-1, 0).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre start != end.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre slope must be a valid slope, i.e. one specified in ScriptTile::Slope.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @note Passing data that would be invalid in-game, e.g. existing containing
|
|
|
|
* road parts that can not be build on a tile with the given slope,
|
|
|
|
* does not necessarily means that -1 is returned, i.e. not all
|
|
|
|
* preconditions written here or assumed by the game are extensively
|
|
|
|
* checked to make sure the data entered is valid.
|
|
|
|
* @return 0 when the build parts do not connect, 1 when they do connect once
|
|
|
|
* they are build or 2 when building the first part automatically
|
|
|
|
* builds the second part. -1 means the preconditions are not met.
|
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
static int32 CanBuildConnectedRoadParts(ScriptTile::Slope slope, struct Array *existing, TileIndex start, TileIndex end);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup function for building road parts independend on whether the
|
|
|
|
* "building on slopes" setting is enabled or not.
|
|
|
|
* This implementation can be used for reasoning about an existing tile.
|
|
|
|
* @param tile The the tile to examine.
|
|
|
|
* @param start The tile from where "tile" will be entered.
|
|
|
|
* @param end The tile from where "tile" will be exited.
|
|
|
|
* @pre start != end.
|
|
|
|
* @pre tile != start.
|
|
|
|
* @pre tile != end.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap.IsValidTile(tile).
|
|
|
|
* @pre ScriptMap.IsValidTile(start).
|
|
|
|
* @pre ScriptMap.IsValidTile(end).
|
|
|
|
* @pre ScriptMap.GetDistanceManhattanToTile(tile, start) == 1.
|
|
|
|
* @pre ScriptMap.GetDistanceManhattanToTile(tile, end) == 1.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return 0 when the build parts do not connect, 1 when they do connect once
|
|
|
|
* they are build or 2 when building the first part automatically
|
|
|
|
* builds the second part. -1 means the preconditions are not met.
|
|
|
|
*/
|
|
|
|
static int32 CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Count how many neighbours are road.
|
|
|
|
* @param tile The tile to check on.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
2009-08-16 10:33:36 +00:00
|
|
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return 0 means no neighbour road; max value is 4.
|
|
|
|
*/
|
|
|
|
static int32 GetNeighbourRoadCount(TileIndex tile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the tile in front of a road depot.
|
|
|
|
* @param depot The road depot tile.
|
|
|
|
* @pre IsRoadDepotTile(depot).
|
|
|
|
* @return The tile in front of the depot.
|
|
|
|
*/
|
|
|
|
static TileIndex GetRoadDepotFrontTile(TileIndex depot);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the tile in front of a road station.
|
|
|
|
* @param station The road station tile.
|
|
|
|
* @pre IsRoadStationTile(station).
|
|
|
|
* @return The tile in front of the road station.
|
|
|
|
*/
|
|
|
|
static TileIndex GetRoadStationFrontTile(TileIndex station);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the tile at the back of a drive through road station.
|
|
|
|
* So, one side of the drive through station is retrieved with
|
|
|
|
* GetTileInFrontOfStation, the other with this function.
|
|
|
|
* @param station The road station tile.
|
|
|
|
* @pre IsDriveThroughRoadStationTile(station).
|
|
|
|
* @return The tile at the back of the drive through road station.
|
|
|
|
*/
|
|
|
|
static TileIndex GetDriveThroughBackTile(TileIndex station);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds a road from the center of tile start to the center of tile end.
|
|
|
|
* @param start The start tile of the road.
|
|
|
|
* @param end The end tile of the road.
|
|
|
|
* @pre 'start' is not equal to 'end'.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(start).
|
|
|
|
* @pre ScriptMap::IsValidTile(end).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre 'start' and 'end' are in a straight line, i.e.
|
2011-11-29 23:15:35 +00:00
|
|
|
* ScriptMap::GetTileX(start) == ScriptMap::GetTileX(end) or
|
|
|
|
* ScriptMap::GetTileY(start) == ScriptMap::GetTileY(end).
|
2009-08-16 10:33:36 +00:00
|
|
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_ALREADY_BUILT
|
|
|
|
* @exception ScriptError::ERR_LAND_SLOPED_WRONG
|
|
|
|
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS
|
|
|
|
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
2010-02-02 21:25:01 +00:00
|
|
|
* @note Construction will fail if an obstacle is found between the start and end tiles.
|
2011-12-19 21:02:33 +00:00
|
|
|
* @game @note Building a piece of road (without CompanyMode) results in a piece of road owned by towns.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return Whether the road has been/can be build or not.
|
|
|
|
*/
|
|
|
|
static bool BuildRoad(TileIndex start, TileIndex end);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds a one-way road from the center of tile start to the center
|
|
|
|
* of tile end. If the road already exists, it is made one-way road.
|
|
|
|
* If the road already exists and is already one-way in this direction,
|
|
|
|
* the road is made two-way again. If the road already exists but is
|
|
|
|
* one-way in the other direction, it's made a 'no'-way road (it's
|
|
|
|
* forbidden to enter the tile from any direction).
|
|
|
|
* @param start The start tile of the road.
|
|
|
|
* @param end The end tile of the road.
|
|
|
|
* @pre 'start' is not equal to 'end'.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(start).
|
|
|
|
* @pre ScriptMap::IsValidTile(end).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre 'start' and 'end' are in a straight line, i.e.
|
2011-11-29 23:15:35 +00:00
|
|
|
* ScriptMap::GetTileX(start) == ScriptMap::GetTileX(end) or
|
|
|
|
* ScriptMap::GetTileY(start) == ScriptMap::GetTileY(end).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre GetCurrentRoadType() == ROADTYPE_ROAD.
|
2011-12-19 21:05:36 +00:00
|
|
|
* @game @pre Valid ScriptCompanyMode active in scope.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_ALREADY_BUILT
|
|
|
|
* @exception ScriptError::ERR_LAND_SLOPED_WRONG
|
|
|
|
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS
|
|
|
|
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
2010-02-02 21:25:01 +00:00
|
|
|
* @note Construction will fail if an obstacle is found between the start and end tiles.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return Whether the road has been/can be build or not.
|
|
|
|
*/
|
|
|
|
static bool BuildOneWayRoad(TileIndex start, TileIndex end);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds a road from the edge of tile start to the edge of tile end (both
|
|
|
|
* included).
|
|
|
|
* @param start The start tile of the road.
|
|
|
|
* @param end The end tile of the road.
|
|
|
|
* @pre 'start' is not equal to 'end'.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(start).
|
|
|
|
* @pre ScriptMap::IsValidTile(end).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre 'start' and 'end' are in a straight line, i.e.
|
2011-11-29 23:15:35 +00:00
|
|
|
* ScriptMap::GetTileX(start) == ScriptMap::GetTileX(end) or
|
|
|
|
* ScriptMap::GetTileY(start) == ScriptMap::GetTileY(end).
|
2009-08-16 10:33:36 +00:00
|
|
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_ALREADY_BUILT
|
|
|
|
* @exception ScriptError::ERR_LAND_SLOPED_WRONG
|
|
|
|
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS
|
|
|
|
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
2010-02-02 21:25:01 +00:00
|
|
|
* @note Construction will fail if an obstacle is found between the start and end tiles.
|
2011-12-19 21:02:33 +00:00
|
|
|
* @game @note Building a piece of road (without CompanyMode) results in a piece of road owned by towns.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return Whether the road has been/can be build or not.
|
|
|
|
*/
|
|
|
|
static bool BuildRoadFull(TileIndex start, TileIndex end);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds a one-way road from the edge of tile start to the edge of tile end
|
|
|
|
* (both included). If the road already exists, it is made one-way road.
|
|
|
|
* If the road already exists and is already one-way in this direction,
|
|
|
|
* the road is made two-way again. If the road already exists but is
|
|
|
|
* one-way in the other direction, it's made a 'no'-way road (it's
|
|
|
|
* forbidden to enter the tile from any direction).
|
|
|
|
* @param start The start tile of the road.
|
|
|
|
* @param start The start tile of the road.
|
|
|
|
* @param end The end tile of the road.
|
|
|
|
* @pre 'start' is not equal to 'end'.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(start).
|
|
|
|
* @pre ScriptMap::IsValidTile(end).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre 'start' and 'end' are in a straight line, i.e.
|
2011-11-29 23:15:35 +00:00
|
|
|
* ScriptMap::GetTileX(start) == ScriptMap::GetTileX(end) or
|
|
|
|
* ScriptMap::GetTileY(start) == ScriptMap::GetTileY(end).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre GetCurrentRoadType() == ROADTYPE_ROAD.
|
2011-12-19 21:05:36 +00:00
|
|
|
* @game @pre Valid ScriptCompanyMode active in scope.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_ALREADY_BUILT
|
|
|
|
* @exception ScriptError::ERR_LAND_SLOPED_WRONG
|
|
|
|
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS
|
|
|
|
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
2010-02-02 21:25:01 +00:00
|
|
|
* @note Construction will fail if an obstacle is found between the start and end tiles.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return Whether the road has been/can be build or not.
|
|
|
|
*/
|
|
|
|
static bool BuildOneWayRoadFull(TileIndex start, TileIndex end);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds a road depot.
|
|
|
|
* @param tile Place to build the depot.
|
|
|
|
* @param front The tile exactly in front of the depot.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
|
|
|
* @pre ScriptMap::IsValidTile(front).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre 'tile' is not equal to 'front', but in a straight line of it.
|
2009-08-16 10:33:36 +00:00
|
|
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
2011-12-19 21:05:36 +00:00
|
|
|
* @game @pre Valid ScriptCompanyMode active in scope.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_FLAT_LAND_REQUIRED
|
|
|
|
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return Whether the road depot has been/can be build or not.
|
|
|
|
*/
|
|
|
|
static bool BuildRoadDepot(TileIndex tile, TileIndex front);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds a road bus or truck station.
|
2009-02-14 20:07:05 +00:00
|
|
|
* @param tile Place to build the station.
|
2009-01-12 17:11:45 +00:00
|
|
|
* @param front The tile exactly in front of the station.
|
2009-02-14 22:06:11 +00:00
|
|
|
* @param road_veh_type Whether to build a truck or bus station.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @param station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT.
|
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
|
|
|
* @pre ScriptMap::IsValidTile(front).
|
2009-02-14 22:06:11 +00:00
|
|
|
* @pre 'tile' is not equal to 'front', but in a straight line of it.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id).
|
2009-08-16 10:33:36 +00:00
|
|
|
* @pre GetCurrentRoadType() == ROADTYPE_ROAD.
|
2011-12-19 21:05:36 +00:00
|
|
|
* @game @pre Valid ScriptCompanyMode active in scope.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
|
|
|
|
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
|
|
|
* @exception ScriptError::ERR_FLAT_LAND_REQUIRED
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD
|
|
|
|
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
|
|
|
* @exception ScriptStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
|
|
|
|
* @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS
|
|
|
|
* @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN
|
2009-02-14 22:06:11 +00:00
|
|
|
* @return Whether the station has been/can be build or not.
|
|
|
|
*/
|
|
|
|
static bool BuildRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds a drive-through road bus or truck station.
|
2009-08-16 09:04:53 +00:00
|
|
|
* @param tile Place to build the station.
|
2009-02-14 22:06:11 +00:00
|
|
|
* @param front A tile on the same axis with 'tile' as the station shall be oriented.
|
|
|
|
* @param road_veh_type Whether to build a truck or bus station.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @param station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT.
|
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
|
|
|
* @pre ScriptMap::IsValidTile(front).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre 'tile' is not equal to 'front', but in a straight line of it.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id).
|
2009-08-16 10:33:36 +00:00
|
|
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
2011-12-19 21:05:36 +00:00
|
|
|
* @game @pre Valid ScriptCompanyMode active in scope.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
|
|
|
|
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
|
|
|
* @exception ScriptError::ERR_FLAT_LAND_REQUIRED
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD
|
|
|
|
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
|
|
|
* @exception ScriptStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
|
|
|
|
* @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS
|
|
|
|
* @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return Whether the station has been/can be build or not.
|
|
|
|
*/
|
2009-02-14 22:06:11 +00:00
|
|
|
static bool BuildDriveThroughRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a road from the center of tile start to the center of tile end.
|
|
|
|
* @param start The start tile of the road.
|
|
|
|
* @param end The end tile of the road.
|
2012-10-25 19:25:31 +00:00
|
|
|
* @pre 'start' is not equal to 'end'.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(start).
|
|
|
|
* @pre ScriptMap::IsValidTile(end).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre 'start' and 'end' are in a straight line, i.e.
|
2011-11-29 23:15:35 +00:00
|
|
|
* ScriptMap::GetTileX(start) == ScriptMap::GetTileX(end) or
|
|
|
|
* ScriptMap::GetTileY(start) == ScriptMap::GetTileY(end).
|
2009-08-16 10:33:36 +00:00
|
|
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
2011-12-19 21:05:36 +00:00
|
|
|
* @game @pre Valid ScriptCompanyMode active in scope.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
|
|
|
|
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return Whether the road has been/can be removed or not.
|
|
|
|
*/
|
|
|
|
static bool RemoveRoad(TileIndex start, TileIndex end);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a road from the edge of tile start to the edge of tile end (both
|
|
|
|
* included).
|
|
|
|
* @param start The start tile of the road.
|
|
|
|
* @param end The end tile of the road.
|
2012-10-25 19:25:31 +00:00
|
|
|
* @pre 'start' is not equal to 'end'.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(start).
|
|
|
|
* @pre ScriptMap::IsValidTile(end).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre 'start' and 'end' are in a straight line, i.e.
|
2011-11-29 23:15:35 +00:00
|
|
|
* ScriptMap::GetTileX(start) == ScriptMap::GetTileX(end) or
|
|
|
|
* ScriptMap::GetTileY(start) == ScriptMap::GetTileY(end).
|
2009-08-16 10:33:36 +00:00
|
|
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
2011-12-19 21:05:36 +00:00
|
|
|
* @game @pre Valid ScriptCompanyMode active in scope.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
|
|
|
|
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
|
|
|
* @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return Whether the road has been/can be removed or not.
|
|
|
|
*/
|
|
|
|
static bool RemoveRoadFull(TileIndex start, TileIndex end);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a road depot.
|
|
|
|
* @param tile Place to remove the depot from.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre Tile is a road depot.
|
2011-12-19 21:05:36 +00:00
|
|
|
* @game @pre Valid ScriptCompanyMode active in scope.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
|
|
|
|
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return Whether the road depot has been/can be removed or not.
|
|
|
|
*/
|
|
|
|
static bool RemoveRoadDepot(TileIndex tile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a road bus or truck station.
|
|
|
|
* @param tile Place to remove the station from.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(tile).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre Tile is a road station.
|
2011-12-19 21:05:36 +00:00
|
|
|
* @game @pre Valid ScriptCompanyMode active in scope.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
|
|
|
|
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return Whether the station has been/can be removed or not.
|
|
|
|
*/
|
|
|
|
static bool RemoveRoadStation(TileIndex tile);
|
|
|
|
|
2010-01-29 23:56:42 +00:00
|
|
|
/**
|
|
|
|
* Get the baseprice of building a road-related object.
|
|
|
|
* @param roadtype the roadtype that is build (on)
|
|
|
|
* @param build_type the type of object to build
|
|
|
|
* @pre IsRoadTypeAvailable(railtype)
|
|
|
|
* @return The baseprice of building the given object.
|
|
|
|
*/
|
|
|
|
static Money GetBuildCost(RoadType roadtype, BuildType build_type);
|
|
|
|
|
2011-12-03 23:40:57 +00:00
|
|
|
/**
|
|
|
|
* Get the maintenance cost factor of a roadtype.
|
2011-12-04 15:48:15 +00:00
|
|
|
* @param roadtype The roadtype to get the maintenance factor of.
|
2011-12-03 23:40:57 +00:00
|
|
|
* @pre IsRoadTypeAvailable(roadtype)
|
|
|
|
* @return Maintenance cost factor of the roadtype.
|
|
|
|
*/
|
|
|
|
static uint16 GetMaintenanceCostFactor(RoadType roadtype);
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal function used by Build(OneWay)Road(Full).
|
|
|
|
*/
|
|
|
|
static bool _BuildRoadInternal(TileIndex start, TileIndex end, bool one_way, bool full);
|
2009-02-14 22:06:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal function used by Build(DriveThrough)RoadStation.
|
|
|
|
*/
|
|
|
|
static bool _BuildRoadStationInternal(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, bool drive_through, StationID station_id);
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#endif /* SCRIPT_ROAD_HPP */
|