mirror of https://github.com/OpenTTD/OpenTTD
(svn r26149) -Fix [FS#5825]: [Script] Various API functions did not check whether ScrtipRoad::SetCurrentRoadType was called appropiately.
parent
2e79fd9c40
commit
bf0e7c34e6
|
@ -73,6 +73,7 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||||
EnforcePrecondition(false, TileX(start) == TileX(end) || TileY(start) == TileY(end));
|
EnforcePrecondition(false, TileX(start) == TileX(end) || TileY(start) == TileY(end));
|
||||||
EnforcePrecondition(false, vehicle_type == ScriptVehicle::VT_ROAD || vehicle_type == ScriptVehicle::VT_RAIL || vehicle_type == ScriptVehicle::VT_WATER);
|
EnforcePrecondition(false, vehicle_type == ScriptVehicle::VT_ROAD || vehicle_type == ScriptVehicle::VT_RAIL || vehicle_type == ScriptVehicle::VT_WATER);
|
||||||
EnforcePrecondition(false, vehicle_type != ScriptVehicle::VT_RAIL || ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType()));
|
EnforcePrecondition(false, vehicle_type != ScriptVehicle::VT_RAIL || ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType()));
|
||||||
|
EnforcePrecondition(false, vehicle_type != ScriptVehicle::VT_ROAD || ScriptRoad::IsRoadTypeAvailable(ScriptRoad::GetCurrentRoadType()));
|
||||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY || vehicle_type == ScriptVehicle::VT_ROAD);
|
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY || vehicle_type == ScriptVehicle::VT_ROAD);
|
||||||
|
|
||||||
uint type = 0;
|
uint type = 0;
|
||||||
|
|
|
@ -133,7 +133,8 @@ public:
|
||||||
* @pre 'start' and 'end' are in a straight line, i.e.
|
* @pre 'start' and 'end' are in a straight line, i.e.
|
||||||
* ScriptMap::GetTileX(start) == ScriptMap::GetTileX(end) or
|
* ScriptMap::GetTileX(start) == ScriptMap::GetTileX(end) or
|
||||||
* ScriptMap::GetTileY(start) == ScriptMap::GetTileY(end).
|
* ScriptMap::GetTileY(start) == ScriptMap::GetTileY(end).
|
||||||
* @pre vehicle_type == ScriptVehicle::VT_ROAD || vehicle_type == ScriptVehicle::VT_WATER ||
|
* @pre vehicle_type == ScriptVehicle::VT_WATER ||
|
||||||
|
* (vehicle_type == ScriptVehicle::VT_ROAD && ScriptRoad::IsRoadTypeAvailable(ScriptRoad::GetCurrentRoadType())) ||
|
||||||
* (vehicle_type == ScriptVehicle::VT_RAIL && ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType())).
|
* (vehicle_type == ScriptVehicle::VT_RAIL && ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType())).
|
||||||
* @game @pre Outside CompanyMode: vehicle_type == ScriptVehicle::VT_ROAD.
|
* @game @pre Outside CompanyMode: vehicle_type == ScriptVehicle::VT_ROAD.
|
||||||
* @exception ScriptError::ERR_ALREADY_BUILT
|
* @exception ScriptError::ERR_ALREADY_BUILT
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
/* static */ bool ScriptRoad::IsRoadDepotTile(TileIndex tile)
|
/* static */ bool ScriptRoad::IsRoadDepotTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (!::IsValidTile(tile)) return false;
|
if (!::IsValidTile(tile)) return false;
|
||||||
|
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return false;
|
||||||
|
|
||||||
return ::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) == ROAD_TILE_DEPOT &&
|
return ::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) == ROAD_TILE_DEPOT &&
|
||||||
(::RoadTypeToRoadTypes((::RoadType)GetCurrentRoadType()) & ::GetRoadTypes(tile)) != 0;
|
(::RoadTypeToRoadTypes((::RoadType)GetCurrentRoadType()) & ::GetRoadTypes(tile)) != 0;
|
||||||
|
@ -40,6 +41,7 @@
|
||||||
/* static */ bool ScriptRoad::IsRoadStationTile(TileIndex tile)
|
/* static */ bool ScriptRoad::IsRoadStationTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (!::IsValidTile(tile)) return false;
|
if (!::IsValidTile(tile)) return false;
|
||||||
|
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return false;
|
||||||
|
|
||||||
return ::IsRoadStopTile(tile) && (::RoadTypeToRoadTypes((::RoadType)GetCurrentRoadType()) & ::GetRoadTypes(tile)) != 0;
|
return ::IsRoadStopTile(tile) && (::RoadTypeToRoadTypes((::RoadType)GetCurrentRoadType()) & ::GetRoadTypes(tile)) != 0;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +49,7 @@
|
||||||
/* static */ bool ScriptRoad::IsDriveThroughRoadStationTile(TileIndex tile)
|
/* static */ bool ScriptRoad::IsDriveThroughRoadStationTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (!::IsValidTile(tile)) return false;
|
if (!::IsValidTile(tile)) return false;
|
||||||
|
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return false;
|
||||||
|
|
||||||
return ::IsDriveThroughStopTile(tile) && (::RoadTypeToRoadTypes((::RoadType)GetCurrentRoadType()) & ::GetRoadTypes(tile)) != 0;
|
return ::IsDriveThroughStopTile(tile) && (::RoadTypeToRoadTypes((::RoadType)GetCurrentRoadType()) & ::GetRoadTypes(tile)) != 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ public:
|
||||||
* Checks whether the given tile is actually a tile with a road depot.
|
* Checks whether the given tile is actually a tile with a road depot.
|
||||||
* @param tile The tile to check.
|
* @param tile The tile to check.
|
||||||
* @pre ScriptMap::IsValidTile(tile).
|
* @pre ScriptMap::IsValidTile(tile).
|
||||||
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
||||||
* @return True if and only if the tile has a road depot.
|
* @return True if and only if the tile has a road depot.
|
||||||
*/
|
*/
|
||||||
static bool IsRoadDepotTile(TileIndex tile);
|
static bool IsRoadDepotTile(TileIndex tile);
|
||||||
|
@ -101,6 +102,7 @@ public:
|
||||||
* Checks whether the given tile is actually a tile with a road station.
|
* Checks whether the given tile is actually a tile with a road station.
|
||||||
* @param tile The tile to check.
|
* @param tile The tile to check.
|
||||||
* @pre ScriptMap::IsValidTile(tile).
|
* @pre ScriptMap::IsValidTile(tile).
|
||||||
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
||||||
* @return True if and only if the tile has a road station.
|
* @return True if and only if the tile has a road station.
|
||||||
*/
|
*/
|
||||||
static bool IsRoadStationTile(TileIndex tile);
|
static bool IsRoadStationTile(TileIndex tile);
|
||||||
|
@ -110,6 +112,7 @@ public:
|
||||||
* road station.
|
* road station.
|
||||||
* @param tile The tile to check.
|
* @param tile The tile to check.
|
||||||
* @pre ScriptMap::IsValidTile(tile).
|
* @pre ScriptMap::IsValidTile(tile).
|
||||||
|
* @pre IsRoadTypeAvailable(GetCurrentRoadType()).
|
||||||
* @return True if and only if the tile has a drive through road station.
|
* @return True if and only if the tile has a drive through road station.
|
||||||
*/
|
*/
|
||||||
static bool IsDriveThroughRoadStationTile(TileIndex tile);
|
static bool IsDriveThroughRoadStationTile(TileIndex tile);
|
||||||
|
|
|
@ -82,6 +82,7 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance *instance)
|
||||||
EnforcePrecondition(false, ::IsValidTile(start));
|
EnforcePrecondition(false, ::IsValidTile(start));
|
||||||
EnforcePrecondition(false, vehicle_type == ScriptVehicle::VT_RAIL || vehicle_type == ScriptVehicle::VT_ROAD);
|
EnforcePrecondition(false, vehicle_type == ScriptVehicle::VT_RAIL || vehicle_type == ScriptVehicle::VT_ROAD);
|
||||||
EnforcePrecondition(false, vehicle_type != ScriptVehicle::VT_RAIL || ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType()));
|
EnforcePrecondition(false, vehicle_type != ScriptVehicle::VT_RAIL || ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType()));
|
||||||
|
EnforcePrecondition(false, vehicle_type != ScriptVehicle::VT_ROAD || ScriptRoad::IsRoadTypeAvailable(ScriptRoad::GetCurrentRoadType()));
|
||||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY || vehicle_type == ScriptVehicle::VT_ROAD);
|
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY || vehicle_type == ScriptVehicle::VT_ROAD);
|
||||||
|
|
||||||
uint type = 0;
|
uint type = 0;
|
||||||
|
|
|
@ -85,8 +85,8 @@ public:
|
||||||
* @param start Where to start the tunnel.
|
* @param start Where to start the tunnel.
|
||||||
* @param vehicle_type The vehicle-type of tunnel to build.
|
* @param vehicle_type The vehicle-type of tunnel to build.
|
||||||
* @pre ScriptMap::IsValidTile(start).
|
* @pre ScriptMap::IsValidTile(start).
|
||||||
* @pre vehicle_type == ScriptVehicle::VT_ROAD || (vehicle_type == ScriptVehicle::VT_RAIL &&
|
* @pre (vehicle_type == ScriptVehicle::VT_ROAD && ScriptRoad::IsRoadTypeAvailable(ScriptRoad::GetCurrentRoadType())) ||
|
||||||
* ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType())).
|
* (vehicle_type == ScriptVehicle::VT_RAIL && ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType())).
|
||||||
* @game @pre Outside CompanyMode: vehicle_type == ScriptVehicle::VT_ROAD.
|
* @game @pre Outside CompanyMode: vehicle_type == ScriptVehicle::VT_ROAD.
|
||||||
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
||||||
* @exception ScriptTunnel::ERR_TUNNEL_CANNOT_BUILD_ON_WATER
|
* @exception ScriptTunnel::ERR_TUNNEL_CANNOT_BUILD_ON_WATER
|
||||||
|
|
Loading…
Reference in New Issue