(svn r26396) -Add: [script] AI/GS APIs to get cargo waiting from/via other station

This commit is contained in:
zuu 2014-03-10 22:18:53 +00:00
parent 51501be48f
commit ae23f519f7
11 changed files with 156 additions and 50 deletions

View File

@ -21,32 +21,37 @@ void SQAICargo_Register(Squirrel *engine)
SQAICargo.PreRegister(engine);
SQAICargo.AddConstructor<void (ScriptCargo::*)(), 1>(engine, "x");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_PASSENGERS, "CC_PASSENGERS");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_MAIL, "CC_MAIL");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_EXPRESS, "CC_EXPRESS");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_ARMOURED, "CC_ARMOURED");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_BULK, "CC_BULK");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_PIECE_GOODS, "CC_PIECE_GOODS");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_LIQUID, "CC_LIQUID");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_REFRIGERATED, "CC_REFRIGERATED");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_HAZARDOUS, "CC_HAZARDOUS");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_COVERED, "CC_COVERED");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_NONE, "TE_NONE");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_PASSENGERS, "TE_PASSENGERS");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_MAIL, "TE_MAIL");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_GOODS, "TE_GOODS");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_WATER, "TE_WATER");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_FOOD, "TE_FOOD");
SQAICargo.DefSQConst(engine, ScriptCargo::CT_AUTO_REFIT, "CT_AUTO_REFIT");
SQAICargo.DefSQConst(engine, ScriptCargo::CT_NO_REFIT, "CT_NO_REFIT");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_PASSENGERS, "CC_PASSENGERS");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_MAIL, "CC_MAIL");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_EXPRESS, "CC_EXPRESS");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_ARMOURED, "CC_ARMOURED");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_BULK, "CC_BULK");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_PIECE_GOODS, "CC_PIECE_GOODS");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_LIQUID, "CC_LIQUID");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_REFRIGERATED, "CC_REFRIGERATED");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_HAZARDOUS, "CC_HAZARDOUS");
SQAICargo.DefSQConst(engine, ScriptCargo::CC_COVERED, "CC_COVERED");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_NONE, "TE_NONE");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_PASSENGERS, "TE_PASSENGERS");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_MAIL, "TE_MAIL");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_GOODS, "TE_GOODS");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_WATER, "TE_WATER");
SQAICargo.DefSQConst(engine, ScriptCargo::TE_FOOD, "TE_FOOD");
SQAICargo.DefSQConst(engine, ScriptCargo::CT_AUTO_REFIT, "CT_AUTO_REFIT");
SQAICargo.DefSQConst(engine, ScriptCargo::CT_NO_REFIT, "CT_NO_REFIT");
SQAICargo.DefSQConst(engine, ScriptCargo::DT_MANUAL, "DT_MANUAL");
SQAICargo.DefSQConst(engine, ScriptCargo::DT_ASYMMETRIC, "DT_ASYMMETRIC");
SQAICargo.DefSQConst(engine, ScriptCargo::DT_SYMMETRIC, "DT_SYMMETRIC");
SQAICargo.DefSQConst(engine, ScriptCargo::INVALID_DISTRIBUTION_TYPE, "INVALID_DISTRIBUTION_TYPE");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::IsValidCargo, "IsValidCargo", 2, ".i");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::IsValidTownEffect, "IsValidTownEffect", 2, ".i");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::GetCargoLabel, "GetCargoLabel", 2, ".i");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::IsFreight, "IsFreight", 2, ".i");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::HasCargoClass, "HasCargoClass", 3, ".ii");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::GetTownEffect, "GetTownEffect", 2, ".i");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::GetCargoIncome, "GetCargoIncome", 4, ".iii");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::IsValidCargo, "IsValidCargo", 2, ".i");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::IsValidTownEffect, "IsValidTownEffect", 2, ".i");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::GetCargoLabel, "GetCargoLabel", 2, ".i");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::IsFreight, "IsFreight", 2, ".i");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::HasCargoClass, "HasCargoClass", 3, ".ii");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::GetTownEffect, "GetTownEffect", 2, ".i");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::GetCargoIncome, "GetCargoIncome", 4, ".iii");
SQAICargo.DefSQStaticMethod(engine, &ScriptCargo::GetDistributionType, "GetDistributionType", 2, ".i");
SQAICargo.PostRegister(engine);
}

View File

