Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bwapi/BWAPI/Source/BWAPI/GameDrawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ namespace BWAPI
switch ( s )
{
case BWAPIC::ShapeType::Text:
bwDrawText(x1,y1,shapeStrings.at(shape.extra1).c_str(),ctype,(char)shape.extra2);
break;
if (shape.extra1 >= shapeStrings.size()) break;
bwDrawText(x1,y1,shapeStrings.at(shape.extra1).c_str(),ctype,(char)shape.extra2);
break;
case BWAPIC::ShapeType::Box:
x2 = shape.x2;
y2 = shape.y2;
Expand Down
4 changes: 2 additions & 2 deletions bwapi/OpenBWData/BW/BWData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ struct ui_wrapper {
struct draw_ui_wrapper {
draw_ui_wrapper(bwgame::state& st, std::string mpq_path) {}
std::tuple<int, int, uint32_t*> draw(int x, int y, int width, int height) {
return {0, 0, nullptr};
return std::tuple<int, int, uint32_t*>(0, 0, nullptr);
}
};

Expand Down Expand Up @@ -1587,7 +1587,7 @@ void Game::setRandomSeed(uint32_t value)
impl->st.lcg_rand_state = value;
}

void Game::disableTriggers()
void Game::disableTriggers()
{
impl->st.trigger_timer = -1;
}
Expand Down
12 changes: 6 additions & 6 deletions bwapi/include/BWAPI/BestFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,41 @@ namespace BWAPI
// Constructor
template <typename _T>
BestFilter(const _T &predicate) : pred(predicate)
{};
{}

// Assignment
template <typename _T>
BestFilter<_PARAM> &operator =(const _T &other)
{
this->pred = other;
return *this;
};
}

// Bitwise operators
template <typename _T>
inline BestFilter<_PARAM> operator &&(const _T &other) const
{
return [=](_PARAM p1, _PARAM p2)->_PARAM{ return other( (*this)(p1, p2) ); };
};
}

// call
inline _PARAM operator()(const _PARAM &p1, const _PARAM &p2) const
{
return this->pred(p1, p2);
};
}

};

template <typename _PARAM>
BestFilter<_PARAM> Lowest(const CompareFilter<_PARAM,int> &filter)
{
return [=](_PARAM p1, _PARAM p2)->_PARAM{ return filter(p2) < filter(p1) ? p2 : p1; };
};
}
template <typename _PARAM>
BestFilter<_PARAM> Highest(const CompareFilter<_PARAM,int> &filter)
{
return [=](_PARAM p1, _PARAM p2)->_PARAM{ return filter(p2) > filter(p1) ? p2 : p1; };
};
}

}

2 changes: 1 addition & 1 deletion bwapi/include/BWAPI/BulletType.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ namespace BWAPI
constexpr BulletType Neutron_Flare{Enum::Neutron_Flare};
constexpr BulletType None{Enum::None};
constexpr BulletType Unknown{Enum::Unknown};
};
}
static_assert(sizeof(BulletType) == sizeof(int), "Expected type to resolve to primitive size.");
}
10 changes: 5 additions & 5 deletions bwapi/include/BWAPI/ComparisonFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,27 @@ namespace BWAPI
// Division
template <typename T>
CompareFilter<PType,RType,std::function<RType(PType)> > operator /(const T &other) const
{
{
return [=](PType v)->int{ int rval = other(v);
return rval == 0 ? std::numeric_limits<int>::max() : (*this)(v) / rval;
};
};
}

// Modulus
template <typename T>
CompareFilter<PType,RType,std::function<RType(PType)> > operator %(const T &other) const
{
{
return [=](PType v)->int{ int rval = other(v);
return rval == 0 ? 0 : (*this)(v) % rval;
};
};
}

// call
inline RType operator()(PType u) const
{
return pred(u);
};

inline bool isValid() const
{
return (bool)pred;
Expand Down
8 changes: 4 additions & 4 deletions bwapi/include/BWAPI/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ namespace BWAPI
Unknown,
MAX
};
};
};
}
}

/// <summary>The Error object is generally used to determine why certain functions in BWAPI
/// have failed.</summary>
///
Expand All @@ -71,7 +71,7 @@ namespace BWAPI
///
/// @returns Set of error types.
const Error::set& allErrors();

