diff options
author | frosch <frosch@openttd.org> | 2010-07-10 10:54:30 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-07-10 10:54:30 +0000 |
commit | 969c059feae435ff5cabb2f33d10d939b318ec02 (patch) | |
tree | d5daa0d05cd4f59342be87002abe60b1bd2826d0 /src/ai/api/ai_industrytype.hpp.sq | |
parent | 1055c2b0fd8feb8a4a3eb039c3170d7ee8160b46 (diff) | |
download | openttd-969c059feae435ff5cabb2f33d10d939b318ec02.tar.xz |
(svn r20107) -Add: [NoAI] AIIndustryType::INDUSTRYTYPE_TOWN and AIIndustryType::INDUSTRYTYPE_UNKNOWN for AIRail::BuildNewGRFRailStation(). Note that BuildNewGRFRailStation() now checks the passed industry type for validity.
Diffstat (limited to 'src/ai/api/ai_industrytype.hpp.sq')
-rw-r--r-- | src/ai/api/ai_industrytype.hpp.sq | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ai/api/ai_industrytype.hpp.sq b/src/ai/api/ai_industrytype.hpp.sq index 494566021..938477145 100644 --- a/src/ai/api/ai_industrytype.hpp.sq +++ b/src/ai/api/ai_industrytype.hpp.sq @@ -12,6 +12,10 @@ #include "ai_industrytype.hpp" namespace SQConvert { + /* Allow enums to be used as Squirrel parameters */ + template <> AIIndustryType::SpecialIndustryType GetParam(ForceType<AIIndustryType::SpecialIndustryType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIIndustryType::SpecialIndustryType)tmp; } + template <> int Return<AIIndustryType::SpecialIndustryType>(HSQUIRRELVM vm, AIIndustryType::SpecialIndustryType res) { sq_pushinteger(vm, (int32)res); return 1; } + /* Allow AIIndustryType to be used as Squirrel parameter */ template <> AIIndustryType *GetParam(ForceType<AIIndustryType *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIIndustryType *)instance; } template <> AIIndustryType &GetParam(ForceType<AIIndustryType &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIIndustryType *)instance; } @@ -26,6 +30,9 @@ void SQAIIndustryType_Register(Squirrel *engine) SQAIIndustryType.PreRegister(engine); SQAIIndustryType.AddConstructor<void (AIIndustryType::*)(), 1>(engine, "x"); + SQAIIndustryType.DefSQConst(engine, AIIndustryType::INDUSTRYTYPE_UNKNOWN, "INDUSTRYTYPE_UNKNOWN"); + SQAIIndustryType.DefSQConst(engine, AIIndustryType::INDUSTRYTYPE_TOWN, "INDUSTRYTYPE_TOWN"); + SQAIIndustryType.DefSQStaticMethod(engine, &AIIndustryType::IsValidIndustryType, "IsValidIndustryType", 2, ".i"); SQAIIndustryType.DefSQStaticMethod(engine, &AIIndustryType::GetName, "GetName", 2, ".i"); SQAIIndustryType.DefSQStaticMethod(engine, &AIIndustryType::GetProducedCargo, "GetProducedCargo", 2, ".i"); |