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