PageRenderTime 54ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/skynetbot-read-only/include_/BWAPI/Error.h

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