(svn r23629) -Add: allow ScriptRoad::BuildRoad, ScriptBridge::BuildBridge (for roads) and ScriptTunnel:BuildTunnel (for roads) to work for GameScript
This commit is contained in:
@@ -42,6 +42,7 @@ void SQGSBridge_Register(Squirrel *engine)
|
||||
SQGSBridge.DefSQStaticMethod(engine, &ScriptBridge::GetPrice, "GetPrice", 3, ".ii");
|
||||
SQGSBridge.DefSQStaticMethod(engine, &ScriptBridge::GetMaxLength, "GetMaxLength", 2, ".i");
|
||||
SQGSBridge.DefSQStaticMethod(engine, &ScriptBridge::GetMinLength, "GetMinLength", 2, ".i");
|
||||
SQGSBridge.DefSQStaticMethod(engine, &ScriptBridge::BuildBridge, "BuildBridge", 5, ".iiii");
|
||||
SQGSBridge.DefSQStaticMethod(engine, &ScriptBridge::GetOtherBridgeEnd, "GetOtherBridgeEnd", 2, ".i");
|
||||
|
||||
SQGSBridge.PostRegister(engine);
|
||||
|
@@ -59,6 +59,8 @@ void SQGSRoad_Register(Squirrel *engine)
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetRoadDepotFrontTile, "GetRoadDepotFrontTile", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetRoadStationFrontTile, "GetRoadStationFrontTile", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetDriveThroughBackTile, "GetDriveThroughBackTile", 2, ".i");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::BuildRoad, "BuildRoad", 3, ".ii");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::BuildRoadFull, "BuildRoadFull", 3, ".ii");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetBuildCost, "GetBuildCost", 3, ".ii");
|
||||
SQGSRoad.DefSQStaticMethod(engine, &ScriptRoad::GetMaintenanceCostFactor, "GetMaintenanceCostFactor", 2, ".i");
|
||||
|
||||
|
@@ -77,6 +77,7 @@ void SQGSTile_Register(Squirrel *engine)
|
||||
ScriptError::RegisterErrorMapString(ScriptTile::ERR_AREA_ALREADY_FLAT, "ERR_AREA_ALREADY_FLAT");
|
||||
ScriptError::RegisterErrorMapString(ScriptTile::ERR_EXCAVATION_WOULD_DAMAGE, "ERR_EXCAVATION_WOULD_DAMAGE");
|
||||
|
||||
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::IsBuildable, "IsBuildable", 2, ".i");
|
||||
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::IsBuildableRectangle, "IsBuildableRectangle", 4, ".iii");
|
||||
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::IsWaterTile, "IsWaterTile", 2, ".i");
|
||||
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::IsCoastTile, "IsCoastTile", 2, ".i");
|
||||
|
@@ -39,6 +39,7 @@ void SQGSTunnel_Register(Squirrel *engine)
|
||||
|
||||
SQGSTunnel.DefSQStaticMethod(engine, &ScriptTunnel::IsTunnelTile, "IsTunnelTile", 2, ".i");
|
||||
SQGSTunnel.DefSQStaticMethod(engine, &ScriptTunnel::GetOtherTunnelEnd, "GetOtherTunnelEnd", 2, ".i");
|
||||
SQGSTunnel.DefSQStaticMethod(engine, &ScriptTunnel::BuildTunnel, "BuildTunnel", 3, ".ii");
|
||||
|
||||
SQGSTunnel.PostRegister(engine);
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include "../../strings_func.h"
|
||||
#include "../../economy_func.h"
|
||||
#include "../../date_func.h"
|
||||
#include "../../company_func.h"
|
||||
|
||||
/* static */ bool ScriptBridge::IsValidBridge(BridgeID bridge_id)
|
||||
{
|
||||
@@ -74,6 +75,7 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||
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_RAIL || ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType()));
|
||||
EnforcePrecondition(false, _current_company != OWNER_DEITY || vehicle_type == ScriptVehicle::VT_ROAD);
|
||||
|
||||
uint type = 0;
|
||||
switch (vehicle_type) {
|
||||
|
@@ -135,6 +135,7 @@ public:
|
||||
* ScriptMap::GetTileY(start) == ScriptMap::GetTileY(end).
|
||||
* @pre vehicle_type == ScriptVehicle::VT_ROAD || vehicle_type == ScriptVehicle::VT_WATER ||
|
||||
* (vehicle_type == ScriptVehicle::VT_RAIL && ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType())).
|
||||
* @game @pre Outside CompanyMode: vehicle_type == ScriptVehicle::VT_ROAD.
|
||||
* @exception ScriptError::ERR_ALREADY_BUILT
|
||||
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
||||
* @exception ScriptError::ERR_LAND_SLOPED_WRONG
|
||||
@@ -143,9 +144,9 @@ public:
|
||||
* @exception ScriptBridge::ERR_BRIDGE_CANNOT_END_IN_WATER
|
||||
* @exception ScriptBridge::ERR_BRIDGE_HEADS_NOT_ON_SAME_HEIGHT
|
||||
* @return Whether the bridge has been/can be build or not.
|
||||
* @game @note Building a bridge (without CompanyMode) results in a bridge owned by towns.
|
||||
* @note No matter if the road pieces were build or not, if building the
|
||||
* bridge succeeded, this function returns true.
|
||||
* @api -game
|
||||
*/
|
||||
static bool BuildBridge(ScriptVehicle::VehicleType vehicle_type, BridgeID bridge_id, TileIndex start, TileIndex end);
|
||||
|
||||
|
@@ -265,8 +265,8 @@ public:
|
||||
* @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS
|
||||
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
||||
* @note Construction will fail if an obstacle is found between the start and end tiles.
|
||||
* @game @note Building a piece of road (without CompanyMode) results in a piece of road owned by towns.
|
||||
* @return Whether the road has been/can be build or not.
|
||||
* @api -game
|
||||
*/
|
||||
static bool BuildRoad(TileIndex start, TileIndex end);
|
||||
|
||||
@@ -317,8 +317,8 @@ public:
|
||||
* @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS
|
||||
* @exception ScriptError::ERR_VEHICLE_IN_THE_WAY
|
||||
* @note Construction will fail if an obstacle is found between the start and end tiles.
|
||||
* @game @note Building a piece of road (without CompanyMode) results in a piece of road owned by towns.
|
||||
* @return Whether the road has been/can be build or not.
|
||||
* @api -game
|
||||
*/
|
||||
static bool BuildRoadFull(TileIndex start, TileIndex end);
|
||||
|
||||
|
@@ -130,7 +130,6 @@ public:
|
||||
* as you can build tram-rails on road-tiles.
|
||||
* @note For rail you also might want to check for ScriptRoad::IsRoad(),
|
||||
* as in some cases you can build rails on road-tiles.
|
||||
* @api -game
|
||||
*/
|
||||
static bool IsBuildable(TileIndex tile);
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include "../script_instance.hpp"
|
||||
#include "../../tunnel_map.h"
|
||||
#include "../../command_func.h"
|
||||
#include "../../company_func.h"
|
||||
|
||||
/* static */ bool ScriptTunnel::IsTunnelTile(TileIndex tile)
|
||||
{
|
||||
@@ -83,6 +84,7 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance *instance)
|
||||
EnforcePrecondition(false, ::IsValidTile(start));
|
||||
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, _current_company != OWNER_DEITY || vehicle_type == ScriptVehicle::VT_ROAD);
|
||||
|
||||
uint type = 0;
|
||||
if (vehicle_type == ScriptVehicle::VT_ROAD) {
|
||||
|
@@ -87,6 +87,7 @@ public:
|
||||
* @pre ScriptMap::IsValidTile(start).
|
||||
* @pre vehicle_type == ScriptVehicle::VT_ROAD || (vehicle_type == ScriptVehicle::VT_RAIL &&
|
||||
* ScriptRail::IsRailTypeAvailable(ScriptRail::GetCurrentRailType())).
|
||||
* @game @pre Outside CompanyMode: vehicle_type == ScriptVehicle::VT_ROAD.
|
||||
* @exception ScriptError::ERR_AREA_NOT_CLEAR
|
||||
* @exception ScriptTunnel::ERR_TUNNEL_CANNOT_BUILD_ON_WATER
|
||||
* @exception ScriptTunnel::ERR_TUNNEL_START_SITE_UNSUITABLE
|
||||
@@ -96,7 +97,7 @@ public:
|
||||
* @note The slope of a tile can be determined by ScriptTile::GetSlope(TileIndex).
|
||||
* @note No matter if the road pieces were build or not, if building the
|
||||
* tunnel succeeded, this function returns true.
|
||||
* @api -game
|
||||
* @game @note Building a bridge (without CompanyMode) results in a bridge owned by towns.
|
||||
*/
|
||||
static bool BuildTunnel(ScriptVehicle::VehicleType vehicle_type, TileIndex start);
|
||||
|
||||
|
Reference in New Issue
Block a user