src/ai/api/ai_error.hpp
author rubidium
Sun, 06 Apr 2008 14:12:19 +0000
branchnoai
changeset 9868 3998f2e73dda
parent 9867 b7d9ffe24f81
child 9871 dfafb0cf20ee
permissions -rw-r--r--
(svn r12590) [NoAI] -Add: EnforcePrecondition macro to make code much better readable.
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,                      // []
9844
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
		/** 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
    58
		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
    59
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    60
		/** 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
    61
		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
    62
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    63
		/** 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
    64
		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
    65
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    66
		/** 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
    67
		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
    68
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    69
		/** 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
    70
		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
    71
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    72
		/** 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
    73
		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
    74
f241472f09dc (svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
rubidium
parents: 9864
diff changeset
    75
		/** 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
    76
		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
    77
f241472f09dc (svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
rubidium
parents: 9864
diff changeset
    78
		/** The building you want to build requires flat land */
f241472f09dc (svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
rubidium
parents: 9864
diff changeset
    79
		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
    80
	};
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    81
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
	 * 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
    84
	 * @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
    85
	 * @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
    86
	 */
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    87
	static ErrorCategories GetErrorCategory();
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
	/**
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    90
	 * 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
    91
	 * @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
    92
	 */
9864
4a9b7b610b13 (svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents: 9863
diff changeset
    93
	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
    94
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    95
	/**
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    96
	 * 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
    97
	 * @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
    98
	 */
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
    99
	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
   100
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
   101
	/**
9863
73647fe2e301 (svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents: 9861
diff changeset
   102
	 * 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
   103
	 * @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
   104
	 * @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
   105
	 * @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
   106
	 */
9864
4a9b7b610b13 (svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents: 9863
diff changeset
   107
	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
   108
73647fe2e301 (svn r12552) [NoAI] -Change: do not force the use of StringIDs when setting errors.
rubidium
parents: 9861
diff changeset
   109
	/**
9844
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
   110
	 * 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
   111
	 * @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
   112
	 * @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
   113
	 * @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
   114
	 */
9864
4a9b7b610b13 (svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents: 9863
diff changeset
   115
	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
   116
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
   117
	/**
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
   118
	 * 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
   119
	 * @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
   120
	 * @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
   121
	 * @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
   122
	 */
9864
4a9b7b610b13 (svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents: 9863
diff changeset
   123
	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
   124
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
   125
private:
9864
4a9b7b610b13 (svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents: 9863
diff changeset
   126
	typedef std::map<StringID, AIErrorType> AIErrorMap;
4a9b7b610b13 (svn r12554) [NoAI] -Codechange: add more typing information.
rubidium
parents: 9863
diff changeset
   127
	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
   128
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
   129
	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
   130
	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
   131
};
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
   132
738b8f69675f (svn r12510) [NoAI] -Add: added AIError, which allows you to catch errors triggered by commands (Morloth)
truebrain
parents:
diff changeset
   133
#endif /* AI_ERROR_HPP */