constexpr Error Unit_Does_Not_Exist{Enum::Unit_Does_Not_Exist};
constexpr Error Unit_Not_Visible{Enum::Unit_Not_Visible};
constexpr Error Unit_Not_Owned{Enum::Unit_Not_Owned};
Expand Down
4 changes: 2 additions & 2 deletions bwapi/include/BWAPI/ExplosionType.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ namespace BWAPI
Unknown,
MAX
};
};
};
}
}
/// <summary>A representation of a weapon's explosion type.</summary> This indicates how the
/// weapon behaves, such as if it deals splash damage or causes an effect to occur.
///
Expand Down
38 changes: 19 additions & 19 deletions bwapi/include/BWAPI/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace BWAPI
typedef PlayerInterface *Player;
class Playerset;
class Race;

class RegionInterface;
typedef RegionInterface *Region;

Expand Down Expand Up @@ -218,7 +218,7 @@ namespace BWAPI
/// Example:
/// @code
/// BWAPI::Broodwar->setLocalSpeed(0);
///
///
/// // Log and display the best logical FPS seen in the game
/// static int bestFPS = 0;
/// bestFPS = std::max(bestFPS, BWAPI::Broodwar->getFPS());
Expand Down Expand Up @@ -460,7 +460,7 @@ namespace BWAPI
/// The distance from \p center to search for units. If omitted, then the entire map is
/// searched.
/// </param>
///
///
/// @returns The desired unit that best matches the given criteria.
/// @retval nullptr if a suitable unit was not found.
///
Expand Down Expand Up @@ -604,7 +604,7 @@ namespace BWAPI
/// <param name="tileY">
/// The y value of the tile to check.
/// </param>
///
///
/// @returns boolean identifying the visibility of the tile. If the given tile is visible, then
/// the value is true. If the given tile is concealed by the fog of war, then this value will
/// be false.
Expand All @@ -622,7 +622,7 @@ namespace BWAPI
/// <param name="tileY">
/// The y tile coordinate to check.
/// </param>
///
///
/// @retval true If the player has explored the given tile position (partially revealed fog).
/// @retval false If the tile position was never explored (completely black fog).
///
Expand Down Expand Up @@ -680,7 +680,7 @@ namespace BWAPI
/// omitted, then only the immediate tile position is checked for power, and the function
/// will assume that the location requires power for any unit type.
/// </param>
///
///
/// @retval true if the type at the given tile position will receive power.
/// @retval false if the type will be unpowered at the given tile position.
bool hasPower(int tileX, int tileY, UnitType unitType = UnitTypes::None) const;
Expand Down Expand Up @@ -792,9 +792,9 @@ namespace BWAPI
/// <summary>Prints text to the screen as a notification.</summary> This function allows text
/// formatting using Text::Enum members. The behaviour of this function is the same as printf,
/// located in header cstdio.
///
///
/// @note That text printed through this function is not seen by other players or in replays.
///
///
/// <param name="format">
/// Text formatting. See std::printf for more information. Refrain from passing non-constant
/// strings directly in this parameter.
Expand All @@ -816,7 +816,7 @@ namespace BWAPI
///
/// @see printf
/*55*/ virtual void vPrintf(const char *format, va_list args) = 0;

/// <summary>Sends a text message to all other players in the game.</summary> The behaviour of
/// this function is the same as std::printf, located in header cstdio.
///
Expand All @@ -829,7 +829,7 @@ namespace BWAPI
///
/// @see sendTextEx, std::printf
void sendText(const char *format, ...);

/// @copydoc sendText
///
/// This function is intended to forward an already-existing argument list.
Expand All @@ -856,7 +856,7 @@ namespace BWAPI
///
/// @see sendText, std::printf
void sendTextEx(bool toAllies, const char *format, ...);

/// @copydoc sendTextEx
///
/// This function is intended to forward an already-existing argument list.
Expand Down Expand Up @@ -959,13 +959,13 @@ namespace BWAPI
/// <summary>Retrieves the set of units that are currently selected by the user outside of
/// BWAPI.</summary> This function requires that Flag::UserInput be enabled.
///
/// @returns A Unitset containing the user's selected units. If Flag::UserInput is disabled,
/// @returns A Unitset containing the user's selected units. If Flag::UserInput is disabled,
/// then this set is always empty.
///
/// @see enableFlag
virtual const Unitset& getSelectedUnits() const = 0;

/// <summary>Retrieves the player object that BWAPI is controlling.</summary>
/// <summary>Retrieves the player object that BWAPI is controlling.</summary>
///
/// @returns Pointer to Player interface object representing the current player.
/// @retval nullptr if the current game is a replay.
Expand Down Expand Up @@ -1318,7 +1318,7 @@ namespace BWAPI
/// frame.
/// @see getRemainingLatencyTime, getLatencyFrames
virtual int getRemainingLatencyFrames() const = 0;