@ -47,6 +47,8 @@ void SQAIStation_Register(Squirrel *engine)
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::IsValidStation, "IsValidStation", 2, ".i");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetStationID, "GetStationID", 2, ".i");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetCargoWaiting, "GetCargoWaiting", 3, ".ii");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetCargoWaitingFrom, "GetCargoWaitingFrom", 4, ".iii");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetCargoWaitingVia, "GetCargoWaitingVia", 4, ".iii");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::HasCargoRating, "HasCargoRating", 3, ".ii");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetCargoRating, "GetCargoRating", 3, ".ii");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetCoverageRadius, "GetCoverageRadius", 2, ".i");

View File

@ -20,9 +20,12 @@
* 1.4.0 is not yet released. The following changes are not set in stone yet.
*
* API additions:
* \li AICargo::GetDistributionType
* \li AIDate::DATE_INVALID
* \li AIDate::IsValidDate
* \li AIStation::HasCargoRating
* \li AIStation::GetCargoWaitingFrom
* \li AIStation::GetCargoWaitingVia
* \li AITile::GetTerrainType
* \li AITown::FoundTown
* \li AITown::GetFundBuildingsDuration

View File

@ -21,32 +21,37 @@ void SQGSCargo_Register(Squirrel *engine)
SQGSCargo.PreRegister(engine);
SQGSCargo.AddConstructor<void (ScriptCargo::*)(), 1>(engine, "x");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_PASSENGERS, "CC_PASSENGERS");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_MAIL, "CC_MAIL");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_EXPRESS, "CC_EXPRESS");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_ARMOURED, "CC_ARMOURED");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_BULK, "CC_BULK");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_PIECE_GOODS, "CC_PIECE_GOODS");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_LIQUID, "CC_LIQUID");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_REFRIGERATED, "CC_REFRIGERATED");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_HAZARDOUS, "CC_HAZARDOUS");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_COVERED, "CC_COVERED");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_NONE, "TE_NONE");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_PASSENGERS, "TE_PASSENGERS");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_MAIL, "TE_MAIL");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_GOODS, "TE_GOODS");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_WATER, "TE_WATER");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_FOOD, "TE_FOOD");
SQGSCargo.DefSQConst(engine, ScriptCargo::CT_AUTO_REFIT, "CT_AUTO_REFIT");
SQGSCargo.DefSQConst(engine, ScriptCargo::CT_NO_REFIT, "CT_NO_REFIT");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_PASSENGERS, "CC_PASSENGERS");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_MAIL, "CC_MAIL");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_EXPRESS, "CC_EXPRESS");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_ARMOURED, "CC_ARMOURED");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_BULK, "CC_BULK");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_PIECE_GOODS, "CC_PIECE_GOODS");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_LIQUID, "CC_LIQUID");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_REFRIGERATED, "CC_REFRIGERATED");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_HAZARDOUS, "CC_HAZARDOUS");
SQGSCargo.DefSQConst(engine, ScriptCargo::CC_COVERED, "CC_COVERED");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_NONE, "TE_NONE");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_PASSENGERS, "TE_PASSENGERS");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_MAIL, "TE_MAIL");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_GOODS, "TE_GOODS");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_WATER, "TE_WATER");
SQGSCargo.DefSQConst(engine, ScriptCargo::TE_FOOD, "TE_FOOD");
SQGSCargo.DefSQConst(engine, ScriptCargo::CT_AUTO_REFIT, "CT_AUTO_REFIT");
SQGSCargo.DefSQConst(engine, ScriptCargo::CT_NO_REFIT, "CT_NO_REFIT");
SQGSCargo.DefSQConst(engine, ScriptCargo::DT_MANUAL, "DT_MANUAL");
SQGSCargo.DefSQConst(engine, ScriptCargo::DT_ASYMMETRIC, "DT_ASYMMETRIC");
SQGSCargo.DefSQConst(engine, ScriptCargo::DT_SYMMETRIC, "DT_SYMMETRIC");
SQGSCargo.DefSQConst(engine, ScriptCargo::INVALID_DISTRIBUTION_TYPE, "INVALID_DISTRIBUTION_TYPE");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::IsValidCargo, "IsValidCargo", 2, ".i");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::IsValidTownEffect, "IsValidTownEffect", 2, ".i");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::GetCargoLabel, "GetCargoLabel", 2, ".i");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::IsFreight, "IsFreight", 2, ".i");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::HasCargoClass, "HasCargoClass", 3, ".ii");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::GetTownEffect, "GetTownEffect", 2, ".i");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::GetCargoIncome, "GetCargoIncome", 4, ".iii");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::IsValidCargo, "IsValidCargo", 2, ".i");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::IsValidTownEffect, "IsValidTownEffect", 2, ".i");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::GetCargoLabel, "GetCargoLabel", 2, ".i");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::IsFreight, "IsFreight", 2, ".i");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::HasCargoClass, "HasCargoClass", 3, ".ii");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::GetTownEffect, "GetTownEffect", 2, ".i");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::GetCargoIncome, "GetCargoIncome", 4, ".iii");
SQGSCargo.DefSQStaticMethod(engine, &ScriptCargo::GetDistributionType, "GetDistributionType", 2, ".i");
SQGSCargo.PostRegister(engine);
}

