Index: src/ai/api/ai_tilelist_valuator.hpp.sq =================================================================== --- src/ai/api/ai_tilelist_valuator.hpp.sq (revision 12260) +++ src/ai/api/ai_tilelist_valuator.hpp.sq (working copy) @@ -153,6 +153,25 @@ } namespace SQConvert { + /* Allow AITileList_vCargoProduction to be used as Squirrel parameter */ + template <> AITileList_vCargoProduction *GetParam(ForceType, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AITileList_vCargoProduction *)instance; } + template <> AITileList_vCargoProduction &GetParam(ForceType, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITileList_vCargoProduction *)instance; } + template <> const AITileList_vCargoProduction *GetParam(ForceType, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AITileList_vCargoProduction *)instance; } + template <> const AITileList_vCargoProduction &GetParam(ForceType, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITileList_vCargoProduction *)instance; } + template <> int Return(HSQUIRRELVM vm, AITileList_vCargoProduction *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AITileList_vCargoProduction", res, NULL, DefSQDestructorCallback); return 1; } +}; // namespace SQConvert + +void SQAITileList_vCargoProduction_Register(Squirrel *engine) { + DefSQClass SQAITileList_vCargoProduction("AITileList_vCargoProduction"); + SQAITileList_vCargoProduction.PreRegister(engine); + SQAITileList_vCargoProduction.AddConstructor(engine, "xiiii"); + + SQAITileList_vCargoProduction.DefSQStaticMethod(engine, &AITileList_vCargoProduction::GetClassName, "GetClassName", 1, "x"); + + SQAITileList_vCargoProduction.PostRegister(engine); +} + +namespace SQConvert { /* Allow AITileList_vDistanceManhattanToTile to be used as Squirrel parameter */ template <> AITileList_vDistanceManhattanToTile *GetParam(ForceType, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AITileList_vDistanceManhattanToTile *)instance; } template <> AITileList_vDistanceManhattanToTile &GetParam(ForceType, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITileList_vDistanceManhattanToTile *)instance; } Index: src/ai/api/ai_tilelist_valuator.cpp =================================================================== --- src/ai/api/ai_tilelist_valuator.cpp (revision 12260) +++ src/ai/api/ai_tilelist_valuator.cpp (working copy) @@ -55,6 +55,11 @@ return AITile::GetCargoAcceptance(tile, this->cargo_type, this->width, this->height, this->radius); } +int32 AITileList_vCargoProduction::Valuate(int32 tile) const +{ + return AITile::GetCargoProduction(tile, this->cargo_type, this->width, this->height, this->radius); +} + int32 AITileList_vDistanceManhattanToTile::Valuate(int32 tile) const { return AIMap::DistanceManhattan(this->tile, tile); Index: src/ai/api/ai_tilelist_valuator.hpp =================================================================== --- src/ai/api/ai_tilelist_valuator.hpp (revision 12260) +++ src/ai/api/ai_tilelist_valuator.hpp (working copy) @@ -156,6 +156,33 @@ }; /** + * Get the amount of estimated produced cargo for all tiles in AITileList_v. + * For passengers and mail it indicates how much cargo would be brought to + * the station. + * @post values < 8 means this tile does not accept this cargo. + * @note resulting items are of the type int32 (indicating production) + * @note the input items are of the type TileIndex + */ +class AITileList_vCargoProduction : public AIAbstractList::Valuator { +public: + /** + * The name of the class, needed by several sub-processes. + */ + static const char *GetClassName() { return "AITileList_vCargoProduction"; } + + /** + * Custom constructor, we want a cargo-type as parameter. + */ + AITileList_vCargoProduction(CargoID cargo_type, uint width, uint height, uint radius) { this->cargo_type = cargo_type; this->width = width; this->height = height; this->radius = radius; } + +private: + CargoID cargo_type; + uint width, height, radius; + + int32 Valuate(int32 tile) const; +}; + +/** * Get the manhattan distance to a tile for entries in an AITileList instance. * @note resulting items are of the type distance * @note the input items are of the type TileIndex