#include <ai_error.hpp>
Public Types | |
enum | ErrorCategories { ERR_CAT_NONE = 0, ERR_CAT_GENERAL, ERR_CAT_VEHICLE, ERR_CAT_STATION, ERR_CAT_BRIDGE, ERR_CAT_TUNNEL, ERR_CAT_TILE, ERR_CAT_SIGN, ERR_CAT_RAIL, ERR_CAT_ROAD, ERR_CAT_ORDER, ERR_CAT_MARINE, ERR_CAT_BIT_SIZE = 8 } |
All categories errors can be divided in. More... | |
enum | ErrorMessages { ERR_NONE = ERR_CAT_NONE << ERR_CAT_BIT_SIZE, ERR_UNKNOWN, ERR_PRECONDITION_FAILED, ERR_PRECONDITION_STRING_TOO_LONG, ERR_NEWGRF_SUPPLIED_ERROR, ERR_GENERAL_BASE = ERR_CAT_GENERAL << ERR_CAT_BIT_SIZE, ERR_NOT_ENOUGH_CASH, ERR_LOCAL_AUTHORITY_REFUSES, ERR_ALREADY_BUILT, ERR_AREA_NOT_CLEAR, ERR_OWNED_BY_ANOTHER_COMPANY, ERR_NAME_IS_NOT_UNIQUE, ERR_FLAT_LAND_REQUIRED, ERR_LAND_SLOPED_WRONG, ERR_VEHICLE_IN_THE_WAY, ERR_SITE_UNSUITABLE, ERR_TOO_CLOSE_TO_EDGE, ERR_STATION_TOO_SPREAD_OUT } |
All general related error messages. More... | |
Static Public Member Functions | |
static const char * | GetClassName () |
static ErrorCategories | GetErrorCategory () |
Check the membership of the last thrown error. | |
static AIErrorType | GetLastError () |
Get the last error. | |
static char * | GetLastErrorString () |
Get the last error in string format (for human readability). | |
static AIErrorType | StringToError (StringID internal_string_id) |
Get the error based on the OpenTTD StringID. | |
static void | RegisterErrorMap (StringID internal_string_id, AIErrorType ai_error_msg) |
Map an internal OpenTTD error message to it's NoAI equivalent. | |
static void | RegisterErrorMapString (AIErrorType ai_error_msg, const char *message) |
Map an internal OpenTTD error message to it's NoAI equivalent. | |
Private Types | |
typedef std::map< StringID, AIErrorType > | AIErrorMap |
typedef std::map< AIErrorType, const char * > | AIErrorMapString |
Static Private Attributes | |
static AIErrorMap | error_map = AIError::AIErrorMap() |
static AIErrorMapString | error_map_string = AIError::AIErrorMapString() |
Definition at line 37 of file ai_error.hpp.
All categories errors can be divided in.
Definition at line 44 of file ai_error.hpp.
All general related error messages.
ERR_NONE | Initial error value. |
ERR_UNKNOWN | If an error occured and the error wasn't mapped. |
ERR_PRECONDITION_FAILED | If a precondition is not met. |
ERR_PRECONDITION_STRING_TOO_LONG | A string supplied was too long. |
ERR_NEWGRF_SUPPLIED_ERROR |
An error returned by a NewGRF.
No possibility to get the exact error in an AI readable format |
ERR_GENERAL_BASE | Base for general errors. |
ERR_NOT_ENOUGH_CASH | Not enough cash to perform the previous action. |
ERR_LOCAL_AUTHORITY_REFUSES | Local authority won't allow the previous action. |
ERR_ALREADY_BUILT | The piece of infrastructure you tried to build is already in place. |
ERR_AREA_NOT_CLEAR | Area isn't clear, try to demolish the building on it. |
ERR_OWNED_BY_ANOTHER_COMPANY | Area / property is owned by another company. |
ERR_NAME_IS_NOT_UNIQUE | The name given is not unique for the object type. |
ERR_FLAT_LAND_REQUIRED | The building you want to build requires flat land. |
ERR_LAND_SLOPED_WRONG | Land is sloped in the wrong direction for this build action. |
ERR_VEHICLE_IN_THE_WAY | A vehicle is in the way. |
ERR_SITE_UNSUITABLE | Site is unsuitable. |
ERR_TOO_CLOSE_TO_EDGE | Too close to the edge of the map. |
ERR_STATION_TOO_SPREAD_OUT | Station is too spread out. |
Definition at line 68 of file ai_error.hpp.
AIError::ErrorCategories AIError::GetErrorCategory | ( | ) | [static] |
Check the membership of the last thrown error.
Definition at line 57 of file ai_error.cpp.
References ERR_CAT_BIT_SIZE, and GetLastError().
AIErrorType AIError::GetLastError | ( | ) | [static] |
Get the last error.
Reimplemented from AIObject.
Definition at line 11 of file ai_error.cpp.
References AIObject::GetLastError().
Referenced by GetErrorCategory(), and GetLastErrorString().
char * AIError::GetLastErrorString | ( | ) | [static] |
Get the last error in string format (for human readability).
Definition at line 16 of file ai_error.cpp.
References GetLastError().
AIErrorType AIError::StringToError | ( | StringID | internal_string_id | ) | [static] |
Get the error based on the OpenTTD StringID.
internal_string_id | The string to convert. |
Definition at line 21 of file ai_error.cpp.
References ERR_NEWGRF_SUPPLIED_ERROR, ERR_UNKNOWN, and GB().
Referenced by AIObject::DoCommand().
void AIError::RegisterErrorMap | ( | StringID | internal_string_id, | |
AIErrorType | ai_error_msg | |||
) | [static] |
Map an internal OpenTTD error message to it's NoAI equivalent.
internal_string_id | The OpenTTD StringID used for an error. | |
ai_error_msg | The NoAI equivalent error message. |
Definition at line 47 of file ai_error.cpp.
void AIError::RegisterErrorMapString | ( | AIErrorType | ai_error_msg, | |
const char * | message | |||
) | [static] |
Map an internal OpenTTD error message to it's NoAI equivalent.
ai_error_msg | The NoAI error message representation. | |
message | The string representation of this error message, used for debug purposes. |
Definition at line 52 of file ai_error.cpp.