View File

@ -48,6 +48,8 @@ void SQGSStation_Register(Squirrel *engine)
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::GetOwner, "GetOwner", 2, ".i");
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::GetStationID, "GetStationID", 2, ".i");
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::GetCargoWaiting, "GetCargoWaiting", 3, ".ii");
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::GetCargoWaitingFrom, "GetCargoWaitingFrom", 4, ".iii");
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::GetCargoWaitingVia, "GetCargoWaitingVia", 4, ".iii");
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::HasCargoRating, "HasCargoRating", 3, ".ii");
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::GetCargoRating, "GetCargoRating", 3, ".ii");
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::GetCoverageRadius, "GetCoverageRadius", 2, ".i");

View File

@ -20,6 +20,7 @@
* 1.4.0 is not yet released. The following changes are not set in stone yet.
*
* API additions:
* \li AICargo::GetDistributionType
* \li GSCompany::ChangeBankBalance
* \li GSDate::DATE_INVALID
* \li GSDate::IsValidDate
@ -29,6 +30,8 @@
* \li GSGoal::SetProgress
* \li GSGoal::SetText
* \li GSStation::HasCargoRating
* \li AIStation::GetCargoWaitingFrom
* \li AIStation::GetCargoWaitingVia
* \li GSStoryPage
* \li GSStoryPageList
* \li GSStoryPageElementList

View File

@ -13,6 +13,7 @@
#include "script_cargo.hpp"
#include "../../economy_func.h"
#include "../../core/bitmath_func.hpp"
#include "../../settings_type.h"
/* static */ bool ScriptCargo::IsValidCargo(CargoID cargo_type)
{
@ -64,3 +65,9 @@
if (!IsValidCargo(cargo_type)) return -1;
return ::GetTransportedGoodsIncome(1, distance, Clamp(days_in_transit * 2 / 5, 0, 255), cargo_type);
}
/* static */ ScriptCargo::DistributionType ScriptCargo::GetDistributionType(CargoID cargo_type)
{
if (!ScriptCargo::IsValidCargo(cargo_type)) return INVALID_DISTRIBUTION_TYPE;
return (ScriptCargo::DistributionType)_settings_game.linkgraph.GetDistributionType(cargo_type);
}

View File

@ -14,6 +14,7 @@
#include "script_object.hpp"
#include "../../cargotype.h"
#include "../../linkgraph/linkgraph_type.h"
/**
* Class that handles all cargo related functions.
@ -60,6 +61,16 @@ public:
CT_NO_REFIT = ::CT_NO_REFIT, ///< Do not refit cargo of a vehicle.
};
/**
* Type of cargo distribution.
*/
enum DistributionType {
DT_MANUAL = ::DT_MANUAL, ///< Manual distribution.
DT_ASYMMETRIC = ::DT_ASYMMETRIC, ///< Asymmetric distribution. Usually cargo will only travel in one direction.
DT_SYMMETRIC = ::DT_SYMMETRIC, ///< Symmetric distribution. The same amount of cargo travels in each direction between each pair of nodes.
INVALID_DISTRIBUTION_TYPE = 0xFFFF, ///< Invalid distribution type.
};
/**
* Checks whether the given cargo type is valid.
* @param cargo_type The cargo to check.
@ -121,6 +132,13 @@ public:
* @return The amount of money that would be earned by this trip.
*/
static Money GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit);
/**
* Get the cargo distribution type for a cargo.
* @param cargo_type The cargo to check on.
* @return The cargo distribution type for the given cargo.
*/
static DistributionType GetDistributionType(CargoID cargo_type);
};
#endif /* SCRIPT_CARGO_HPP */

View File

