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

/BWAPI_Beta_3.3/BWAPI_Beta_3.3/include/BWAPI/Error.h

https://bitbucket.org/swishnousky/scai-zerg-team
C Header | 131 lines | 54 code | 31 blank | 46 comment | 0 complexity | 6ac0bf41533157b4e160d1b2b459fa92 MD5 | raw file
Possible License(s): GPL-2.0
  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 when trying to use a tech type with the wrong Unit::useTech method. */
  50. extern const Error Incompatible_TechType;
  51. /** Returned if you to do something like try to cancel an upgrade when the unit isn't upgrading. */
  52. extern const Error Incompatible_State;
  53. /** Returned if you try to research something that is already researched. */
  54. extern const Error Already_Researched;
  55. /** Returned if you try to upgrade something that is already fully upgraded. */
  56. extern const Error Fully_Upgraded;
  57. /** Returned if you try to research something that is already being researched. */
  58. extern const Error Currently_Researching;
  59. /** Returned if you try to upgrade something that is already being upgraded. */
  60. extern const Error Currently_Upgrading;
  61. /** Returned if you try to train or build something without enough minerals. */
  62. extern const Error Insufficient_Minerals;
  63. /** Returned if you try to train or build something without enough vespene gas. */
  64. extern const Error Insufficient_Gas;
  65. /** Returned if you try to train something without enough supply. */
  66. extern const Error Insufficient_Supply;
  67. /** Returned if you to do something like try to order a Defiler to cast a Dark Swarm without enough
  68. * energy. */
  69. extern const Error Insufficient_Energy;
  70. /** Returned if you do something like try to train Medics when you don't have an Academy, or try to lay
  71. * Spider Mines before spider mines have been researched. */
  72. extern const Error Insufficient_Tech;
  73. /** Returned if you do something like try to lay Spider Mines when your Vulture is out of Spider Mines.
  74. * Same thing with Reavers and Scarabs. */
  75. extern const Error Insufficient_Ammo;
  76. /** Returned if you try to train more Interceptors than the Carrier can hold, try to train more Scarabs
  77. * than a Reaver can hold, or try to load more units into a transport than there is space. */
  78. extern const Error Insufficient_Space;
  79. /** Returned if you try to build a barracks at TilePositions::None or something similar */
  80. extern const Error Invalid_Tile_Position;
  81. /** Returned if you try to construct a building on an unbuildable location */
  82. extern const Error Unbuildable_Location;
  83. /** Returned if you try to construct a building where the worker cannot reach based on static map data. */
  84. extern const Error Unreachable_Location;
  85. /** Returned if you order an immovable unit, like a Protoss Photon Cannon, to attack a unit that is out of
  86. * range.*/
  87. extern const Error Out_Of_Range;
  88. /** Returned if you do something like order a Vulture to attack a flying unit. */
  89. extern const Error Unable_To_Hit;
  90. /** Returned if you try to get information that is not allowed with the given flag settings. For example,
  91. * trying to read the enemy's resource counts while the CompleteMapInformation? flag is not enabled will
  92. * return this error. Similarly, trying to read the coordinates of the screen or mouse while the UserInput
  93. * flag is not enabled will also return this error. */
  94. extern const Error Access_Denied;
  95. /** Used when no error has been encountered. */
  96. extern const Error None;
  97. /** Used when the error code is not recognized or can not be determined. */
  98. extern const Error Unknown;
  99. }
  100. }