/// <summary>Retrieves the number of milliseconds it will take before a command sent in the
/// current frame will be executed by Broodwar.</summary>
///
Expand Down Expand Up @@ -1450,7 +1450,7 @@ namespace BWAPI
///
/// @note If making queries on a unit, it's better to call UnitInterface::hasPath, since it is
/// a more lenient version of this function that accounts for some edge cases.
///
///
/// <param name="source">
/// The source position.
/// </param>
Expand Down Expand Up @@ -1568,7 +1568,7 @@ namespace BWAPI
/// - Cancel_Upgrade
/// .
/// .
/// - 3: Extensive optimization
/// - 3: Extensive optimization
/// - Includes the optimizations made by all previous levels.
/// - Units may behave or move differently than expected.
/// - Units performing the following actions are grouped and ordered 12 at a time:
Expand Down Expand Up @@ -1730,7 +1730,7 @@ namespace BWAPI
/// @returns This game's random seed.
/// @since 4.2.0
virtual unsigned getRandomSeed() const = 0;

virtual void setCharacterName(const std::string& name) = 0;
virtual void setGameType(GameType gameType) = 0;
virtual void setAIModule(AIModule* module) = 0;
Expand Down Expand Up @@ -1775,10 +1775,10 @@ namespace BWAPI
// Pass whatever into the stream
ss << in;
return *this;
};
}
/// @overload
GameWrapper &operator <<(ostream_manipulator fn);

/// <summary>Flushes the Broodwar stream, printing all text in the stream to the screen.</summary>
void flush();
};
Expand Down
6 changes: 3 additions & 3 deletions bwapi/include/BWAPI/GameType.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ namespace BWAPI
Unknown,
MAX
};
};
};
}
}
/// <summary>A class that represents game types in Broodwar.</summary> A game type is selected
/// when creating a game.
///
Expand All @@ -58,7 +58,7 @@ namespace BWAPI
///
/// @returns Set of available GameTypes.
const GameType::set& allGameTypes();

constexpr GameType Melee{Enum::Melee};
constexpr GameType Free_For_All{Enum::Free_For_All};
constexpr GameType One_on_One{Enum::One_on_One};
Expand Down
10 changes: 5 additions & 5 deletions bwapi/include/BWAPI/Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace BWAPI
/// <param name="key">
/// The key containing the value to retrieve. Default is 0.
/// </param>
///
///
/// @retval nullptr if index is out of bounds.
/// @returns The client info at the given index.
/// @see setClientInfo
Expand All @@ -70,7 +70,7 @@ namespace BWAPI
CT getClientInfo(int key = 0) const
{
return (CT)(long)this->getClientInfo(key);
};
}

/// <summary>Associates one or more pointers or values with any BWAPI interface.</summary>
///
Expand All @@ -89,10 +89,10 @@ namespace BWAPI
///
/// @see getClientInfo
template < typename V >
void setClientInfo(const V &clientInfo, int key = 0)
void setClientInfo(const V &clientInfoIn, int key = 0)
{
this->clientInfo[key] = (void*)clientInfo;
};
this->clientInfo[key] = (void*)clientInfoIn;
}

/// <summary>Registers an event and associates it with the current Interface object.</summary>
/// Events can be used to automate tasks (like train X @Marines until Y of them have been
Expand Down
2 changes: 1 addition & 1 deletion bwapi/include/BWAPI/Order.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ namespace BWAPI
constexpr Order Fatal{Enum::Fatal};
constexpr Order None{Enum::None};
constexpr Order Unknown{Enum::Unknown};
};
}

static_assert(sizeof(Order) == sizeof(int), "Expected type to resolve to primitive size.");
}
2 changes: 1 addition & 1 deletion bwapi/include/BWAPI/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,4 +654,4 @@ namespace BWAPI
virtual void setMinerals(int value)= 0;
virtual void setGas(int value) = 0;
};
};
}
8 changes: 4 additions & 4 deletions bwapi/include/BWAPI/PlayerType.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ namespace BWAPI
Unknown,
MAX
};
};
};
}
}
/// <summary>Represents the type of controller for the player slot (i.e. human, computer).</summary>
///
///
/// @see PlayerTypes
/// @ingroup TypeClasses
class PlayerType : public Type<PlayerType, PlayerTypes::Enum::Unknown>
Expand Down Expand Up @@ -64,7 +64,7 @@ namespace BWAPI
///
/// @returns Set consisting of all valid PlayerTypes.
const PlayerType::set& allPlayerTypes();

constexpr PlayerType None{Enum::None};
constexpr PlayerType Computer{Enum::Computer};
constexpr PlayerType Player{Enum::Player};
Expand Down
Loading