src/ai/api/ai_engine.hpp.sq
author truebrain
Fri, 22 Feb 2008 12:30:17 +0000
branchnoai
changeset 9737 ee408edf3851
parent 9733 49e424cd4edd
child 9741 53c1c5850e01
permissions -rw-r--r--
(svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
9711
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
     1
#include "ai_engine.hpp"
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
     2
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
     3
namespace SQConvert {
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
     4
	/* Allow AIEngine to be used as Squirrel parameter */
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
     5
	template <> AIEngine *GetParam(ForceType<AIEngine *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIEngine *)instance; }
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
     6
	template <> AIEngine &GetParam(ForceType<AIEngine &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEngine *)instance; }
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
     7
	template <> const AIEngine *GetParam(ForceType<const AIEngine *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIEngine *)instance; }
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
     8
	template <> const AIEngine &GetParam(ForceType<const AIEngine &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEngine *)instance; }
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
     9
	template <> int Return<AIEngine *>(HSQUIRRELVM vm, AIEngine *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIEngine", res, NULL, DefSQDestructorCallback<AIEngine>); return 1; }
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
    10
}; // namespace SQConvert
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
    11
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
    12
void SQAIEngineRegister(Squirrel *engine) {
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
    13
	DefSQClass <AIEngine> SQAIEngine("AIEngine");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
    14
	SQAIEngine.PreRegister(engine);
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
    15
	SQAIEngine.AddConstructor<void (AIEngine::*)(), 1>(engine, "x");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
    16
9713
7cd214115969 (svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents: 9711
diff changeset
    17
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetClassName,   "GetClassName",   1, "x");
7cd214115969 (svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents: 9711
diff changeset
    18
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::IsValidEngine,  "IsValidEngine",  2, "xi");
7cd214115969 (svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents: 9711
diff changeset
    19
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetName,        "GetName",        2, "xi");
7cd214115969 (svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents: 9711
diff changeset
    20
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetCargoType,   "GetCargoType",   2, "xi");
7cd214115969 (svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents: 9711
diff changeset
    21
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetCapacity,    "GetCapacity",    2, "xi");
7cd214115969 (svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents: 9711
diff changeset
    22
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetReliability, "GetReliability", 2, "xi");
7cd214115969 (svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents: 9711
diff changeset
    23
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetMaxSpeed,    "GetMaxSpeed",    2, "xi");
7cd214115969 (svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents: 9711
diff changeset
    24
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetPrice,       "GetPrice",       2, "xi");
9733
49e424cd4edd (svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents: 9715
diff changeset
    25
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetMaxAge,      "GetMaxAge",      2, "xi");
49e424cd4edd (svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents: 9715
diff changeset
    26
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetRunningCost, "GetRunningCost", 2, "xi");
9713
7cd214115969 (svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents: 9711
diff changeset
    27
	SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetVehicleType, "GetVehicleType", 2, "xi");
9711
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
    28
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
    29
	SQAIEngine.PostRegister(engine);
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff changeset
    30
}