PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/bwapi-clr-embedded/MonoBridge/include/BWAPI/Error.h

http://bwapi-mono-bridge.googlecode.com/
C Header | 124 lines | 51 code | 28 blank | 45 comment | 0 complexity | 079d9be4fa48540a9df958d9558ccb5f 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. bool operator==(const Error& other) const;
  16. bool operator!=(const Error& other) const;
  17. bool operator<(const Error& other) const;
  18. /** Returns a unique ID for this error. */
  19. int getID() const;
  20. /** Returns the name of the error. For example Errors::Insufficient_Minerals?.toString() will return a
  21. * std::string object containing "Insufficient Minerals". */
  22. std::string toString() const;
  23. private:
  24. int id;
  25. };
  26. namespace Errors
  27. {
  28. /** Given the name of an error, this function will return the error code. For example:
  29. * Errors::getError("Unbuildable Location") will return Errors::Unbuildable_Location?. */
  30. Error getError(std::string name);
  31. /** The set of all the error codes. */
  32. std::set<Error>& allErrors();
  33. void init();
  34. /** Returned if you try to order a unit or get information from a unit that no longer exists. */
  35. extern const Error Unit_Does_Not_Exist;
  36. /** Returned if you try to retrieve information about a unit that is not currently visible or is dead. */
  37. extern const Error Unit_Not_Visible;
  38. /** Returned when attempting to order a unit that BWAPI does not own (i.e. can't order enemy army to go
  39. * away) */
  40. extern const Error Unit_Not_Owned;
  41. /** Returned when trying to order a unit to do something when it is performing another order or is in a
  42. * state which prevents it from performing the desired order. For example, ordering a Terran Engineering
  43. * Bay to upgrade something while it is already upgrading something else will return this error.
  44. * Similarly, trying to train units from a factory that is lifted will return this error. */
  45. extern const Error Unit_Busy;
  46. /** Returned if you do something weird like try to build a Pylon with an SCV, or train Vultures in a
  47. * Barracks, or order a Hydralisk to lay a spider mine. */
  48. extern const Error Incompatible_UnitType;
  49. /** Returned if when trying to use a tech type with the wrong Unit::useTech method. */
  50. extern const Error Incompatible_TechType;
  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 build something on unbuildable terrain (either from the buildability map data
  75. * or if a unit is in the way). For build tiles that are not visible, we could just use the buildability
  76. * map data and assume that no units are blocking it (to prevent cheating). */
  77. extern const Error Insufficient_Space;
  78. /** Returned if you order an immovable unit, like a Protoss Photon Cannon, to attack a unit that is out
  79. * of range. */
  80. extern const Error Unbuildable_Location;
  81. /** Returned if you order an immovable unit, like a Protoss Photon Cannon, to attack a unit that is out of
  82. * range.*/
  83. extern const Error Out_Of_Range;
  84. /** Returned if you do something like order a Vulture to attack a flying unit. */
  85. extern const Error Unable_To_Hit;
  86. /** Returned if you try to get information that is not allowed with the given flag settings. For example,
  87. * trying to read the enemy's resource counts while the CompleteMapInformation? flag is not enabled will
  88. * return this error. Similarly, trying to read the coordinates of the screen or mouse while the UserInput
  89. * flag is not enabled will also return this error. */
  90. extern const Error Access_Denied;
  91. /** Used when no error has been encountered. */
  92. extern const Error None;
  93. /** Used when the error code is not recognized or can not be determined. */
  94. extern const Error Unknown;
  95. }
  96. }