src/ai/api/ai_pathfinder.hpp.sq
author rubidium
Sun, 15 Jul 2007 16:39:11 +0000
branchnoai
changeset 9668 6fe3d2cb9655
parent 9653 50e2eb4abf46
child 9673 ee4f133c84ec
permissions -rw-r--r--
(svn r10582) [NoAI] -Codechange: allow getting the president and company names of other companies as well as their company value and bank balance.
#include "ai_pathfinder.hpp"

namespace SQConvert {
	/* Allow enums to be used as Squirrel parameters */
	template <> AIPathFinder::PathFinderType GetParam(ForceType<AIPathFinder::PathFinderType>, HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIPathFinder::PathFinderType)tmp; }
	template <> int Return<AIPathFinder::PathFinderType>(HSQUIRRELVM vm, AIPathFinder::PathFinderType res) { sq_pushinteger(vm, (int32)res); return 1; }

	/* Allow AIPathFinder to be used as Squirrel parameter */
	template <> AIPathFinder *GetParam(ForceType<AIPathFinder *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIPathFinder *)instance; }
	template <> AIPathFinder &GetParam(ForceType<AIPathFinder &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIPathFinder *)instance; }
	template <> const AIPathFinder *GetParam(ForceType<const AIPathFinder *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIPathFinder *)instance; }
	template <> const AIPathFinder &GetParam(ForceType<const AIPathFinder &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIPathFinder *)instance; }
}; // namespace SQConvert

void SQAIPathFinderRegister(Squirrel *engine) {
	DefSQClass <AIPathFinder> SQAIPathFinder("AIPathFinder");
	SQAIPathFinder.PreRegister(engine);

	SQAIPathFinder.DefSQConst(engine, AIPathFinder::PATHFINDER_ROAD, "PATHFINDER_ROAD");
	SQAIPathFinder.DefSQConst(engine, AIPathFinder::PATHFINDER_RAIL, "PATHFINDER_RAIL");

	SQAIPathFinder.DefSQStaticMethod(engine, &AIPathFinder::GetClassName, "GetClassName", 1, "x");

	SQAIPathFinder.PostRegister(engine);
}