PageRenderTime 23ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/Common/BWAPI/include/BWAPI/Error.h

http://bwapi-mono-bridge.googlecode.com/
C Header | 136 lines | 54 code | 34 blank | 48 comment | 0 complexity | d7eaa508a5d8efb191fc891149e497a6 MD5 | raw file
  1. #pragma once
  2. #include <string>
  3. #include <set>
  4. namespace BWAPI
  5. {
  6. class UnitType;
  7. /** Functions in BWAPI may set an error code. To retrieve the error code, call Game::getLastError. */
  8. class Error
  9. {
  10. public:
  11. Error();
  12. Error(int id);
  13. Error(const Error& other);
  14. Error& operator=(const Error& other);
  15. operator int() const;
  16. /** Returns a unique ID for this error. */
  17. int getID() const;
  18. /** Returns the name of the error. For example Errors::Insufficient_Minerals?.toString() will return a
  19. * std::string object containing "Insufficient Minerals". */
  20. std::string toString() const;
  21. private:
  22. int id;
  23. };
  24. namespace Errors
  25. {
  26. /** Given the name of an error, this function will return the error code. For example:
  27. * Errors::getError("Unbuildable Location") will return Errors::Unbuildable_Location?. */
  28. Error getError(std::string name);
  29. /** The set of all the error codes. */
  30. std::set<Error>& allErrors();
  31. void init();
  32. /** Returned if you try to order a unit or get information from a unit that no longer exists. */
  33. extern const Error Unit_Does_Not_Exist;
  34. /** Returned if you try to retrieve information about a unit that is not currently visible or is dead. */
  35. extern const Error Unit_Not_Visible;
  36. /** Returned when attempting to order a unit that BWAPI does not own (i.e. can't order enemy army to go
  37. * away) */
  38. extern const Error Unit_Not_Owned;
  39. /** Returned when trying to order a unit to do something when it is performing another order or is in a
  40. * state which prevents it from performing the desired order. For example, ordering a Terran Engineering
  41. * Bay to upgrade something while it is already upgrading something else will return this error.
  42. * Similarly, trying to train units from a factory that is lifted will return this error. */
  43. extern const Error Unit_Busy;
  44. /** Returned if you do something weird like try to build a Pylon with an SCV, or train Vultures in a
  45. * Barracks, or order a Hydralisk to lay a spider mine. */
  46. extern const Error Incompatible_UnitType;
  47. /** Returned when trying to use a tech type with the wrong Unit::useTech method. */
  48. extern const Error Incompatible_TechType;
  49. /** Returned if you to do something like try to cancel an upgrade when the unit isn't upgrading. */
  50. extern const Error Incompatible_State;
  51. /** Returned if you try to research something that is already researched. */
  52. extern const Error Already_Researched;
  53. /** Returned if you try to upgrade something that is already fully upgraded. */
  54. extern const Error Fully_Upgraded;
  55. /** Returned if you try to research something that is already being researched. */
  56. extern const Error Currently_Researching;
  57. /** Returned if you try to upgrade something that is already being upgraded. */
  58. extern const Error Currently_Upgrading;
  59. /** Returned if you try to train or build something without enough minerals. */
  60. extern const Error Insufficient_Minerals;
  61. /** Returned if you try to train or build something without enough vespene gas. */
  62. extern const Error Insufficient_Gas;
  63. /** Returned if you try to train something without enough supply. */
  64. extern const Error Insufficient_Supply;
  65. /** Returned if you to do something like try to order a Defiler to cast a Dark Swarm without enough
  66. * energy. */
  67. extern const Error Insufficient_Energy;
  68. /** Returned if you do something like try to train Medics when you don't have an Academy, or try to lay
  69. * Spider Mines before spider mines have been researched. */
  70. extern const Error Insufficient_Tech;
  71. /** Returned if you do something like try to lay Spider Mines when your Vulture is out of Spider Mines.
  72. * Same thing with Reavers and Scarabs. */
  73. extern const Error Insufficient_Ammo;
  74. /** Returned if you try to train more Interceptors than the Carrier can hold, try to train more Scarabs
  75. * than a Reaver can hold, or try to load more units into a transport than there is space. */
  76. extern const Error Insufficient_Space;
  77. /** Returned if you try to build a barracks at TilePositions::None or something similar */
  78. extern const Error Invalid_Tile_Position;
  79. /** Returned if you try to construct a building on an unbuildable location */
  80. extern const Error Unbuildable_Location;
  81. /** Returned if you try to construct a building where the worker cannot reach based on static map data. */
  82. extern const Error Unreachable_Location;
  83. /** Returned if you order an immovable unit, like a Protoss Photon Cannon, to attack a unit that is out of
  84. * range.*/
  85. extern const Error Out_Of_Range;
  86. /** Returned if you do something like order a Vulture to attack a flying unit. */
  87. extern const Error Unable_To_Hit;
  88. /** Returned if you try to get information that is not allowed with the given flag settings. For example,
  89. * trying to read the enemy's resource counts while the CompleteMapInformation? flag is not enabled will
  90. * return this error. Similarly, trying to read the coordinates of the screen or mouse while the UserInput
  91. * flag is not enabled will also return this error. */
  92. extern const Error Access_Denied;
  93. /** Used when a file can't be found. */
  94. extern const Error File_Not_Found;
  95. /** Used for bad parameters, like passing NULL or an empty string. */
  96. extern const Error Invalid_Parameter;
  97. /** Used when no error has been encountered. */
  98. extern const Error None;
  99. /** Used when the error code is not recognized or can not be determined. */
  100. extern const Error Unknown;
  101. }
  102. }