author | rubidium |
Mon, 07 Apr 2008 12:31:50 +0000 | |
branch | noai |
changeset 9871 | dfafb0cf20ee |
parent 9868 | 3998f2e73dda |
child 9873 | b1ab23560ecb |
permissions | -rw-r--r-- |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
1 |
/* $Id$ */ |
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 |
/** @file ai_error.hpp Everything to query errors. */ |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
4 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
5 |
#ifndef AI_ERROR_HPP |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
6 |
#define AI_ERROR_HPP |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
7 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
8 |
#include "ai_object.hpp" |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
9 |
#include <map> |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
10 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
11 |
/** |
9868
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
12 |
* Helper to write precondition enforcers for the AI API in an abbreviated manner. |
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
13 |
* @param returnval The value to return on failure. |
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
14 |
* @param condition The condition that must be obeyed. |
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
15 |
*/ |
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
16 |
#define EnforcePrecondition(returnval, condition) \ |
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
17 |
if (!(condition)) { \ |
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
18 |
AIObject::SetLastError(AIError::ERR_PRECONDITION_FAILED); \ |
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
19 |
return returnval; \ |
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
20 |
} |
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
21 |
|
3998f2e73dda
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
rubidium
parents:
9867
diff
changeset
|
22 |
/** |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
23 |
* Class that handles all error related functions. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
24 |
*/ |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
25 |
class AIError : public AIObject { |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
26 |
public: |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
27 |
static const char *GetClassName() { return "AIError"; } |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
28 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
29 |
/** |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
30 |
* All categories errors can be divided in. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
31 |
*/ |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
32 |
enum ErrorCategories { |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
33 |
ERR_CAT_NONE = 0, //!< Error messages not related to any category. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
34 |
ERR_CAT_GENERAL, //!< Error messages related to general things. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
35 |
ERR_CAT_VEHICLE, //!< Error messages related to building / maintaining vehicles. |
9866
efc38e1f559a
(svn r12559) [NoAI] -Add: SetLastError support for AIAirport.
rubidium
parents:
9865
diff
changeset
|
36 |
ERR_CAT_STATION, //!< Error messages related to building / maintaining stations. |
9867
b7d9ffe24f81
(svn r12589) [NoAI] -Add: GetLastError support for AIBridge.
rubidium
parents:
9866
diff
changeset
|
37 |
ERR_CAT_BRIDGE, //!< Error messages related to building / removing bridges. |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
38 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
39 |
/** |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
40 |
* DO NOT USE! The error bitsize determines how many errors can be stored in |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
41 |
* a category and what the offsets are of all categories. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
42 |
*/ |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
43 |
ERR_CAT_BIT_SIZE = 8, |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
44 |
}; |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
45 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
46 |
/** |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
47 |
* General error messages (0x0100 - 0x0200). |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
48 |
*/ |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
49 |
enum ErrorMessages { |
9861
53fc03195e31
(svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents:
9844
diff
changeset
|
50 |
/** Initial error value */ |
53fc03195e31
(svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents:
9844
diff
changeset
|
51 |
ERR_NONE = ERR_CAT_NONE << ERR_CAT_BIT_SIZE, // [] |
53fc03195e31
(svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents:
9844
diff
changeset
|
52 |
/** If an error occured and the error wasn't mapped */ |
53fc03195e31
(svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents:
9844
diff
changeset
|
53 |
ERR_UNKNOWN, // [] |
9863
73647fe2e301
(svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents:
9861
diff
changeset
|
54 |
/** If a precondition is not met */ |
73647fe2e301
(svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents:
9861
diff
changeset
|
55 |
ERR_PRECONDITION_FAILED, // [] |
9871
dfafb0cf20ee
(svn r12603) [NoAI] -Add: 'support' for telling AIs that the last error message was a NewGRF generated message, so we can't say anything sensible about the real error message.
rubidium
parents:
9868
diff
changeset
|
56 |
/** An error returned by a NewGRF. No possibility to get the exact error in an AI readable format */ |
dfafb0cf20ee
(svn r12603) [NoAI] -Add: 'support' for telling AIs that the last error message was a NewGRF generated message, so we can't say anything sensible about the real error message.
rubidium
parents:
9868
diff
changeset
|
57 |
ERR_NEWGRF_SUPPLIED_ERROR, // [] |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
58 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
59 |
/** Base for general errors */ |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
60 |
ERR_GENERAL_BASE = ERR_CAT_GENERAL << 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
|
61 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
62 |
/** Not enough cash to perform the previous action */ |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
63 |
ERR_NOT_ENOUGH_CASH, // [STR_0003_NOT_ENOUGH_CASH_REQUIRES] |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
64 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
65 |
/** Local authority won't allow the previous action */ |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
66 |
ERR_LOCAL_AUTHORITY_REFUSES, // [STR_2009_LOCAL_AUTHORITY_REFUSES] |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
67 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
68 |
/** The piece of infrastructure you tried to build is already in place */ |
9867
b7d9ffe24f81
(svn r12589) [NoAI] -Add: GetLastError support for AIBridge.
rubidium
parents:
9866
diff
changeset
|
69 |
ERR_ALREADY_BUILT, // [STR_1007_ALREADY_BUILT, STR_5007_MUST_DEMOLISH_BRIDGE_FIRST] |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
70 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
71 |
/** Area isn't clear, try to demolish the building on it */ |
9865
f241472f09dc
(svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
rubidium
parents:
9864
diff
changeset
|
72 |
ERR_AREA_NOT_CLEAR, // [STR_2004_BUILDING_MUST_BE_DEMOLISHED, STR_5007_MUST_DEMOLISH_BRIDGE_FIRST, STR_300B_MUST_DEMOLISH_RAILROAD, STR_300E_MUST_DEMOLISH_AIRPORT_FIRST, STR_MUST_DEMOLISH_CARGO_TRAM_STATION, STR_3047_MUST_DEMOLISH_TRUCK_STATION, STR_MUST_DEMOLISH_PASSENGER_TRAM_STATION, STR_3046_MUST_DEMOLISH_BUS_STATION, STR_306A_BUOY_IN_THE_WAY, STR_304D_MUST_DEMOLISH_DOCK_FIRST, STR_4800_IN_THE_WAY, STR_5804_COMPANY_HEADQUARTERS_IN, STR_5800_OBJECT_IN_THE_WAY, STR_1801_MUST_REMOVE_ROAD_FIRST, STR_1008_MUST_REMOVE_RAILROAD_TRACK, STR_5007_MUST_DEMOLISH_BRIDGE_FIRST, STR_5006_MUST_DEMOLISH_TUNNEL_FIRST] |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
73 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
74 |
/** 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
|
75 |
ERR_AREA_IS_OWNED_BY_ANOTHER_COMPANY, // [STR_1024_AREA_IS_OWNED_BY_ANOTHER] |
9865
f241472f09dc
(svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
rubidium
parents:
9864
diff
changeset
|
76 |
|
f241472f09dc
(svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
rubidium
parents:
9864
diff
changeset
|
77 |
/** The name given is not unique for the object type */ |
f241472f09dc
(svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
rubidium
parents:
9864
diff
changeset
|
78 |
ERR_NAME_IS_NOT_UNIQUE, // [STR_NAME_MUST_BE_UNIQUE] |
f241472f09dc
(svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
rubidium
parents:
9864
diff
changeset
|
79 |
|
f241472f09dc
(svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
rubidium
parents:
9864
diff
changeset
|
80 |
/** The building you want to build requires flat land */ |
f241472f09dc
(svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
rubidium
parents:
9864
diff
changeset
|
81 |
ERR_FLAT_LAND_REQUIRED, // [STR_0007_FLAT_LAND_REQUIRED] |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
82 |
}; |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
83 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
84 |
/** |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
85 |
* Check the membership of the last thrown error. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
86 |
* @return The category the error belongs to. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
87 |
* @note The last throw error can be aquired by calling GetLastError(). |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
88 |
*/ |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
89 |
static ErrorCategories GetErrorCategory(); |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
90 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
91 |
/** |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
92 |
* Get the last error. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
93 |
* @return An ErrorMessages enum value. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
94 |
*/ |
9864
4a9b7b610b13
(svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents:
9863
diff
changeset
|
95 |
static AIErrorType GetLastError(); |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
96 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
97 |
/** |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
98 |
* Get the last error in string format (for human readability). |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
99 |
* @return An ErrorMessage enum item, as string. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
100 |
*/ |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
101 |
static const char *GetLastErrorString(); |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
102 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
103 |
/** |
9863
73647fe2e301
(svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents:
9861
diff
changeset
|
104 |
* Get the error based on the OpenTTD StringID. |
73647fe2e301
(svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents:
9861
diff
changeset
|
105 |
* @note DO NOT INVOKE THIS METHOD YOURSELF! |
73647fe2e301
(svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents:
9861
diff
changeset
|
106 |
* @param internal_string_id The string to convert. |
73647fe2e301
(svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents:
9861
diff
changeset
|
107 |
* @return The NoAI equivalent error message. |
73647fe2e301
(svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents:
9861
diff
changeset
|
108 |
*/ |
9864
4a9b7b610b13
(svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents:
9863
diff
changeset
|
109 |
static AIErrorType StringToError(StringID internal_string_id); |
9863
73647fe2e301
(svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents:
9861
diff
changeset
|
110 |
|
73647fe2e301
(svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents:
9861
diff
changeset
|
111 |
/** |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
112 |
* Map an internal OpenTTD error message to it's NoAI equivalent. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
113 |
* @note DO NOT INVOKE THIS METHOD YOURSELF! The calls are autogenerated. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
114 |
* @param internal_string_id The OpenTTD StringID used for an error. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
115 |
* @param ai_error_msg The NoAI equivalent error message. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
116 |
*/ |
9864
4a9b7b610b13
(svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents:
9863
diff
changeset
|
117 |
static void RegisterErrorMap(StringID internal_string_id, AIErrorType ai_error_msg); |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
118 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
119 |
/** |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
120 |
* Map an internal OpenTTD error message to it's NoAI equivalent. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
121 |
* @note DO NOT INVOKE THIS METHOD YOURSELF! The calls are autogenerated. |
9861
53fc03195e31
(svn r12544) [NoAI] -Codechange: do not force dependency on OTTD internal strings when defining errors.
rubidium
parents:
9844
diff
changeset
|
122 |
* @param ai_error_msg The NoAI error message representation. |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
123 |
* @param message The string representation of this error message, used for debug purposes. |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
124 |
*/ |
9864
4a9b7b610b13
(svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents:
9863
diff
changeset
|
125 |
static void RegisterErrorMapString(AIErrorType ai_error_msg, const char *message); |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
126 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
127 |
private: |
9864
4a9b7b610b13
(svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents:
9863
diff
changeset
|
128 |
typedef std::map<StringID, AIErrorType> AIErrorMap; |
4a9b7b610b13
(svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents:
9863
diff
changeset
|
129 |
typedef std::map<AIErrorType, const char *> AIErrorMapString; |
9844
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
130 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
131 |
static AIErrorMap error_map; |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
132 |
static AIErrorMapString error_map_string; |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
133 |
}; |
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
134 |
|
738b8f69675f
(svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff
changeset
|
135 |
#endif /* AI_ERROR_HPP */ |