diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj
index afe471f141..85ea55ac60 100644
--- a/projects/openttd_vs100.vcxproj
+++ b/projects/openttd_vs100.vcxproj
@@ -886,6 +886,7 @@
+
@@ -937,6 +938,7 @@
+
diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters
index 1551a9701e..43bb5b6ef6 100644
--- a/projects/openttd_vs100.vcxproj.filters
+++ b/projects/openttd_vs100.vcxproj.filters
@@ -1881,6 +1881,9 @@
Script API
+
+ Script API
+
Script API
@@ -2034,6 +2037,9 @@
Script API Implementation
+
+ Script API Implementation
+
Script API Implementation
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 67c21a416e..896e14b04c 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -2870,6 +2870,10 @@
RelativePath=".\..\src\script\api\script_info_docs.hpp"
>
+
+
@@ -3078,6 +3082,10 @@
RelativePath=".\..\src\script\api\script_industrytypelist.cpp"
>
+
+
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index 194ac3d2d3..d17c07663a 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -2867,6 +2867,10 @@
RelativePath=".\..\src\script\api\script_info_docs.hpp"
>
+
+
@@ -3075,6 +3079,10 @@
RelativePath=".\..\src\script\api\script_industrytypelist.cpp"
>
+
+
diff --git a/source.list b/source.list
index 5b9239eb4e..4a395c4e87 100644
--- a/source.list
+++ b/source.list
@@ -660,6 +660,7 @@ script/api/script_industrylist.hpp
script/api/script_industrytype.hpp
script/api/script_industrytypelist.hpp
script/api/script_info_docs.hpp
+script/api/script_infrastructure.hpp
script/api/script_list.hpp
script/api/script_log.hpp
script/api/script_map.hpp
@@ -713,6 +714,7 @@ script/api/script_industry.cpp
script/api/script_industrylist.cpp
script/api/script_industrytype.cpp
script/api/script_industrytypelist.cpp
+script/api/script_infrastructure.cpp
script/api/script_list.cpp
script/api/script_log.cpp
script/api/script_map.cpp
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp
index 446f06756f..a3131b45be 100644
--- a/src/ai/ai_instance.cpp
+++ b/src/ai/ai_instance.cpp
@@ -53,6 +53,7 @@
#include "../script/api/ai/ai_industrylist.hpp.sq"
#include "../script/api/ai/ai_industrytype.hpp.sq"
#include "../script/api/ai/ai_industrytypelist.hpp.sq"
+#include "../script/api/ai/ai_infrastructure.hpp.sq"
#include "../script/api/ai/ai_list.hpp.sq"
#include "../script/api/ai/ai_log.hpp.sq"
#include "../script/api/ai/ai_map.hpp.sq"
@@ -153,6 +154,7 @@ void AIInstance::RegisterAPI()
SQAIIndustryList_CargoProducing_Register(this->engine);
SQAIIndustryType_Register(this->engine);
SQAIIndustryTypeList_Register(this->engine);
+ SQAIInfrastructure_Register(this->engine);
SQAILog_Register(this->engine);
SQAIMap_Register(this->engine);
SQAIMarine_Register(this->engine);
diff --git a/src/script/api/ai/ai_airport.hpp.sq b/src/script/api/ai/ai_airport.hpp.sq
index 961d3cdebb..63ee130981 100644
--- a/src/script/api/ai/ai_airport.hpp.sq
+++ b/src/script/api/ai/ai_airport.hpp.sq
@@ -51,6 +51,7 @@ void SQAIAirport_Register(Squirrel *engine)
SQAIAirport.DefSQStaticMethod(engine, &ScriptAirport::GetAirportType, "GetAirportType", 2, ".i");
SQAIAirport.DefSQStaticMethod(engine, &ScriptAirport::GetNoiseLevelIncrease, "GetNoiseLevelIncrease", 3, ".ii");
SQAIAirport.DefSQStaticMethod(engine, &ScriptAirport::GetNearestTown, "GetNearestTown", 3, ".ii");
+ SQAIAirport.DefSQStaticMethod(engine, &ScriptAirport::GetMaintenanceCostFactor, "GetMaintenanceCostFactor", 2, ".i");
SQAIAirport.PostRegister(engine);
}
diff --git a/src/script/api/ai/ai_infrastructure.hpp.sq b/src/script/api/ai/ai_infrastructure.hpp.sq
new file mode 100644
index 0000000000..55a1e4743c
--- /dev/null
+++ b/src/script/api/ai/ai_infrastructure.hpp.sq
@@ -0,0 +1,39 @@
+/* $Id$ */
+
+/*
+ * 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 .
+ */
+
+/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
+
+#include "../script_infrastructure.hpp"
+#include "../template/template_infrastructure.hpp.sq"
+
+
+template <> const char *GetClassName() { return "AIInfrastructure"; }
+
+void SQAIInfrastructure_Register(Squirrel *engine)
+{
+ DefSQClass SQAIInfrastructure("AIInfrastructure");
+ SQAIInfrastructure.PreRegister(engine);
+ SQAIInfrastructure.AddConstructor(engine, "x");
+
+ SQAIInfrastructure.DefSQConst(engine, ScriptInfrastructure::INFRASTRUCTURE_RAIL, "INFRASTRUCTURE_RAIL");
+ SQAIInfrastructure.DefSQConst(engine, ScriptInfrastructure::INFRASTRUCTURE_SIGNALS, "INFRASTRUCTURE_SIGNALS");
+ SQAIInfrastructure.DefSQConst(engine, ScriptInfrastructure::INFRASTRUCTURE_ROAD, "INFRASTRUCTURE_ROAD");
+ SQAIInfrastructure.DefSQConst(engine, ScriptInfrastructure::INFRASTRUCTURE_CANAL, "INFRASTRUCTURE_CANAL");
+ SQAIInfrastructure.DefSQConst(engine, ScriptInfrastructure::INFRASTRUCTURE_STATION, "INFRASTRUCTURE_STATION");
+ SQAIInfrastructure.DefSQConst(engine, ScriptInfrastructure::INFRASTRUCTURE_AIRPORT, "INFRASTRUCTURE_AIRPORT");
+
+ SQAIInfrastructure.DefSQStaticMethod(engine, &ScriptInfrastructure::GetRailPieceCount, "GetRailPieceCount", 3, ".ii");
+ SQAIInfrastructure.DefSQStaticMethod(engine, &ScriptInfrastructure::GetRoadPieceCount, "GetRoadPieceCount", 3, ".ii");
+ SQAIInfrastructure.DefSQStaticMethod(engine, &ScriptInfrastructure::GetInfrastructurePieceCount, "GetInfrastructurePieceCount", 3, ".ii");
+ SQAIInfrastructure.DefSQStaticMethod(engine, &ScriptInfrastructure::GetMonthlyRailCosts, "GetMonthlyRailCosts", 3, ".ii");
+ SQAIInfrastructure.DefSQStaticMethod(engine, &ScriptInfrastructure::GetMonthlyRoadCosts, "GetMonthlyRoadCosts", 3, ".ii");
+ SQAIInfrastructure.DefSQStaticMethod(engine, &ScriptInfrastructure::GetMonthlyInfrastructureCosts, "GetMonthlyInfrastructureCosts", 3, ".ii");
+
+ SQAIInfrastructure.PostRegister(engine);
+}
diff --git a/src/script/api/ai/ai_rail.hpp.sq b/src/script/api/ai/ai_rail.hpp.sq
index 85d15f0ff4..8ec22e3384 100644
--- a/src/script/api/ai/ai_rail.hpp.sq
+++ b/src/script/api/ai/ai_rail.hpp.sq
@@ -91,6 +91,7 @@ void SQAIRail_Register(Squirrel *engine)
SQAIRail.DefSQStaticMethod(engine, &ScriptRail::RemoveSignal, "RemoveSignal", 3, ".ii");
SQAIRail.DefSQStaticMethod(engine, &ScriptRail::GetBuildCost, "GetBuildCost", 3, ".ii");
SQAIRail.DefSQStaticMethod(engine, &ScriptRail::GetMaxSpeed, "GetMaxSpeed", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &ScriptRail::GetMaintenanceCostFactor, "GetMaintenanceCostFactor", 2, ".i");
SQAIRail.PostRegister(engine);
}
diff --git a/src/script/api/ai/ai_road.hpp.sq b/src/script/api/ai/ai_road.hpp.sq
index 2e8b681001..3da4607c90 100644
--- a/src/script/api/ai/ai_road.hpp.sq
+++ b/src/script/api/ai/ai_road.hpp.sq
@@ -74,6 +74,7 @@ void SQAIRoad_Register(Squirrel *engine)
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::RemoveRoadDepot, "RemoveRoadDepot", 2, ".i");
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::RemoveRoadStation, "RemoveRoadStation", 2, ".i");
SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::GetBuildCost, "GetBuildCost", 3, ".ii");
+ SQAIRoad.DefSQStaticMethod(engine, &ScriptRoad::GetMaintenanceCostFactor, "GetMaintenanceCostFactor", 2, ".i");
SQAIRoad.PostRegister(engine);
}
diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp
index d69af43247..28e30ccf72 100644
--- a/src/script/api/ai_changelog.hpp
+++ b/src/script/api/ai_changelog.hpp
@@ -21,6 +21,7 @@
*
* API additions:
*
+ * \li AIAirport::GetMaintenanceCostFactor
* \li AICargo::CT_AUTO_REFIT
* \li AICargo::CT_NO_REFIT
* \li AICargo::IsValidTownEffect
@@ -32,9 +33,12 @@
* \li AICompany::GetQuarterlyCompanyValue
* \li AIController::GetOpsTillSuspend
* \li AIInfo::CONFIG_DEVELOPER
+ * \li AIInfrastructure
* \li AIOrder::GetOrderRefit
* \li AIOrder::IsRefitOrder
* \li AIOrder::SetOrderRefit
+ * \li AIRail::GetMaintenanceCostFactor
+ * \li AIRoad::GetMaintenanceCostFactor
* \li AITown::GetCargoGoal
* \li AITown::GetGrowthRate
* \li AITown::GetLastMonthReceived
diff --git a/src/script/api/script_airport.cpp b/src/script/api/script_airport.cpp
index fbc763cb16..a1364d7af1 100644
--- a/src/script/api/script_airport.cpp
+++ b/src/script/api/script_airport.cpp
@@ -151,3 +151,10 @@
return AirportGetNearestTown(AirportSpec::Get(type), tile)->index;
}
+
+/* static */ uint16 ScriptAirport::GetMaintenanceCostFactor(AirportType type)
+{
+ if (!IsAirportInformationAvailable(type)) return INVALID_TOWN;
+
+ return AirportSpec::Get(type)->maintenance_cost;
+}
diff --git a/src/script/api/script_airport.hpp b/src/script/api/script_airport.hpp
index d382e643be..6dc2fca505 100644
--- a/src/script/api/script_airport.hpp
+++ b/src/script/api/script_airport.hpp
@@ -193,6 +193,14 @@ public:
* @return The TownID of the town closest to the tile.
*/
static TownID GetNearestTown(TileIndex tile, AirportType type);
+
+ /**
+ * Get the maintenance cost factor of an airport type.
+ * @param type The airport type to get the maintenance factor of.
+ * @pre IsAirportInformationAvailable(type)
+ * @return Maintenance cost factor of the airport type.
+ */
+ static uint16 GetMaintenanceCostFactor(AirportType type);
};
#endif /* SCRIPT_AIRPORT_HPP */
diff --git a/src/script/api/script_infrastructure.cpp b/src/script/api/script_infrastructure.cpp
new file mode 100644
index 0000000000..2e318f1e53
--- /dev/null
+++ b/src/script/api/script_infrastructure.cpp
@@ -0,0 +1,132 @@
+/* $Id$ */
+
+/*
+ * 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 .
+ */
+
+/** @file script_infrastructure.cpp Implementation of ScriptInfrastructure. */
+
+#include "../../stdafx.h"
+#include "script_infrastructure.hpp"
+#include "../../settings_func.h"
+#include "../../company_base.h"
+#include "../../rail.h"
+#include "../../road_func.h"
+#include "../../water.h"
+#include "../../station_func.h"
+
+
+/* static */ uint32 ScriptInfrastructure::GetRailPieceCount(ScriptCompany::CompanyID company, ScriptRail::RailType railtype)
+{
+ company = ScriptCompany::ResolveCompanyID(company);
+ if (company == ScriptCompany::COMPANY_INVALID || (::RailType)railtype >= RAILTYPE_END) return 0;
+
+ return ::Company::Get((::CompanyID)company)->infrastructure.rail[railtype];
+}
+
+/* static */ uint32 ScriptInfrastructure::GetRoadPieceCount(ScriptCompany::CompanyID company, ScriptRoad::RoadType roadtype)
+{
+ company = ScriptCompany::ResolveCompanyID(company);
+ if (company == ScriptCompany::COMPANY_INVALID || (::RoadType)roadtype >= ROADTYPE_END) return 0;
+
+ return ::Company::Get((::CompanyID)company)->infrastructure.road[roadtype];
+}
+
+/* static */ uint32 ScriptInfrastructure::GetInfrastructurePieceCount(ScriptCompany::CompanyID company, Infrastructure infra_type)
+{
+ company = ScriptCompany::ResolveCompanyID(company);
+ if (company == ScriptCompany::COMPANY_INVALID) return 0;
+
+ ::Company *c = ::Company::Get((::CompanyID)company);
+ switch (infra_type) {
+ case INFRASTRUCTURE_RAIL: {
+ uint32 count = 0;
+ for (::RailType rt = ::RAILTYPE_BEGIN; rt != ::RAILTYPE_END; rt++) {
+ count += c->infrastructure.rail[rt];
+ }
+ return count;
+ }
+
+ case INFRASTRUCTURE_SIGNALS:
+ return c->infrastructure.signal;
+
+ case INFRASTRUCTURE_ROAD: {
+ uint32 count = 0;
+ for (::RoadType rt = ::ROADTYPE_BEGIN; rt != ::ROADTYPE_END; rt++) {
+ count += c->infrastructure.road[rt];
+ }
+ return count;
+ }
+
+ case INFRASTRUCTURE_CANAL:
+ return c->infrastructure.water;
+
+ case INFRASTRUCTURE_STATION:
+ return c->infrastructure.station;
+
+ case INFRASTRUCTURE_AIRPORT:
+ return c->infrastructure.airport;
+
+ default:
+ return 0;
+ }
+}
+
+/* static */ Money ScriptInfrastructure::GetMonthlyRailCosts(ScriptCompany::CompanyID company, ScriptRail::RailType railtype)
+{
+ company = ScriptCompany::ResolveCompanyID(company);
+ if (company == ScriptCompany::COMPANY_INVALID || (::RailType)railtype >= RAILTYPE_END || !_settings_game.economy.infrastructure_maintenance) return 0;
+
+ return ::RailMaintenanceCost((::RailType)railtype, ::Company::Get((::CompanyID)company)->infrastructure.rail[railtype]);
+}
+
+/* static */ Money ScriptInfrastructure::GetMonthlyRoadCosts(ScriptCompany::CompanyID company, ScriptRoad::RoadType roadtype)
+{
+ company = ScriptCompany::ResolveCompanyID(company);
+ if (company == ScriptCompany::COMPANY_INVALID || (::RoadType)roadtype >= ROADTYPE_END || !_settings_game.economy.infrastructure_maintenance) return 0;
+
+ return ::RoadMaintenanceCost((::RoadType)roadtype, ::Company::Get((::CompanyID)company)->infrastructure.road[roadtype]);
+}
+
+/* static */ Money ScriptInfrastructure::GetMonthlyInfrastructureCosts(ScriptCompany::CompanyID company, Infrastructure infra_type)
+{
+ company = ScriptCompany::ResolveCompanyID(company);
+ if (company == ScriptCompany::COMPANY_INVALID || !_settings_game.economy.infrastructure_maintenance) return 0;
+
+ ::Company *c = ::Company::Get((::CompanyID)company);
+ switch (infra_type) {
+ case INFRASTRUCTURE_RAIL: {
+ Money cost;
+ for (::RailType rt = ::RAILTYPE_BEGIN; rt != ::RAILTYPE_END; rt++) {
+ cost += RailMaintenanceCost(rt, c->infrastructure.rail[rt]);
+ }
+ return cost;
+ }
+
+ case INFRASTRUCTURE_SIGNALS:
+ return SignalMaintenanceCost(c->infrastructure.signal);
+
+ case INFRASTRUCTURE_ROAD: {
+ Money cost;
+ for (::RoadType rt = ::ROADTYPE_BEGIN; rt != ::ROADTYPE_END; rt++) {
+ cost += RoadMaintenanceCost(rt, c->infrastructure.road[rt]);
+ }
+ return cost;
+ }
+
+ case INFRASTRUCTURE_CANAL:
+ return CanalMaintenanceCost(c->infrastructure.water);
+
+ case INFRASTRUCTURE_STATION:
+ return StationMaintenanceCost(c->infrastructure.station);
+
+ case INFRASTRUCTURE_AIRPORT:
+ return AirportMaintenanceCost(c->index);
+
+ default:
+ return 0;
+ }
+}
diff --git a/src/script/api/script_infrastructure.hpp b/src/script/api/script_infrastructure.hpp
new file mode 100644
index 0000000000..84728092e6
--- /dev/null
+++ b/src/script/api/script_infrastructure.hpp
@@ -0,0 +1,86 @@
+/* $Id$ */
+
+/*
+ * 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 .
+ */
+
+/** @file script_infrastructure.hpp Everything to query a company's infrastructure. */
+
+#ifndef SCRIPT_INFRASTRUCTURE_HPP
+#define SCRIPT_INFRASTRUCTURE_HPP
+
+#include "script_object.hpp"
+#include "script_road.hpp"
+#include "script_rail.hpp"
+
+/**
+ * Class that handles all company infrastructure related functions.
+ * @api ai
+ */
+class ScriptInfrastructure : public ScriptObject {
+public:
+ /** Infrastructure categories. */
+ enum Infrastructure {
+ INFRASTRUCTURE_RAIL, ///< Rail infrastructure.
+ INFRASTRUCTURE_SIGNALS, ///< Signal infrastructure.
+ INFRASTRUCTURE_ROAD, ///< Road infrastructure.
+ INFRASTRUCTURE_CANAL, ///< Canal infrastructure.
+ INFRASTRUCTURE_STATION, ///< Station infrastructure.
+ INFRASTRUCTURE_AIRPORT, ///< Airport infrastructure.
+ };
+
+ /**
+ * Return the number of rail pieces of a specific rail type for a company.
+ * @param company The company to get the count for.
+ * @param railtype Rail type to get the count of.
+ * @return Count for the rail type.
+ */
+ static uint32 GetRailPieceCount(ScriptCompany::CompanyID company, ScriptRail::RailType railtype);
+
+ /**
+ * Return the number of road pieces of a specific road type for a company.
+ * @param company The company to get the count for.
+ * @param roadtype Road type to get the count of.
+ * @return Count for the road type.
+ */
+ static uint32 GetRoadPieceCount(ScriptCompany::CompanyID company, ScriptRoad::RoadType roadtype);
+
+ /**
+ * Return the number of pieces of an infrastructure category for a company.
+ * @param company The company to get the count for.
+ * @param infra_type Infrastructure category to get the cost of.
+ * @return Count for the wanted category.
+ * @note #INFRASTRUCTURE_RAIL and #INFRASTRUCTURE_ROAD return the total count for all rail/road types.
+ */
+ static uint32 GetInfrastructurePieceCount(ScriptCompany::CompanyID company, Infrastructure infra_type);
+
+ /**
+ * Return the monthly maintenance costs of a specific rail type for a company.
+ * @param company The company to get the monthly cost for.
+ * @param railtype Rail type to get the cost of.
+ * @return Monthly maintenance cost for the rail type.
+ */
+ static Money GetMonthlyRailCosts(ScriptCompany::CompanyID company, ScriptRail::RailType railtype);
+
+ /**
+ * Return the monthly maintenance costs of a specific road type for a company.
+ * @param company The company to get the monthly cost for.
+ * @param roadtype Road type to get the cost of.
+ * @return Monthly maintenance cost for the road type.
+ */
+ static Money GetMonthlyRoadCosts(ScriptCompany::CompanyID company, ScriptRoad::RoadType roadtype);
+
+ /**
+ * Return the monthly maintenance costs of an infrastructure category for a company.
+ * @param company The company to get the monthly cost for.
+ * @param infra_type Infrastructure category to get the cost of.
+ * @return Monthly maintenance cost for the wanted category.
+ * @note #INFRASTRUCTURE_RAIL and #INFRASTRUCTURE_ROAD return the total cost for all rail/road types.
+ */
+ static Money GetMonthlyInfrastructureCosts(ScriptCompany::CompanyID company, Infrastructure infra_type);
+};
+
+#endif /* SCRIPT_INFRASTRUCTURE_HPP */
diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp
index 1ebeb74ecd..6f0ce7255b 100644
--- a/src/script/api/script_rail.cpp
+++ b/src/script/api/script_rail.cpp
@@ -492,3 +492,10 @@ static bool IsValidSignalType(int signal_type)
return ::GetRailTypeInfo((::RailType)railtype)->max_speed;
}
+
+/* static */ uint16 ScriptRail::GetMaintenanceCostFactor(RailType railtype)
+{
+ if (!ScriptRail::IsRailTypeAvailable(railtype)) return 0;
+
+ return ::GetRailTypeInfo((::RailType)railtype)->maintenance_multiplier;
+}
diff --git a/src/script/api/script_rail.hpp b/src/script/api/script_rail.hpp
index b7d7db9236..96d673af62 100644
--- a/src/script/api/script_rail.hpp
+++ b/src/script/api/script_rail.hpp
@@ -464,6 +464,14 @@ public:
* To get km/h multiply this number by 1.00584.
*/
static int32 GetMaxSpeed(RailType railtype);
+
+ /**
+ * Get the maintenance cost factor of a railtype.
+ * @param railtype The railtype to get the maintenance factor of.
+ * @pre IsRailTypeAvailable(railtype)
+ * @return Maintenance cost factor of the railtype.
+ */
+ static uint16 GetMaintenanceCostFactor(RailType railtype);
};
#endif /* SCRIPT_RAIL_HPP */
diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp
index 06991e5acd..806d00130e 100644
--- a/src/script/api/script_road.cpp
+++ b/src/script/api/script_road.cpp
@@ -581,3 +581,10 @@ static bool NeighbourHasReachableRoad(::RoadTypes rts, TileIndex start_tile, Dia
default: return -1;
}
}
+
+/* static */ uint16 ScriptRoad::GetMaintenanceCostFactor(RoadType roadtype)
+{
+ if (!ScriptRoad::IsRoadTypeAvailable(roadtype)) return 0;
+
+ return roadtype == ROADTYPE_TRAM ? 3 : 2;
+}
diff --git a/src/script/api/script_road.hpp b/src/script/api/script_road.hpp
index 1139adafb5..fe855c0bbd 100644
--- a/src/script/api/script_road.hpp
+++ b/src/script/api/script_road.hpp
@@ -471,6 +471,14 @@ public:
*/
static Money GetBuildCost(RoadType roadtype, BuildType build_type);
+ /**
+ * Get the maintenance cost factor of a roadtype.
+ * @param railtype The roadtype to get the maintenance factor of.
+ * @pre IsRoadTypeAvailable(roadtype)
+ * @return Maintenance cost factor of the roadtype.
+ */
+ static uint16 GetMaintenanceCostFactor(RoadType roadtype);
+
private:
/**
diff --git a/src/script/api/template/template_infrastructure.hpp.sq b/src/script/api/template/template_infrastructure.hpp.sq
new file mode 100644
index 0000000000..39460e1406
--- /dev/null
+++ b/src/script/api/template/template_infrastructure.hpp.sq
@@ -0,0 +1,25 @@
+/* $Id$ */
+
+/*
+ * 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 .
+ */
+
+/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
+
+#include "../script_infrastructure.hpp"
+
+namespace SQConvert {
+ /* Allow enums to be used as Squirrel parameters */
+ template <> inline ScriptInfrastructure::Infrastructure GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptInfrastructure::Infrastructure)tmp; }
+ template <> inline int Return(HSQUIRRELVM vm, ScriptInfrastructure::Infrastructure res) { sq_pushinteger(vm, (int32)res); return 1; }
+
+ /* Allow ScriptInfrastructure to be used as Squirrel parameter */
+ template <> inline ScriptInfrastructure *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptInfrastructure *)instance; }
+ template <> inline ScriptInfrastructure &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptInfrastructure *)instance; }
+ template <> inline const ScriptInfrastructure *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptInfrastructure *)instance; }
+ template <> inline const ScriptInfrastructure &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptInfrastructure *)instance; }
+ template <> inline int Return(HSQUIRRELVM vm, ScriptInfrastructure *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Infrastructure", res, NULL, DefSQDestructorCallback, true); return 1; }
+} // namespace SQConvert