From 2128f1e92906563fc7237b8a43f6fa723de70e7c Mon Sep 17 00:00:00 2001 From: fonsinchen Date: Sun, 21 Sep 2014 16:20:48 +0000 Subject: (svn r26893) -Feature: ScriptStationList_Cargo for sorting cargo by from and via --- src/ai/ai_instance.cpp | 11 + src/game/game_instance.cpp | 11 + src/script/api/ai/ai_stationlist.hpp.sq | 139 ++++++++++++ src/script/api/ai_changelog.hpp | 8 + src/script/api/game/game_stationlist.hpp.sq | 139 ++++++++++++ src/script/api/game_changelog.hpp | 8 + src/script/api/script_stationlist.cpp | 238 ++++++++++++++++++++ src/script/api/script_stationlist.hpp | 245 +++++++++++++++++++++ .../api/template/template_stationlist.hpp.sq | 105 +++++++++ 9 files changed, 904 insertions(+) (limited to 'src') diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index 1c304c856..c03e74599 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -171,6 +171,17 @@ void AIInstance::RegisterAPI() SQAISignList_Register(this->engine); SQAIStation_Register(this->engine); SQAIStationList_Register(this->engine); + SQAIStationList_Cargo_Register(this->engine); + SQAIStationList_CargoPlanned_Register(this->engine); + SQAIStationList_CargoPlannedByFrom_Register(this->engine); + SQAIStationList_CargoPlannedByVia_Register(this->engine); + SQAIStationList_CargoPlannedFromByVia_Register(this->engine); + SQAIStationList_CargoPlannedViaByFrom_Register(this->engine); + SQAIStationList_CargoWaiting_Register(this->engine); + SQAIStationList_CargoWaitingByFrom_Register(this->engine); + SQAIStationList_CargoWaitingByVia_Register(this->engine); + SQAIStationList_CargoWaitingFromByVia_Register(this->engine); + SQAIStationList_CargoWaitingViaByFrom_Register(this->engine); SQAIStationList_Vehicle_Register(this->engine); SQAISubsidy_Register(this->engine); SQAISubsidyList_Register(this->engine); diff --git a/src/game/game_instance.cpp b/src/game/game_instance.cpp index 9d030f296..c5e5c7f05 100644 --- a/src/game/game_instance.cpp +++ b/src/game/game_instance.cpp @@ -173,6 +173,17 @@ void GameInstance::RegisterAPI() SQGSSignList_Register(this->engine); SQGSStation_Register(this->engine); SQGSStationList_Register(this->engine); + SQGSStationList_Cargo_Register(this->engine); + SQGSStationList_CargoPlanned_Register(this->engine); + SQGSStationList_CargoPlannedByFrom_Register(this->engine); + SQGSStationList_CargoPlannedByVia_Register(this->engine); + SQGSStationList_CargoPlannedFromByVia_Register(this->engine); + SQGSStationList_CargoPlannedViaByFrom_Register(this->engine); + SQGSStationList_CargoWaiting_Register(this->engine); + SQGSStationList_CargoWaitingByFrom_Register(this->engine); + SQGSStationList_CargoWaitingByVia_Register(this->engine); + SQGSStationList_CargoWaitingFromByVia_Register(this->engine); + SQGSStationList_CargoWaitingViaByFrom_Register(this->engine); SQGSStationList_Vehicle_Register(this->engine); SQGSStoryPage_Register(this->engine); SQGSStoryPageElementList_Register(this->engine); diff --git a/src/script/api/ai/ai_stationlist.hpp.sq b/src/script/api/ai/ai_stationlist.hpp.sq index 998e89cc1..93a8c6e76 100644 --- a/src/script/api/ai/ai_stationlist.hpp.sq +++ b/src/script/api/ai/ai_stationlist.hpp.sq @@ -25,6 +25,145 @@ void SQAIStationList_Register(Squirrel *engine) } +template <> const char *GetClassName() { return "AIStationList_Cargo"; } + +void SQAIStationList_Cargo_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_Cargo("AIStationList_Cargo"); + SQAIStationList_Cargo.PreRegister(engine, "AIList"); + SQAIStationList_Cargo.AddConstructor(engine, "xiiiii"); + + SQAIStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CS_BY_FROM, "CS_BY_FROM"); + SQAIStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CS_VIA_BY_FROM, "CS_VIA_BY_FROM"); + SQAIStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CS_BY_VIA, "CS_BY_VIA"); + SQAIStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CS_FROM_BY_VIA, "CS_FROM_BY_VIA"); + SQAIStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CM_WAITING, "CM_WAITING"); + SQAIStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CM_PLANNED, "CM_PLANNED"); + + SQAIStationList_Cargo.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "AIStationList_CargoWaiting"; } + +void SQAIStationList_CargoWaiting_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_CargoWaiting("AIStationList_CargoWaiting"); + SQAIStationList_CargoWaiting.PreRegister(engine, "AIStationList_Cargo"); + SQAIStationList_CargoWaiting.AddConstructor(engine, "xiiii"); + + SQAIStationList_CargoWaiting.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "AIStationList_CargoPlanned"; } + +void SQAIStationList_CargoPlanned_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_CargoPlanned("AIStationList_CargoPlanned"); + SQAIStationList_CargoPlanned.PreRegister(engine, "AIStationList_Cargo"); + SQAIStationList_CargoPlanned.AddConstructor(engine, "xiiii"); + + SQAIStationList_CargoPlanned.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "AIStationList_CargoWaitingByFrom"; } + +void SQAIStationList_CargoWaitingByFrom_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_CargoWaitingByFrom("AIStationList_CargoWaitingByFrom"); + SQAIStationList_CargoWaitingByFrom.PreRegister(engine, "AIStationList_CargoWaiting"); + SQAIStationList_CargoWaitingByFrom.AddConstructor(engine, "xii"); + + SQAIStationList_CargoWaitingByFrom.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "AIStationList_CargoWaitingViaByFrom"; } + +void SQAIStationList_CargoWaitingViaByFrom_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_CargoWaitingViaByFrom("AIStationList_CargoWaitingViaByFrom"); + SQAIStationList_CargoWaitingViaByFrom.PreRegister(engine, "AIStationList_CargoWaiting"); + SQAIStationList_CargoWaitingViaByFrom.AddConstructor(engine, "xiii"); + + SQAIStationList_CargoWaitingViaByFrom.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "AIStationList_CargoWaitingByVia"; } + +void SQAIStationList_CargoWaitingByVia_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_CargoWaitingByVia("AIStationList_CargoWaitingByVia"); + SQAIStationList_CargoWaitingByVia.PreRegister(engine, "AIStationList_CargoWaiting"); + SQAIStationList_CargoWaitingByVia.AddConstructor(engine, "xii"); + + SQAIStationList_CargoWaitingByVia.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "AIStationList_CargoWaitingFromByVia"; } + +void SQAIStationList_CargoWaitingFromByVia_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_CargoWaitingFromByVia("AIStationList_CargoWaitingFromByVia"); + SQAIStationList_CargoWaitingFromByVia.PreRegister(engine, "AIStationList_CargoWaiting"); + SQAIStationList_CargoWaitingFromByVia.AddConstructor(engine, "xiii"); + + SQAIStationList_CargoWaitingFromByVia.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "AIStationList_CargoPlannedByFrom"; } + +void SQAIStationList_CargoPlannedByFrom_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_CargoPlannedByFrom("AIStationList_CargoPlannedByFrom"); + SQAIStationList_CargoPlannedByFrom.PreRegister(engine, "AIStationList_CargoPlanned"); + SQAIStationList_CargoPlannedByFrom.AddConstructor(engine, "xii"); + + SQAIStationList_CargoPlannedByFrom.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "AIStationList_CargoPlannedViaByFrom"; } + +void SQAIStationList_CargoPlannedViaByFrom_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_CargoPlannedViaByFrom("AIStationList_CargoPlannedViaByFrom"); + SQAIStationList_CargoPlannedViaByFrom.PreRegister(engine, "AIStationList_CargoPlanned"); + SQAIStationList_CargoPlannedViaByFrom.AddConstructor(engine, "xiii"); + + SQAIStationList_CargoPlannedViaByFrom.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "AIStationList_CargoPlannedByVia"; } + +void SQAIStationList_CargoPlannedByVia_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_CargoPlannedByVia("AIStationList_CargoPlannedByVia"); + SQAIStationList_CargoPlannedByVia.PreRegister(engine, "AIStationList_CargoPlanned"); + SQAIStationList_CargoPlannedByVia.AddConstructor(engine, "xii"); + + SQAIStationList_CargoPlannedByVia.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "AIStationList_CargoPlannedFromByVia"; } + +void SQAIStationList_CargoPlannedFromByVia_Register(Squirrel *engine) +{ + DefSQClass SQAIStationList_CargoPlannedFromByVia("AIStationList_CargoPlannedFromByVia"); + SQAIStationList_CargoPlannedFromByVia.PreRegister(engine, "AIStationList_CargoPlanned"); + SQAIStationList_CargoPlannedFromByVia.AddConstructor(engine, "xiii"); + + SQAIStationList_CargoPlannedFromByVia.PostRegister(engine); +} + + template <> const char *GetClassName() { return "AIStationList_Vehicle"; } void SQAIStationList_Vehicle_Register(Squirrel *engine) diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index 54d69776e..01e05b61e 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -25,6 +25,14 @@ * \li AIStation::GetCargoPlannedFromVia * \li AIStation::GetCargoPlannedVia * \li AIStation::GetCargoWaitingFromVia + * \li AIStationList_CargoPlannedByFrom + * \li AIStationList_CargoPlannedByVia + * \li AIStationList_CargoPlannedFromByVia + * \li AIStationList_CargoPlannedViaByFrom + * \li AIStationList_CargoWaitingByFrom + * \li AIStationList_CargoWaitingByVia + * \li AIStationList_CargoWaitingFromByVia + * \li AIStationList_CargoWaitingViaByFrom * * \b 1.4.2 * diff --git a/src/script/api/game/game_stationlist.hpp.sq b/src/script/api/game/game_stationlist.hpp.sq index 65138964f..a3cdfaa96 100644 --- a/src/script/api/game/game_stationlist.hpp.sq +++ b/src/script/api/game/game_stationlist.hpp.sq @@ -25,6 +25,145 @@ void SQGSStationList_Register(Squirrel *engine) } +template <> const char *GetClassName() { return "GSStationList_Cargo"; } + +void SQGSStationList_Cargo_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_Cargo("GSStationList_Cargo"); + SQGSStationList_Cargo.PreRegister(engine, "GSList"); + SQGSStationList_Cargo.AddConstructor(engine, "xiiiii"); + + SQGSStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CS_BY_FROM, "CS_BY_FROM"); + SQGSStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CS_VIA_BY_FROM, "CS_VIA_BY_FROM"); + SQGSStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CS_BY_VIA, "CS_BY_VIA"); + SQGSStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CS_FROM_BY_VIA, "CS_FROM_BY_VIA"); + SQGSStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CM_WAITING, "CM_WAITING"); + SQGSStationList_Cargo.DefSQConst(engine, ScriptStationList_Cargo::CM_PLANNED, "CM_PLANNED"); + + SQGSStationList_Cargo.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSStationList_CargoWaiting"; } + +void SQGSStationList_CargoWaiting_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_CargoWaiting("GSStationList_CargoWaiting"); + SQGSStationList_CargoWaiting.PreRegister(engine, "GSStationList_Cargo"); + SQGSStationList_CargoWaiting.AddConstructor(engine, "xiiii"); + + SQGSStationList_CargoWaiting.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSStationList_CargoPlanned"; } + +void SQGSStationList_CargoPlanned_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_CargoPlanned("GSStationList_CargoPlanned"); + SQGSStationList_CargoPlanned.PreRegister(engine, "GSStationList_Cargo"); + SQGSStationList_CargoPlanned.AddConstructor(engine, "xiiii"); + + SQGSStationList_CargoPlanned.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSStationList_CargoWaitingByFrom"; } + +void SQGSStationList_CargoWaitingByFrom_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_CargoWaitingByFrom("GSStationList_CargoWaitingByFrom"); + SQGSStationList_CargoWaitingByFrom.PreRegister(engine, "GSStationList_CargoWaiting"); + SQGSStationList_CargoWaitingByFrom.AddConstructor(engine, "xii"); + + SQGSStationList_CargoWaitingByFrom.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSStationList_CargoWaitingViaByFrom"; } + +void SQGSStationList_CargoWaitingViaByFrom_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_CargoWaitingViaByFrom("GSStationList_CargoWaitingViaByFrom"); + SQGSStationList_CargoWaitingViaByFrom.PreRegister(engine, "GSStationList_CargoWaiting"); + SQGSStationList_CargoWaitingViaByFrom.AddConstructor(engine, "xiii"); + + SQGSStationList_CargoWaitingViaByFrom.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSStationList_CargoWaitingByVia"; } + +void SQGSStationList_CargoWaitingByVia_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_CargoWaitingByVia("GSStationList_CargoWaitingByVia"); + SQGSStationList_CargoWaitingByVia.PreRegister(engine, "GSStationList_CargoWaiting"); + SQGSStationList_CargoWaitingByVia.AddConstructor(engine, "xii"); + + SQGSStationList_CargoWaitingByVia.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSStationList_CargoWaitingFromByVia"; } + +void SQGSStationList_CargoWaitingFromByVia_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_CargoWaitingFromByVia("GSStationList_CargoWaitingFromByVia"); + SQGSStationList_CargoWaitingFromByVia.PreRegister(engine, "GSStationList_CargoWaiting"); + SQGSStationList_CargoWaitingFromByVia.AddConstructor(engine, "xiii"); + + SQGSStationList_CargoWaitingFromByVia.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSStationList_CargoPlannedByFrom"; } + +void SQGSStationList_CargoPlannedByFrom_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_CargoPlannedByFrom("GSStationList_CargoPlannedByFrom"); + SQGSStationList_CargoPlannedByFrom.PreRegister(engine, "GSStationList_CargoPlanned"); + SQGSStationList_CargoPlannedByFrom.AddConstructor(engine, "xii"); + + SQGSStationList_CargoPlannedByFrom.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSStationList_CargoPlannedViaByFrom"; } + +void SQGSStationList_CargoPlannedViaByFrom_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_CargoPlannedViaByFrom("GSStationList_CargoPlannedViaByFrom"); + SQGSStationList_CargoPlannedViaByFrom.PreRegister(engine, "GSStationList_CargoPlanned"); + SQGSStationList_CargoPlannedViaByFrom.AddConstructor(engine, "xiii"); + + SQGSStationList_CargoPlannedViaByFrom.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSStationList_CargoPlannedByVia"; } + +void SQGSStationList_CargoPlannedByVia_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_CargoPlannedByVia("GSStationList_CargoPlannedByVia"); + SQGSStationList_CargoPlannedByVia.PreRegister(engine, "GSStationList_CargoPlanned"); + SQGSStationList_CargoPlannedByVia.AddConstructor(engine, "xii"); + + SQGSStationList_CargoPlannedByVia.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSStationList_CargoPlannedFromByVia"; } + +void SQGSStationList_CargoPlannedFromByVia_Register(Squirrel *engine) +{ + DefSQClass SQGSStationList_CargoPlannedFromByVia("GSStationList_CargoPlannedFromByVia"); + SQGSStationList_CargoPlannedFromByVia.PreRegister(engine, "GSStationList_CargoPlanned"); + SQGSStationList_CargoPlannedFromByVia.AddConstructor(engine, "xiii"); + + SQGSStationList_CargoPlannedFromByVia.PostRegister(engine); +} + + template <> const char *GetClassName() { return "GSStationList_Vehicle"; } void SQGSStationList_Vehicle_Register(Squirrel *engine) diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index 8ce162e0a..a627e3270 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -25,6 +25,14 @@ * \li GSStation::GetCargoPlannedFromVia * \li GSStation::GetCargoPlannedVia * \li GSStation::GetCargoWaitingFromVia + * \li GSStationList_CargoPlannedByFrom + * \li GSStationList_CargoPlannedByVia + * \li GSStationList_CargoPlannedFromByVia + * \li GSStationList_CargoPlannedViaByFrom + * \li GSStationList_CargoWaitingByFrom + * \li GSStationList_CargoWaitingByVia + * \li GSStationList_CargoWaitingFromByVia + * \li GSStationList_CargoWaitingViaByFrom * * \b 1.4.2 * diff --git a/src/script/api/script_stationlist.cpp b/src/script/api/script_stationlist.cpp index 9d88fd8fc..7467c1a34 100644 --- a/src/script/api/script_stationlist.cpp +++ b/src/script/api/script_stationlist.cpp @@ -12,6 +12,7 @@ #include "../../stdafx.h" #include "script_stationlist.hpp" #include "script_vehicle.hpp" +#include "script_cargo.hpp" #include "../../station_base.h" #include "../../vehicle_base.h" @@ -35,3 +36,240 @@ ScriptStationList_Vehicle::ScriptStationList_Vehicle(VehicleID vehicle_id) if (o->IsType(OT_GOTO_STATION)) this->AddItem(o->GetDestination()); } } + +ScriptStationList_Cargo::ScriptStationList_Cargo(ScriptStationList_Cargo::CargoMode mode, + ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, + StationID other_station) +{ + switch(mode) { + case CM_WAITING: + ScriptStationList_CargoWaiting(selector, station_id, cargo, other_station).SwapList(this); + break; + case CM_PLANNED: + ScriptStationList_CargoPlanned(selector, station_id, cargo, other_station).SwapList(this); + break; + default: + NOT_REACHED(); + } +} + +ScriptStationList_CargoWaiting::ScriptStationList_CargoWaiting( + ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, + StationID other_station) +{ + switch(selector) { + case CS_BY_FROM: + ScriptStationList_CargoWaitingByFrom(station_id, cargo).SwapList(this); + break; + case CS_VIA_BY_FROM: + ScriptStationList_CargoWaitingViaByFrom(station_id, cargo, other_station).SwapList(this); + break; + case CS_BY_VIA: + ScriptStationList_CargoWaitingByVia(station_id, cargo).SwapList(this); + break; + case CS_FROM_BY_VIA: + ScriptStationList_CargoWaitingFromByVia(station_id, cargo, other_station).SwapList(this); + break; + default: + NOT_REACHED(); + } +} + +ScriptStationList_CargoPlanned::ScriptStationList_CargoPlanned( + ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, + StationID other_station) +{ + switch(selector) { + case CS_BY_FROM: + ScriptStationList_CargoPlannedByFrom(station_id, cargo).SwapList(this); + break; + case CS_VIA_BY_FROM: + ScriptStationList_CargoPlannedViaByFrom(station_id, cargo, other_station).SwapList(this); + break; + case CS_BY_VIA: + ScriptStationList_CargoPlannedByVia(station_id, cargo).SwapList(this); + break; + case CS_FROM_BY_VIA: + ScriptStationList_CargoPlannedFromByVia(station_id, cargo, other_station).SwapList(this); + break; + default: + NOT_REACHED(); + } +} + +class CargoCollector { +public: + CargoCollector(ScriptStationList_Cargo *parent, StationID station_id, CargoID cargo, + StationID other); + ~CargoCollector() ; + + template + void Update(StationID from, StationID via, uint amount); + const GoodsEntry *GE() const { return ge; } + +private: + void SetValue(); + + ScriptStationList_Cargo *list; + const GoodsEntry *ge; + StationID other_station; + + StationID last_key; + uint amount; +}; + +CargoCollector::CargoCollector(ScriptStationList_Cargo *parent, + StationID station_id, CargoID cargo, StationID other) : + list(parent), ge(NULL), other_station(other), last_key(INVALID_STATION), amount(0) +{ + if (!ScriptStation::IsValidStation(station_id)) return; + if (!ScriptCargo::IsValidCargo(cargo)) return; + this->ge = &(Station::Get(station_id)->goods[cargo]); +} + +CargoCollector::~CargoCollector() +{ + this->SetValue(); +} + +void CargoCollector::SetValue() +{ + if (this->amount > 0) { + if (this->list->HasItem(this->last_key)) { + this->list->SetValue(this->last_key, + this->list->GetValue(this->last_key) + this->amount); + } else { + this->list->AddItem(this->last_key, this->amount); + } + } +} + +template +void CargoCollector::Update(StationID from, StationID via, uint amount) +{ + StationID key = INVALID_STATION; + switch (Tselector) { + case ScriptStationList_Cargo::CS_VIA_BY_FROM: + if (via != this->other_station) return; + /* fall through */ + case ScriptStationList_Cargo::CS_BY_FROM: + key = from; + break; + case ScriptStationList_Cargo::CS_FROM_BY_VIA: + if (from != this->other_station) return; + /* fall through */ + case ScriptStationList_Cargo::CS_BY_VIA: + key = via; + break; + } + if (key == this->last_key) { + this->amount += amount; + } else { + this->SetValue(); + this->amount = amount; + this->last_key = key; + } +} + + +template +void ScriptStationList_CargoWaiting::Add(StationID station_id, CargoID cargo, StationID other_station) +{ + CargoCollector collector(this, station_id, cargo, other_station); + if (collector.GE() == NULL) return; + + StationCargoList::ConstIterator iter = collector.GE()->cargo.Packets()->begin(); + StationCargoList::ConstIterator end = collector.GE()->cargo.Packets()->end(); + for (; iter != end; ++iter) { + collector.Update((*iter)->SourceStation(), iter.GetKey(), (*iter)->Count()); + } +} + + +template +void ScriptStationList_CargoPlanned::Add(StationID station_id, CargoID cargo, StationID other_station) +{ + CargoCollector collector(this, station_id, cargo, other_station); + if (collector.GE() == NULL) return; + + FlowStatMap::const_iterator iter = collector.GE()->flows.begin(); + FlowStatMap::const_iterator end = collector.GE()->flows.end(); + for (; iter != end; ++iter) { + const FlowStat::SharesMap *shares = iter->second.GetShares(); + uint prev = 0; + for (FlowStat::SharesMap::const_iterator flow_iter = shares->begin(); + flow_iter != shares->end(); ++flow_iter) { + collector.Update(iter->first, flow_iter->second, flow_iter->first - prev); + prev = flow_iter->first; + } + } +} + +ScriptStationList_CargoWaitingByFrom::ScriptStationList_CargoWaitingByFrom(StationID station_id, + CargoID cargo) +{ + this->Add(station_id, cargo); +} + +ScriptStationList_CargoWaitingViaByFrom::ScriptStationList_CargoWaitingViaByFrom( + StationID station_id, CargoID cargo, StationID via) +{ + CargoCollector collector(this, station_id, cargo, via); + if (collector.GE() == NULL) return; + + std::pair range = + collector.GE()->cargo.Packets()->equal_range(via); + for (StationCargoList::ConstIterator iter = range.first; iter != range.second; ++iter) { + collector.Update((*iter)->SourceStation(), iter.GetKey(), (*iter)->Count()); + } +} + + +ScriptStationList_CargoWaitingByVia::ScriptStationList_CargoWaitingByVia(StationID station_id, + CargoID cargo) +{ + this->Add(station_id, cargo); +} + +ScriptStationList_CargoWaitingFromByVia::ScriptStationList_CargoWaitingFromByVia( + StationID station_id, CargoID cargo, StationID from) +{ + this->Add(station_id, cargo, from); +} + +ScriptStationList_CargoPlannedByFrom::ScriptStationList_CargoPlannedByFrom(StationID station_id, + CargoID cargo) +{ + this->Add(station_id, cargo); +} + +ScriptStationList_CargoPlannedViaByFrom::ScriptStationList_CargoPlannedViaByFrom( + StationID station_id, CargoID cargo, StationID via) +{ + this->Add(station_id, cargo, via); +} + + +ScriptStationList_CargoPlannedByVia::ScriptStationList_CargoPlannedByVia(StationID station_id, + CargoID cargo) +{ + this->Add(station_id, cargo); +} + + +ScriptStationList_CargoPlannedFromByVia::ScriptStationList_CargoPlannedFromByVia( + StationID station_id, CargoID cargo, StationID from) +{ + CargoCollector collector(this, station_id, cargo, from); + if (collector.GE() == NULL) return; + + FlowStatMap::const_iterator iter = collector.GE()->flows.find(from); + if (iter == collector.GE()->flows.end()) return; + const FlowStat::SharesMap *shares = iter->second.GetShares(); + uint prev = 0; + for (FlowStat::SharesMap::const_iterator flow_iter = shares->begin(); + flow_iter != shares->end(); ++flow_iter) { + collector.Update(iter->first, flow_iter->second, flow_iter->first - prev); + prev = flow_iter->first; + } +} diff --git a/src/script/api/script_stationlist.hpp b/src/script/api/script_stationlist.hpp index cd9c98137..bc1947178 100644 --- a/src/script/api/script_stationlist.hpp +++ b/src/script/api/script_stationlist.hpp @@ -28,6 +28,251 @@ public: ScriptStationList(ScriptStation::StationType station_type); }; +/** + * Creates a list of stations associated with cargo at a station. This is very generic. Use the + * subclasses for all practical purposes. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_Cargo : public ScriptList { +public: + /** + * Criteria of selecting and grouping cargo at a station. + */ + enum CargoSelector { + CS_BY_FROM, ///< Group by origin station. + CS_VIA_BY_FROM, ///< Select by next hop and group by origin station. + CS_BY_VIA, ///< Group by next hop. + CS_FROM_BY_VIA ///< Select by origin station and group by next hop. + }; + + /** + * Ways of associating cargo to stations. + */ + enum CargoMode { + CM_WAITING, ///< Waiting cargo. + CM_PLANNED ///< Planned cargo. + }; + + /** + * Creates a list of stations associated with cargo in the specified way, selected and grouped + * by the chosen criteria. + * @param mode Mode of association, either waiting cargo or planned cargo. + * @param selector Mode of grouping and selecting to be applied. + * @param station_id Station to be queried. + * @param cargo Cargo type to query for. + * @param other_station Other station to restrict the query with. + */ + ScriptStationList_Cargo(ScriptStationList_Cargo::CargoMode mode, ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station); + +protected: + + /** + * Creates an empty list. + */ + ScriptStationList_Cargo() {} +}; + +/** + * Creates a list of stations associated with cargo waiting at a station. This is very generic. Use + * the subclasses for all practical purposes. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_CargoWaiting : public ScriptStationList_Cargo { +protected: + friend class ScriptStationList_Cargo; + + /** + * Creates an empty list. + */ + ScriptStationList_CargoWaiting() {} + + /** + * Add waiting cargo to the list. + * @param station_id Station to query for waiting cargo. + * @param cargo Cargo type to query for. + * @param other_station Other station to restrict the query with. + */ + template + void Add(StationID station_id, CargoID cargo, StationID other_station = INVALID_STATION); + +public: + + /** + * Creates a list of stations associated with waiting cargo, selected and grouped by the chosen + * criteria. + * @param selector Mode of grouping and selecting to be applied. + * @param station_id Station to be queried. + * @param cargo Cargo type to query for. + * @param other_station Other station to restrict the query with. + */ + ScriptStationList_CargoWaiting(ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station); +}; + +/** + * Creates a list of stations associated with cargo planned to pass a station. This is very + * generic. Use the subclasses for all practical purposes. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_CargoPlanned : public ScriptStationList_Cargo { +protected: + friend class ScriptStationList_Cargo; + + /** + * Creates an empty list. + */ + ScriptStationList_CargoPlanned() {} + + /** + * Add planned cargo to the list. + * @param station_id Station to query for waiting cargo. + * @param cargo Cargo type to query for. + * @param other_station Other station to restrict the query with. + */ + template + void Add(StationID station_id, CargoID cargo, StationID other_station = INVALID_STATION); + +public: + + /** + * Creates a list of stations associated with cargo planned to pass the station, selected and + * grouped by the chosen criteria. + * @param selector Mode of grouping and selecting to be applied. + * @param station_id Station to be queried. + * @param cargo Cargo type to query for. + * @param other_station Other station to restrict the query with. + */ + ScriptStationList_CargoPlanned(ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station); +}; + +/** + * Creates a list of origin stations of waiting cargo at a station, with the amounts of cargo + * waiting from each of those origin stations as values. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_CargoWaitingByFrom : public ScriptStationList_CargoWaiting { +public: + /** + * @param station_id Station to query for waiting cargo. + * @param cargo Cargo type to query for. + */ + ScriptStationList_CargoWaitingByFrom(StationID station_id, CargoID cargo); +}; + +/** + * Creates a list of origin stations of cargo waiting at a station for a transfer via another + * station, with the amounts of cargo waiting from each of those origin stations as values. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_CargoWaitingViaByFrom : public ScriptStationList_CargoWaiting { +public: + /** + * @param station_id Station to query for waiting cargo. + * @param cargo Cargo type to query for. + * @param via Next hop to restrict the query with. + */ + ScriptStationList_CargoWaitingViaByFrom(StationID station_id, CargoID cargo, StationID via); +}; + +/** + * Creates a list of next hops of waiting cargo at a station, with the amounts of cargo waiting for + * each of those next hops as values. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_CargoWaitingByVia : public ScriptStationList_CargoWaiting { +public: + /** + * @param station_id Station to query for waiting cargo. + * @param cargo Cargo type to query for. + */ + ScriptStationList_CargoWaitingByVia(StationID station_id, CargoID cargo); +}; + +/** + * Creates a list of next hops of waiting cargo from a specific station at another station, with + * the amounts of cargo waiting for each of those next hops as values. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_CargoWaitingFromByVia : public ScriptStationList_CargoWaiting { +public: + /** + * @param station_id Station to query for waiting cargo. + * @param cargo Cargo type to query for. + * @param from Origin station to restrict the query with. + */ + ScriptStationList_CargoWaitingFromByVia(StationID station_id, CargoID cargo, StationID from); +}; + +/** + * Creates a list of origin stations of cargo planned to pass a station, with the monthly amounts + * of cargo planned for each of those origin stations as values. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_CargoPlannedByFrom : public ScriptStationList_CargoPlanned { +public: + /** + * @param station_id Station to query for planned flows. + * @param cargo Cargo type to query for. + */ + ScriptStationList_CargoPlannedByFrom(StationID station_id, CargoID cargo); +}; + +/** + * Creates a list of origin stations of cargo planned to pass a station going via another station, + * with the monthly amounts of cargo planned for each of those origin stations as values. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_CargoPlannedViaByFrom : public ScriptStationList_CargoPlanned { +public: + /** + * @param station_id Station to query for planned flows. + * @param cargo Cargo type to query for. + * @param via Next hop to restrict the query with. + */ + ScriptStationList_CargoPlannedViaByFrom(StationID station_id, CargoID cargo, StationID via); +}; + +/** + * Creates a list of next hops of cargo planned to pass a station, with the monthly amounts of + * cargo planned for each of those next hops as values. + * Cargo planned to go "via" the station being queried will actually be delivered there. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_CargoPlannedByVia : public ScriptStationList_CargoPlanned { +public: + /** + * @param station_id Station to query for planned flows. + * @param cargo Cargo type to query for. + */ + ScriptStationList_CargoPlannedByVia(StationID station_id, CargoID cargo); +}; + +/** + * Creates a list of next hops of cargo planned to pass a station and originating from another + * station, with the monthly amounts of cargo planned for each of those next hops as values. + * Cargo planned to go "via" the station being queried will actually be delivered there. + * @api ai game + * @ingroup ScriptList + */ +class ScriptStationList_CargoPlannedFromByVia : public ScriptStationList_CargoPlanned { +public: + /** + * @param station_id Station to query for planned flows. + * @param cargo Cargo type to query for. + * @param from Origin station to restrict the query with. + */ + ScriptStationList_CargoPlannedFromByVia(StationID station_id, CargoID cargo, StationID from); +}; + /** * Creates a list of stations which the vehicle has in its orders. * @api ai game diff --git a/src/script/api/template/template_stationlist.hpp.sq b/src/script/api/template/template_stationlist.hpp.sq index f9f49a4ef..5f7bd2812 100644 --- a/src/script/api/template/template_stationlist.hpp.sq +++ b/src/script/api/template/template_stationlist.hpp.sq @@ -20,6 +20,111 @@ namespace SQConvert { template <> inline int Return(HSQUIRRELVM vm, ScriptStationList *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList", res, NULL, DefSQDestructorCallback, true); return 1; } } // namespace SQConvert +namespace SQConvert { + /* Allow enums to be used as Squirrel parameters */ + template <> inline ScriptStationList_Cargo::CargoSelector GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptStationList_Cargo::CargoSelector)tmp; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_Cargo::CargoSelector res) { sq_pushinteger(vm, (int32)res); return 1; } + template <> inline ScriptStationList_Cargo::CargoMode GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptStationList_Cargo::CargoMode)tmp; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_Cargo::CargoMode res) { sq_pushinteger(vm, (int32)res); return 1; } + + /* Allow ScriptStationList_Cargo to be used as Squirrel parameter */ + template <> inline ScriptStationList_Cargo *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_Cargo *)instance; } + template <> inline ScriptStationList_Cargo &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_Cargo *)instance; } + template <> inline const ScriptStationList_Cargo *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_Cargo *)instance; } + template <> inline const ScriptStationList_Cargo &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_Cargo *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_Cargo *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_Cargo", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptStationList_CargoWaiting to be used as Squirrel parameter */ + template <> inline ScriptStationList_CargoWaiting *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoWaiting *)instance; } + template <> inline ScriptStationList_CargoWaiting &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoWaiting *)instance; } + template <> inline const ScriptStationList_CargoWaiting *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoWaiting *)instance; } + template <> inline const ScriptStationList_CargoWaiting &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoWaiting *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_CargoWaiting *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_CargoWaiting", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptStationList_CargoPlanned to be used as Squirrel parameter */ + template <> inline ScriptStationList_CargoPlanned *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoPlanned *)instance; } + template <> inline ScriptStationList_CargoPlanned &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoPlanned *)instance; } + template <> inline const ScriptStationList_CargoPlanned *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoPlanned *)instance; } + template <> inline const ScriptStationList_CargoPlanned &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoPlanned *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_CargoPlanned *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_CargoPlanned", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptStationList_CargoWaitingByFrom to be used as Squirrel parameter */ + template <> inline ScriptStationList_CargoWaitingByFrom *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoWaitingByFrom *)instance; } + template <> inline ScriptStationList_CargoWaitingByFrom &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoWaitingByFrom *)instance; } + template <> inline const ScriptStationList_CargoWaitingByFrom *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoWaitingByFrom *)instance; } + template <> inline const ScriptStationList_CargoWaitingByFrom &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoWaitingByFrom *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_CargoWaitingByFrom *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_CargoWaitingByFrom", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptStationList_CargoWaitingViaByFrom to be used as Squirrel parameter */ + template <> inline ScriptStationList_CargoWaitingViaByFrom *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoWaitingViaByFrom *)instance; } + template <> inline ScriptStationList_CargoWaitingViaByFrom &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoWaitingViaByFrom *)instance; } + template <> inline const ScriptStationList_CargoWaitingViaByFrom *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoWaitingViaByFrom *)instance; } + template <> inline const ScriptStationList_CargoWaitingViaByFrom &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoWaitingViaByFrom *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_CargoWaitingViaByFrom *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_CargoWaitingViaByFrom", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptStationList_CargoWaitingByVia to be used as Squirrel parameter */ + template <> inline ScriptStationList_CargoWaitingByVia *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoWaitingByVia *)instance; } + template <> inline ScriptStationList_CargoWaitingByVia &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoWaitingByVia *)instance; } + template <> inline const ScriptStationList_CargoWaitingByVia *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoWaitingByVia *)instance; } + template <> inline const ScriptStationList_CargoWaitingByVia &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoWaitingByVia *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_CargoWaitingByVia *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_CargoWaitingByVia", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptStationList_CargoWaitingFromByVia to be used as Squirrel parameter */ + template <> inline ScriptStationList_CargoWaitingFromByVia *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoWaitingFromByVia *)instance; } + template <> inline ScriptStationList_CargoWaitingFromByVia &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoWaitingFromByVia *)instance; } + template <> inline const ScriptStationList_CargoWaitingFromByVia *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoWaitingFromByVia *)instance; } + template <> inline const ScriptStationList_CargoWaitingFromByVia &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoWaitingFromByVia *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_CargoWaitingFromByVia *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_CargoWaitingFromByVia", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptStationList_CargoPlannedByFrom to be used as Squirrel parameter */ + template <> inline ScriptStationList_CargoPlannedByFrom *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoPlannedByFrom *)instance; } + template <> inline ScriptStationList_CargoPlannedByFrom &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoPlannedByFrom *)instance; } + template <> inline const ScriptStationList_CargoPlannedByFrom *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoPlannedByFrom *)instance; } + template <> inline const ScriptStationList_CargoPlannedByFrom &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoPlannedByFrom *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_CargoPlannedByFrom *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_CargoPlannedByFrom", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptStationList_CargoPlannedViaByFrom to be used as Squirrel parameter */ + template <> inline ScriptStationList_CargoPlannedViaByFrom *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoPlannedViaByFrom *)instance; } + template <> inline ScriptStationList_CargoPlannedViaByFrom &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoPlannedViaByFrom *)instance; } + template <> inline const ScriptStationList_CargoPlannedViaByFrom *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoPlannedViaByFrom *)instance; } + template <> inline const ScriptStationList_CargoPlannedViaByFrom &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoPlannedViaByFrom *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_CargoPlannedViaByFrom *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_CargoPlannedViaByFrom", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptStationList_CargoPlannedByVia to be used as Squirrel parameter */ + template <> inline ScriptStationList_CargoPlannedByVia *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoPlannedByVia *)instance; } + template <> inline ScriptStationList_CargoPlannedByVia &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoPlannedByVia *)instance; } + template <> inline const ScriptStationList_CargoPlannedByVia *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoPlannedByVia *)instance; } + template <> inline const ScriptStationList_CargoPlannedByVia &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoPlannedByVia *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_CargoPlannedByVia *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_CargoPlannedByVia", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptStationList_CargoPlannedFromByVia to be used as Squirrel parameter */ + template <> inline ScriptStationList_CargoPlannedFromByVia *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoPlannedFromByVia *)instance; } + template <> inline ScriptStationList_CargoPlannedFromByVia &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoPlannedFromByVia *)instance; } + template <> inline const ScriptStationList_CargoPlannedFromByVia *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_CargoPlannedFromByVia *)instance; } + template <> inline const ScriptStationList_CargoPlannedFromByVia &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStationList_CargoPlannedFromByVia *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStationList_CargoPlannedFromByVia *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StationList_CargoPlannedFromByVia", res, NULL, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + namespace SQConvert { /* Allow ScriptStationList_Vehicle to be used as Squirrel parameter */ template <> inline ScriptStationList_Vehicle *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStationList_Vehicle *)instance; } -- cgit v1.2.3-70-g09d2