summaryrefslogtreecommitdiff
path: root/src/script/api
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-12-03 23:40:57 +0000
committermichi_cc <michi_cc@openttd.org>2011-12-03 23:40:57 +0000
commit0e5e8fff12a3c91f0198afb25c03eb71b2248005 (patch)
tree235af65c5215b3417adad3be39b39ad8e85208b0 /src/script/api
parentd3b7b89493e025654d218fb77da095649b4f6ba2 (diff)
downloadopenttd-0e5e8fff12a3c91f0198afb25c03eb71b2248005.tar.xz
(svn r23416) -Add: [NoAI] API for querying infrastructure costs.
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/ai/ai_airport.hpp.sq1
-rw-r--r--src/script/api/ai/ai_infrastructure.hpp.sq39
-rw-r--r--src/script/api/ai/ai_rail.hpp.sq1
-rw-r--r--src/script/api/ai/ai_road.hpp.sq1
-rw-r--r--src/script/api/ai_changelog.hpp4
-rw-r--r--src/script/api/script_airport.cpp7
-rw-r--r--src/script/api/script_airport.hpp8
-rw-r--r--src/script/api/script_infrastructure.cpp132
-rw-r--r--src/script/api/script_infrastructure.hpp86
-rw-r--r--src/script/api/script_rail.cpp7
-rw-r--r--src/script/api/script_rail.hpp8
-rw-r--r--src/script/api/script_road.cpp7
-rw-r--r--src/script/api/script_road.hpp8
-rw-r--r--src/script/api/template/template_infrastructure.hpp.sq25
14 files changed, 334 insertions, 0 deletions
diff --git a/src/script/api/ai/ai_airport.hpp.sq b/src/script/api/ai/ai_airport.hpp.sq
index 961d3cdeb..63ee13098 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 000000000..55a1e4743
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
+
+#include "../script_infrastructure.hpp"
+#include "../template/template_infrastructure.hpp.sq"
+
+
+template <> const char *GetClassName<ScriptInfrastructure, ST_AI>() { return "AIInfrastructure"; }
+
+void SQAIInfrastructure_Register(Squirrel *engine)
+{
+ DefSQClass<ScriptInfrastructure, ST_AI> SQAIInfrastructure("AIInfrastructure");
+ SQAIInfrastructure.PreRegister(engine);
+ SQAIInfrastructure.AddConstructor<void (ScriptInfrastructure::*)(), 1>(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 85d15f0ff..8ec22e338 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 2e8b68100..3da4607c9 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 d69af4324..28e30ccf7 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 fbc763cb1..a1364d7af 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 d382e643b..6dc2fca50 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 000000000..2e318f1e5
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+/** @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 000000000..84728092e
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+/** @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 1ebeb74ec..6f0ce7255 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 b7d7db923..96d673af6 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 06991e5ac..806d00130 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 1139adafb..fe855c0bb 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 000000000..39460e140
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+/* 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<ScriptInfrastructure::Infrastructure>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptInfrastructure::Infrastructure)tmp; }
+ template <> inline int Return<ScriptInfrastructure::Infrastructure>(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<ScriptInfrastructure *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptInfrastructure *)instance; }
+ template <> inline ScriptInfrastructure &GetParam(ForceType<ScriptInfrastructure &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptInfrastructure *)instance; }
+ template <> inline const ScriptInfrastructure *GetParam(ForceType<const ScriptInfrastructure *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptInfrastructure *)instance; }
+ template <> inline const ScriptInfrastructure &GetParam(ForceType<const ScriptInfrastructure &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptInfrastructure *)instance; }
+ template <> inline int Return<ScriptInfrastructure *>(HSQUIRRELVM vm, ScriptInfrastructure *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Infrastructure", res, NULL, DefSQDestructorCallback<ScriptInfrastructure>, true); return 1; }
+} // namespace SQConvert