summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_industry.hpp.sq
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-08-07 20:51:53 +0000
committeryexo <yexo@openttd.org>2010-08-07 20:51:53 +0000
commit178f74c31cd79ac248308a6fa389e5aa223b0895 (patch)
treee782722a0c69d4242fffc9e12fad9409679221d0 /src/ai/api/ai_industry.hpp.sq
parentaf9d8824bd7d08fa512f34c02c238d0042d060a7 (diff)
downloadopenttd-178f74c31cd79ac248308a6fa389e5aa223b0895.tar.xz
(svn r20399) -Change: [NoAI] AIIndustry::IsCargoAccepted now returns 3 possible values so AIs can detect a temporaral refusal from an industry to accept some cargo type
Diffstat (limited to 'src/ai/api/ai_industry.hpp.sq')
-rw-r--r--src/ai/api/ai_industry.hpp.sq8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ai/api/ai_industry.hpp.sq b/src/ai/api/ai_industry.hpp.sq
index 86c7d90b7..e0ff0ff8c 100644
--- a/src/ai/api/ai_industry.hpp.sq
+++ b/src/ai/api/ai_industry.hpp.sq
@@ -12,6 +12,10 @@
#include "ai_industry.hpp"
namespace SQConvert {
+ /* Allow enums to be used as Squirrel parameters */
+ template <> AIIndustry::CargoAcceptState GetParam(ForceType<AIIndustry::CargoAcceptState>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIIndustry::CargoAcceptState)tmp; }
+ template <> int Return<AIIndustry::CargoAcceptState>(HSQUIRRELVM vm, AIIndustry::CargoAcceptState res) { sq_pushinteger(vm, (int32)res); return 1; }
+
/* Allow AIIndustry to be used as Squirrel parameter */
template <> AIIndustry *GetParam(ForceType<AIIndustry *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIIndustry *)instance; }
template <> AIIndustry &GetParam(ForceType<AIIndustry &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIIndustry *)instance; }
@@ -26,6 +30,10 @@ void SQAIIndustry_Register(Squirrel *engine)
SQAIIndustry.PreRegister(engine);
SQAIIndustry.AddConstructor<void (AIIndustry::*)(), 1>(engine, "x");
+ SQAIIndustry.DefSQConst(engine, AIIndustry::CAS_NOT_ACCEPTED, "CAS_NOT_ACCEPTED");
+ SQAIIndustry.DefSQConst(engine, AIIndustry::CAS_ACCEPTED, "CAS_ACCEPTED");
+ SQAIIndustry.DefSQConst(engine, AIIndustry::CAS_TEMP_REFUSED, "CAS_TEMP_REFUSED");
+
SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetIndustryCount, "GetIndustryCount", 1, ".");
SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::IsValidIndustry, "IsValidIndustry", 2, ".i");
SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetIndustryID, "GetIndustryID", 2, ".i");