@ -13,6 +13,7 @@
#include "script_station.hpp"
#include "script_map.hpp"
#include "script_town.hpp"
#include "script_cargo.hpp"
#include "../../station_base.h"
#include "../../roadstop_base.h"
#include "../../town.h"
@ -44,6 +45,39 @@
return ::Station::Get(station_id)->goods[cargo_id].cargo.TotalCount();
}
/* static */ int32 ScriptStation::GetCargoWaitingFrom(StationID station_id, StationID from_station_id, CargoID cargo_id)
{
if (!IsValidStation(station_id)) return -1;
if (!IsValidStation(from_station_id) && from_station_id != STATION_INVALID) return -1;
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
const StationCargoList &cargo_list = ::Station::Get(station_id)->goods[cargo_id].cargo;
uint16 cargo_count = 0;
for (StationCargoList::ConstIterator it = cargo_list.Packets()->begin(); it != cargo_list.Packets()->end(); it++) {
CargoPacket *cp = *it;
if (cp->SourceStation() == from_station_id) cargo_count += cp->Count();
}
return cargo_count;
}
/* static */ int32 ScriptStation::GetCargoWaitingVia(StationID station_id, StationID via_station_id, CargoID cargo_id)
{
if (!IsValidStation(station_id)) return -1;
if (!IsValidStation(via_station_id) && via_station_id != STATION_INVALID) return -1;
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
const StationCargoList &cargo_list = ::Station::Get(station_id)->goods[cargo_id].cargo;
uint16 cargo_count = 0;
std::pair<StationCargoList::ConstIterator, StationCargoList::ConstIterator> range = cargo_list.Packets()->equal_range(via_station_id);
for (StationCargoList::ConstIterator it = range.first; it != range.second; it++) {
CargoPacket *cp = *it;
cargo_count += cp->Count();
}
return cargo_count;
}
/* static */ bool ScriptStation::HasCargoRating(StationID station_id, CargoID cargo_id)
{
if (!IsValidStation(station_id)) return false;

View File

@ -86,6 +86,31 @@ public:
*/
static int32 GetCargoWaiting(StationID station_id, CargoID cargo_id);
/**
* See how much cargo with a specific source station there is waiting on a station.
* @param station_id The station to get the cargo-waiting of.
* @param cargo_id The cargo to get the cargo-waiting of.
* @pre IsValidStation(station_id).
* @pre IsValidStation(from_station_id) || from_station_id == STATION_INVALID.
* @pre IsValidCargo(cargo_id).
* @return The amount of units waiting at the station originating from from_station_id.
* @note source station means, the station where cargo was first loaded.
*/
static int32 GetCargoWaitingFrom(StationID station_id, StationID from_station_id, CargoID cargo_id);
/**
* See how much cargo with a specific via-station there is waiting on a station.
* @param station_id The station to get the cargo-waiting of, or pass STATION_INVALID to get waiting cargo for "via any station".
* @param cargo_id The cargo to get the cargo-waiting of.
* @pre IsValidStation(station_id).
* @pre IsValidStation(via_station_id) || via_station_id == STATION_INVALID.
* @pre IsValidCargo(cargo_id).
* @return The amount of units waiting at the station with via_station_id as next hop.
* @note if ScriptCargo.GetCargoDistributionType(cargo_id) == ScriptCargo.DT_MANUAL, then all waiting cargo will have STATION_INVALID as next hop.
*/
static int32 GetCargoWaitingVia(StationID station_id, StationID via_station_id, CargoID cargo_id);
/**
* Check whether the given cargo at the given station a rating.
* @param station_id The station to get the cargo-rating state of.

View File

@ -19,6 +19,8 @@ namespace SQConvert {
template <> inline int Return<ScriptCargo::TownEffect>(HSQUIRRELVM vm, ScriptCargo::TownEffect res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> inline ScriptCargo::SpecialCargoID GetParam(ForceType<ScriptCargo::SpecialCargoID>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptCargo::SpecialCargoID)tmp; }
template <> inline int Return<ScriptCargo::SpecialCargoID>(HSQUIRRELVM vm, ScriptCargo::SpecialCargoID res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> inline ScriptCargo::DistributionType GetParam(ForceType<ScriptCargo::DistributionType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptCargo::DistributionType)tmp; }
template <> inline int Return<ScriptCargo::DistributionType>(HSQUIRRELVM vm, ScriptCargo::DistributionType res) { sq_pushinteger(vm, (int32)res); return 1; }
/* Allow ScriptCargo to be used as Squirrel parameter */
template <> inline ScriptCargo *GetParam(ForceType<ScriptCargo *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptCargo *)instance; }