src/ai/api/ai_error.hpp.sq
author rubidium
Thu, 03 Apr 2008 13:28:46 +0000
branchnoai
changeset 9861 53fc03195e31
parent 9844 738b8f69675f
child 9863 73647fe2e301
permissions -rw-r--r--
(svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
9844
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
     1
#include "ai_error.hpp"
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
     2
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
     3
namespace SQConvert {
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
     4
	/* Allow enums to be used as Squirrel parameters */
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
     5
	template <> AIError::ErrorCategories GetParam(ForceType<AIError::ErrorCategories>, HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIError::ErrorCategories)tmp; }
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
     6
	template <> int Return<AIError::ErrorCategories>(HSQUIRRELVM vm, AIError::ErrorCategories res) { sq_pushinteger(vm, (int32)res); return 1; }
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
     7
	template <> AIError::ErrorMessages GetParam(ForceType<AIError::ErrorMessages>, HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIError::ErrorMessages)tmp; }
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
     8
	template <> int Return<AIError::ErrorMessages>(HSQUIRRELVM vm, AIError::ErrorMessages res) { sq_pushinteger(vm, (int32)res); return 1; }
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
     9
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    10
	/* Allow AIError to be used as Squirrel parameter */
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    11
	template <> AIError *GetParam(ForceType<AIError *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIError *)instance; }
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    12
	template <> AIError &GetParam(ForceType<AIError &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIError *)instance; }
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    13
	template <> const AIError *GetParam(ForceType<const AIError *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIError *)instance; }
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    14
	template <> const AIError &GetParam(ForceType<const AIError &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIError *)instance; }
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    15
	template <> int Return<AIError *>(HSQUIRRELVM vm, AIError *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIError", res, NULL, DefSQDestructorCallback<AIError>); return 1; }
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    16
}; // namespace SQConvert
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    17
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    18
void SQAIError_Register(Squirrel *engine) {
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    19
	DefSQClass <AIError> SQAIError("AIError");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    20
	SQAIError.PreRegister(engine);
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    21
	SQAIError.AddConstructor<void (AIError::*)(), 1>(engine, "x");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    22
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    23
	SQAIError.DefSQConst(engine, AIError::ERR_CAT_NONE,                         "ERR_CAT_NONE");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    24
	SQAIError.DefSQConst(engine, AIError::ERR_CAT_GENERAL,                      "ERR_CAT_GENERAL");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    25
	SQAIError.DefSQConst(engine, AIError::ERR_CAT_VEHICLE,                      "ERR_CAT_VEHICLE");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    26
	SQAIError.DefSQConst(engine, AIError::ERR_CAT_BIT_SIZE,                     "ERR_CAT_BIT_SIZE");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    27
	SQAIError.DefSQConst(engine, AIError::ERR_NONE,                             "ERR_NONE");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    28
	SQAIError.DefSQConst(engine, AIError::ERR_UNKNOWN,                          "ERR_UNKNOWN");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    29
	SQAIError.DefSQConst(engine, AIError::ERR_GENERAL_BASE,                     "ERR_GENERAL_BASE");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    30
	SQAIError.DefSQConst(engine, AIError::ERR_NOT_ENOUGH_CASH,                  "ERR_NOT_ENOUGH_CASH");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    31
	SQAIError.DefSQConst(engine, AIError::ERR_LOCAL_AUTHORITY_REFUSES,          "ERR_LOCAL_AUTHORITY_REFUSES");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    32
	SQAIError.DefSQConst(engine, AIError::ERR_ALREADY_BUILT,                    "ERR_ALREADY_BUILT");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    33
	SQAIError.DefSQConst(engine, AIError::ERR_AREA_NOT_CLEAR,                   "ERR_AREA_NOT_CLEAR");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    34
	SQAIError.DefSQConst(engine, AIError::ERR_AREA_IS_OWNED_BY_ANOTHER_COMPANY, "ERR_AREA_IS_OWNED_BY_ANOTHER_COMPANY");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    35
9861
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    36
	AIError::RegisterErrorMap(STR_0003_NOT_ENOUGH_CASH_REQUIRES,    AIError::ERR_NOT_ENOUGH_CASH);
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    37
	AIError::RegisterErrorMap(STR_2009_LOCAL_AUTHORITY_REFUSES,     AIError::ERR_LOCAL_AUTHORITY_REFUSES);
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    38
	AIError::RegisterErrorMap(STR_1007_ALREADY_BUILT,               AIError::ERR_ALREADY_BUILT);
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    39
	AIError::RegisterErrorMap(STR_2004_BUILDING_MUST_BE_DEMOLISHED, AIError::ERR_AREA_NOT_CLEAR);
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    40
	AIError::RegisterErrorMap(STR_1024_AREA_IS_OWNED_BY_ANOTHER,    AIError::ERR_AREA_IS_OWNED_BY_ANOTHER_COMPANY);
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    41
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    42
	AIError::RegisterErrorMapString(AIError::ERR_NONE,                             "ERR_NONE");
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    43
	AIError::RegisterErrorMapString(AIError::ERR_UNKNOWN,                          "ERR_UNKNOWN");
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    44
	AIError::RegisterErrorMapString(AIError::ERR_NOT_ENOUGH_CASH,                  "ERR_NOT_ENOUGH_CASH");
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    45
	AIError::RegisterErrorMapString(AIError::ERR_LOCAL_AUTHORITY_REFUSES,          "ERR_LOCAL_AUTHORITY_REFUSES");
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    46
	AIError::RegisterErrorMapString(AIError::ERR_ALREADY_BUILT,                    "ERR_ALREADY_BUILT");
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    47
	AIError::RegisterErrorMapString(AIError::ERR_AREA_NOT_CLEAR,                   "ERR_AREA_NOT_CLEAR");
53fc03195e31 (svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents: 9844
diff changeset
    48
	AIError::RegisterErrorMapString(AIError::ERR_AREA_IS_OWNED_BY_ANOTHER_COMPANY, "ERR_AREA_IS_OWNED_BY_ANOTHER_COMPANY");
9844
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    49
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    50
	SQAIError.DefSQStaticMethod(engine, &AIError::GetClassName,           "GetClassName",           1, "x");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    51
	SQAIError.DefSQStaticMethod(engine, &AIError::GetErrorCategory,       "GetErrorCategory",       1, "x");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    52
	SQAIError.DefSQStaticMethod(engine, &AIError::GetLastError,           "GetLastError",           1, "x");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    53
	SQAIError.DefSQStaticMethod(engine, &AIError::GetLastErrorString,     "GetLastErrorString",     1, "x");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    54
	SQAIError.DefSQStaticMethod(engine, &AIError::RegisterErrorMap,       "RegisterErrorMap",       3, "xii");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    55
	SQAIError.DefSQStaticMethod(engine, &AIError::RegisterErrorMapString, "RegisterErrorMapString", 3, "xis");
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    56
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    57
	SQAIError.PostRegister(engine);
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    58
}