src/ai/api/ai_marine.hpp.sq
author rubidium
Tue, 08 Apr 2008 07:24:23 +0000
branchnoai
changeset 10094 e737405b06dd
parent 9741 53c1c5850e01
child 10212 1e0a2a182253
permissions -rw-r--r--
(svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
9691
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
     1
#include "ai_marine.hpp"
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
     2
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
     3
namespace SQConvert {
10094
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
     4
	/* Allow enums to be used as Squirrel parameters */
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
     5
	template <> AIMarine::ErrorMessages GetParam(ForceType<AIMarine::ErrorMessages>, HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIMarine::ErrorMessages)tmp; }
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
     6
	template <> int Return<AIMarine::ErrorMessages>(HSQUIRRELVM vm, AIMarine::ErrorMessages res) { sq_pushinteger(vm, (int32)res); return 1; }
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
     7
9691
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
     8
	/* Allow AIMarine to be used as Squirrel parameter */
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
     9
	template <> AIMarine *GetParam(ForceType<AIMarine *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIMarine *)instance; }
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    10
	template <> AIMarine &GetParam(ForceType<AIMarine &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIMarine *)instance; }
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    11
	template <> const AIMarine *GetParam(ForceType<const AIMarine *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIMarine *)instance; }
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    12
	template <> const AIMarine &GetParam(ForceType<const AIMarine &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIMarine *)instance; }
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    13
	template <> int Return<AIMarine *>(HSQUIRRELVM vm, AIMarine *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIMarine", res, NULL, DefSQDestructorCallback<AIMarine>); return 1; }
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    14
}; // namespace SQConvert
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    15
9741
53c1c5850e01 (svn r12221) [NoAI] -Fix: Register functions are no _Register functions, and always on top of the sort list
truebrain
parents: 9737
diff changeset
    16
void SQAIMarine_Register(Squirrel *engine) {
9691
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    17
	DefSQClass <AIMarine> SQAIMarine("AIMarine");
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    18
	SQAIMarine.PreRegister(engine);
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    19
	SQAIMarine.AddConstructor<void (AIMarine::*)(), 1>(engine, "x");
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    20
10094
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
    21
	SQAIMarine.DefSQConst(engine, AIMarine::ERR_MARINE_BASE,                   "ERR_MARINE_BASE");
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
    22
	SQAIMarine.DefSQConst(engine, AIMarine::ERR_MARINE_MUST_BE_BUILT_ON_WATER, "ERR_MARINE_MUST_BE_BUILT_ON_WATER");
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
    23
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
    24
	AIError::RegisterErrorMap(STR_3801_MUST_BE_BUILT_ON_WATER, AIMarine::ERR_MARINE_MUST_BE_BUILT_ON_WATER);
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
    25
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
    26
	AIError::RegisterErrorMapString(AIMarine::ERR_MARINE_MUST_BE_BUILT_ON_WATER, "ERR_MARINE_MUST_BE_BUILT_ON_WATER");
e737405b06dd (svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents: 9741
diff changeset
    27
9691
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    28
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::GetClassName,     "GetClassName",     1, "x");
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    29
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsWaterDepotTile, "IsWaterDepotTile", 2, "xi");
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    30
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsDockTile,       "IsDockTile",       2, "xi");
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    31
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsBuoyTile,       "IsBuoyTile",       2, "xi");
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    32
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsLockTile,       "IsLockTile",       2, "xi");
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    33
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsCanalTile,      "IsCanalTile",      2, "xi");
9737
ee408edf3851 (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)
truebrain
parents: 9691
diff changeset
    34
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::BuildWaterDepot,  "BuildWaterDepot",  3, "xib");
ee408edf3851 (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)
truebrain
parents: 9691
diff changeset
    35
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::BuildDock,        "BuildDock",        2, "xi");
ee408edf3851 (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)
truebrain
parents: 9691
diff changeset
    36
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::BuildBuoy,        "BuildBuoy",        2, "xi");
ee408edf3851 (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)
truebrain
parents: 9691
diff changeset
    37
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::BuildLock,        "BuildLock",        2, "xi");
ee408edf3851 (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)
truebrain
parents: 9691
diff changeset
    38
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::BuildCanal,       "BuildCanal",       2, "xi");
ee408edf3851 (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)
truebrain
parents: 9691
diff changeset
    39
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::RemoveWaterDepot, "RemoveWaterDepot", 2, "xi");
ee408edf3851 (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)
truebrain
parents: 9691
diff changeset
    40
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::RemoveDock,       "RemoveDock",       2, "xi");
ee408edf3851 (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)
truebrain
parents: 9691
diff changeset
    41
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::RemoveBuoy,       "RemoveBuoy",       2, "xi");
ee408edf3851 (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)
truebrain
parents: 9691
diff changeset
    42
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::RemoveLock,       "RemoveLock",       2, "xi");
ee408edf3851 (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)
truebrain
parents: 9691
diff changeset
    43
	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::RemoveCanal,      "RemoveCanal",      2, "xi");
9691
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    44
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    45
	SQAIMarine.PostRegister(engine);
1231d4e5f5aa (svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
truelight
parents:
diff changeset
    46
}