mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r23134) -Add [FS#3799]: [NoAI] AICargoList_StationAccepting
This commit is contained in:
parent
1750b2ad9f
commit
3566f8b905
@ -186,6 +186,7 @@ void AIInstance::RegisterAPI()
|
||||
SQAICargoList_Register(this->engine);
|
||||
SQAICargoList_IndustryAccepting_Register(this->engine);
|
||||
SQAICargoList_IndustryProducing_Register(this->engine);
|
||||
SQAICargoList_StationAccepting_Register(this->engine);
|
||||
SQAICompany_Register(this->engine);
|
||||
SQAIDate_Register(this->engine);
|
||||
SQAIDepotList_Register(this->engine);
|
||||
|
@ -12,8 +12,10 @@
|
||||
#include "../../stdafx.h"
|
||||
#include "ai_cargolist.hpp"
|
||||
#include "ai_industry.hpp"
|
||||
#include "ai_station.hpp"
|
||||
#include "../../cargotype.h"
|
||||
#include "../../industry.h"
|
||||
#include "../../station_base.h"
|
||||
|
||||
AICargoList::AICargoList()
|
||||
{
|
||||
@ -48,3 +50,13 @@ AICargoList_IndustryProducing::AICargoList_IndustryProducing(IndustryID industry
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AICargoList_StationAccepting::AICargoList_StationAccepting(StationID station_id)
|
||||
{
|
||||
if (!AIStation::IsValidStation(station_id)) return;
|
||||
|
||||
Station *st = ::Station::Get(station_id);
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||
if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::GES_ACCEPTANCE)) this->AddItem(i);
|
||||
}
|
||||
}
|
||||
|
@ -57,4 +57,19 @@ public:
|
||||
AICargoList_IndustryProducing(IndustryID industry_id);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a list of cargos that the given station accepts.
|
||||
* @ingroup AIList
|
||||
*/
|
||||
class AICargoList_StationAccepting : public AIList {
|
||||
public:
|
||||
/** Get the name of this class to identify it towards squirrel. */
|
||||
static const char *GetClassName() { return "AICargoList_StationAccepting"; }
|
||||
|
||||
/**
|
||||
* @param station_id The station to get the list of cargos it accepts from.
|
||||
*/
|
||||
AICargoList_StationAccepting(StationID station_id);
|
||||
};
|
||||
|
||||
#endif /* AI_CARGOLIST_HPP */
|
||||
|
@ -64,3 +64,21 @@ void SQAICargoList_IndustryProducing_Register(Squirrel *engine)
|
||||
|
||||
SQAICargoList_IndustryProducing.PostRegister(engine);
|
||||
}
|
||||
|
||||
namespace SQConvert {
|
||||
/* Allow AICargoList_StationAccepting to be used as Squirrel parameter */
|
||||
template <> AICargoList_StationAccepting *GetParam(ForceType<AICargoList_StationAccepting *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AICargoList_StationAccepting *)instance; }
|
||||
template <> AICargoList_StationAccepting &GetParam(ForceType<AICargoList_StationAccepting &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AICargoList_StationAccepting *)instance; }
|
||||
template <> const AICargoList_StationAccepting *GetParam(ForceType<const AICargoList_StationAccepting *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AICargoList_StationAccepting *)instance; }
|
||||
template <> const AICargoList_StationAccepting &GetParam(ForceType<const AICargoList_StationAccepting &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AICargoList_StationAccepting *)instance; }
|
||||
template <> int Return<AICargoList_StationAccepting *>(HSQUIRRELVM vm, AICargoList_StationAccepting *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AICargoList_StationAccepting", res, NULL, DefSQDestructorCallback<AICargoList_StationAccepting>); return 1; }
|
||||
} // namespace SQConvert
|
||||
|
||||
void SQAICargoList_StationAccepting_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass <AICargoList_StationAccepting> SQAICargoList_StationAccepting("AICargoList_StationAccepting");
|
||||
SQAICargoList_StationAccepting.PreRegister(engine, "AIList");
|
||||
SQAICargoList_StationAccepting.AddConstructor<void (AICargoList_StationAccepting::*)(StationID station_id), 2>(engine, "xi");
|
||||
|
||||
SQAICargoList_StationAccepting.PostRegister(engine);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
*
|
||||
* \li AICargo::CT_AUTO_REFIT
|
||||
* \li AICargo::CT_NO_REFIT
|
||||
* \li AICargoList_StationAccepting
|
||||
* \li AICompany::GetQuarterlyIncome
|
||||
* \li AICompany::GetQuarterlyExpenses
|
||||
* \li AICompany::GetQuarterlyCargoDelivered
|
||||
|
Loading…
Reference in New Issue
Block a user