src/ai/api/ai_tilelist_valuator.hpp
author rubidium
Sat, 14 Apr 2007 20:38:10 +0000
branchnoai
changeset 9594 5009a30f320a
parent 9593 012f29f59906
child 9595 91423dbb6f5f
permissions -rw-r--r--
(svn r9627) [NoAI] -Fix: let the squirrel export script export all needed (and a few more) types of references to structs and classes.
/* $Id$ */

/** @file ai_tilelist.hpp all the valuators for tilelist */

#ifndef AI_TILELIST_VALUATOR_HPP
#define AI_TILELIST_VALUATOR_HPP

#include "ai_abstractlist.hpp"

/**
 * Check if tiles are buildable for entries in an AITownList instance.
 * @note resulting items are of the type bool (0 = not buildable, 1 = buildable)
 * @note the input items are of the type TileIndex
 */
class AITileListBuildable : public AIAbstractList::Valuator {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITileListBuildable"; }

private:
	int32 Valuate(int32 tile) const;
};

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

void SQAITileListBuildableRegister(Squirrel *engine) {
	DefSQClass <AITileListBuildable> SQAITileListBuildable("AITileListBuildable");
	SQAITileListBuildable.PreRegister(engine);
	SQAITileListBuildable.AddConstructor(engine);

	SQAITileListBuildable.DefSQStaticMethod(engine, &AITileListBuildable::GetClassName, "GetClassName", 1, "x");

	SQAITileListBuildable.PostRegister(engine);
}
#endif /* DEFINE_SQUIRREL_CLASS */

#endif /* AI_TILELIST_VALUATOR_HPP */