src/ai/api/ai_vehicle.hpp.sq
author rubidium
Sun, 03 Feb 2008 20:17:54 +0000
branchnoai
changeset 9724 b39bc69bb2f2
parent 9711 c8b427215c9d
child 9733 49e424cd4edd
permissions -rw-r--r--
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
9596
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
     1
#include "ai_vehicle.hpp"
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
     2
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
     3
namespace SQConvert {
9684
623970482fb2 (svn r10633) [NoAI] -Add: added GetVehicleType and AIVehicle::VehicleType
truelight
parents: 9680
diff changeset
     4
	/* Allow enums to be used as Squirrel parameters */
623970482fb2 (svn r10633) [NoAI] -Add: added GetVehicleType and AIVehicle::VehicleType
truelight
parents: 9680
diff changeset
     5
	template <> AIVehicle::VehicleType GetParam(ForceType<AIVehicle::VehicleType>, HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIVehicle::VehicleType)tmp; }
623970482fb2 (svn r10633) [NoAI] -Add: added GetVehicleType and AIVehicle::VehicleType
truelight
parents: 9680
diff changeset
     6
	template <> int Return<AIVehicle::VehicleType>(HSQUIRRELVM vm, AIVehicle::VehicleType res) { sq_pushinteger(vm, (int32)res); return 1; }
623970482fb2 (svn r10633) [NoAI] -Add: added GetVehicleType and AIVehicle::VehicleType
truelight
parents: 9680
diff changeset
     7
9596
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
     8
	/* Allow AIVehicle to be used as Squirrel parameter */
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
     9
	template <> AIVehicle *GetParam(ForceType<AIVehicle *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIVehicle *)instance; }
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    10
	template <> AIVehicle &GetParam(ForceType<AIVehicle &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIVehicle *)instance; }
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    11
	template <> const AIVehicle *GetParam(ForceType<const AIVehicle *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIVehicle *)instance; }
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    12
	template <> const AIVehicle &GetParam(ForceType<const AIVehicle &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIVehicle *)instance; }
9680
5ed7bbfd51c7 (svn r10629) [NoAI] -Fix: on returning a class instance which is NULL, do not make a wrapper SQ, but return a NULL pointer too
truelight
parents: 9679
diff changeset
    13
	template <> int Return<AIVehicle *>(HSQUIRRELVM vm, AIVehicle *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIVehicle", res, NULL, DefSQDestructorCallback<AIVehicle>); return 1; }
9596
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    14
}; // namespace SQConvert
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    15
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    16
void SQAIVehicleRegister(Squirrel *engine) {
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    17
	DefSQClass <AIVehicle> SQAIVehicle("AIVehicle");
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    18
	SQAIVehicle.PreRegister(engine);
9635
9ee82e091af7 (svn r10526) [NoAI] -Fix: a class with params for the constructor lost his instance when called from SQ (templates can be really useful ;))
truelight
parents: 9615
diff changeset
    19
	SQAIVehicle.AddConstructor<void (AIVehicle::*)(), 1>(engine, "x");
9596
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    20
9684
623970482fb2 (svn r10633) [NoAI] -Add: added GetVehicleType and AIVehicle::VehicleType
truelight
parents: 9680
diff changeset
    21
	SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_RAIL,    "VEHICLE_RAIL");
623970482fb2 (svn r10633) [NoAI] -Add: added GetVehicleType and AIVehicle::VehicleType
truelight
parents: 9680
diff changeset
    22
	SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_ROAD,    "VEHICLE_ROAD");
623970482fb2 (svn r10633) [NoAI] -Add: added GetVehicleType and AIVehicle::VehicleType
truelight
parents: 9680
diff changeset
    23
	SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_WATER,   "VEHICLE_WATER");
623970482fb2 (svn r10633) [NoAI] -Add: added GetVehicleType and AIVehicle::VehicleType
truelight
parents: 9680
diff changeset
    24
	SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_AIR,     "VEHICLE_AIR");
9687
7548e2e60f7c (svn r10674) [NoAI] -Fix: AIVehicle SQ file was out-dated
truelight
parents: 9684
diff changeset
    25
	SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_INVALID, "VEHICLE_INVALID");
9684
623970482fb2 (svn r10633) [NoAI] -Add: added GetVehicleType and AIVehicle::VehicleType
truelight
parents: 9680
diff changeset
    26
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9610
diff changeset
    27
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetClassName,      "GetClassName",      1, "x");
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9610
diff changeset
    28
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsValidVehicle,    "IsValidVehicle",    2, "xi");
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9610
diff changeset
    29
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetLocation,       "GetLocation",       2, "xi");
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9610
diff changeset
    30
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetEngineType,     "GetEngineType",     2, "xi");
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9610
diff changeset
    31
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetUnitNumber,     "GetUnitNumber",     2, "xi");
9699
e1b5f29cc6f9 (svn r10940) [NoAI] -Add: added AIVehicle::GetName and AIVehicle::SetName to set vehicle names
truelight
parents: 9691
diff changeset
    32
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetName,           "GetName",           2, "xi");
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9610
diff changeset
    33
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetAge,            "GetAge",            2, "xi");
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9610
diff changeset
    34
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetMaxAge,         "GetMaxAge",         2, "xi");
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9610
diff changeset
    35
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetAgeLeft,        "GetAgeLeft",        2, "xi");
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9610
diff changeset
    36
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitThisYear, "GetProfitThisYear", 2, "xi");
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9610
diff changeset
    37
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitLastYear, "GetProfitLastYear", 2, "xi");
9684
623970482fb2 (svn r10633) [NoAI] -Add: added GetVehicleType and AIVehicle::VehicleType
truelight
parents: 9680
diff changeset
    38
	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetVehicleType,    "GetVehicleType",    2, "xi");
9596
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    39
9711
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents: 9709
diff changeset
    40
	SQAIVehicle.DefSQMethod(engine, &AIVehicle::BuildVehicle,       "BuildVehicle",       3, "xii");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents: 9709
diff changeset
    41
	SQAIVehicle.DefSQMethod(engine, &AIVehicle::CloneVehicle,       "CloneVehicle",       4, "xiib");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents: 9709
diff changeset
    42
	SQAIVehicle.DefSQMethod(engine, &AIVehicle::RefitVehicle,       "RefitVehicle",       3, "xii");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents: 9709
diff changeset
    43
	SQAIVehicle.DefSQMethod(engine, &AIVehicle::SellVehicle,        "SellVehicle",        2, "xi");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents: 9709
diff changeset
    44
	SQAIVehicle.DefSQMethod(engine, &AIVehicle::SendVehicleToDepot, "SendVehicleToDepot", 2, "xi");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents: 9709
diff changeset
    45
	SQAIVehicle.DefSQMethod(engine, &AIVehicle::IsInDepot,          "IsInDepot",          2, "xi");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents: 9709
diff changeset
    46
	SQAIVehicle.DefSQMethod(engine, &AIVehicle::IsStoppedInDepot,   "IsStoppedInDepot",   2, "xi");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents: 9709
diff changeset
    47
	SQAIVehicle.DefSQMethod(engine, &AIVehicle::StartStopVehicle,   "StartStopVehicle",   2, "xi");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents: 9709
diff changeset
    48
	SQAIVehicle.DefSQMethod(engine, &AIVehicle::SkipToVehicleOrder, "SkipToVehicleOrder", 3, "xii");
c8b427215c9d (svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents: 9709
diff changeset
    49
	SQAIVehicle.DefSQMethod(engine, &AIVehicle::SetName,            "SetName",            3, "xis");
9596
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    50
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    51
	SQAIVehicle.PostRegister(engine);
8af5a1399842 (svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
diff changeset
    52
}