BWAPI
Public Member Functions | Private Member Functions | Private Attributes
BaseClass Class Reference

#include <Base.h>

Collaboration diagram for BaseClass:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 BaseClass (Region region, std::set< TilePosition > tiles, bool startLocation)
 BaseClass (TilePosition position, const UnitGroup &resources, Region region, std::set< TilePosition > tiles, bool startLocation)
void update ()
TilePosition getCenterBuildLocation () const
Position getCenterLocation () const
const UnitGroupgetMinerals () const
const UnitGroupgetGeysers () const
const UnitGroupgetRefineries () const
Unit getResourceDepot () const
bool isActive (bool activeInFuture=false) const
bool isMinedOut () const
bool isUnderAttack () const
bool isContested () const
bool isStartLocation () const
const UnitGroupgetBuildings () const
unsigned int getNumberOfTechBuildings () const
Player getPlayer () const
void onDiscover (Unit unit)
void onMorphRenegade (Unit unit, Player previousPlayer, BWAPI::UnitType previousType)
void onDestroy (Unit unit)
void drawDebugInfo () const
Region getRegion () const
const std::set< TilePosition > & getTiles () const
bool isEnemyBase () const
bool isMyBase () const
bool isAllyBase () const
Unit getClosestEnemyBuilding (Position pos)
const UnitGroupgetEnemyThreats () const
const UnitGroup getDefenders () const
bool depotCompare (const Unit &depotOne, const Unit &depotTwo)
unsigned int getActivateTime () const

Private Member Functions

void updatePlayer ()
void addUnit (Unit unit)
void removeUnit (Unit unit, Player playerToRemove, BWAPI::UnitType typeToRemove)

Private Attributes

Position mCenterPosition
TilePosition mCenterTilePosition
UnitGroup mMinerals
UnitGroup mGeysers
UnitGroup mRefineries
bool mActive
bool mActiveInFuture
unsigned int mActivateTime
bool mMinedOut
bool mIsUnderAttack
bool mIsContested
unsigned int mTechBuildings
bool mIsStartLocation
Player mPlayer
UnitGroup mBuildings
std::deque< UnitmResourceDepots
WeakRegion mRegion
std::set< TilePositionmTiles
std::map< Player, int > mPlayerBuildingNumbers
UnitGroup mAllThreats
std::map< UnitThreatType,
UnitGroup
mThreatTypes
UnitGroup mAllDefenders
UnitGroup mLiftedBuildings

Detailed Description

Definition at line 22 of file Base.h.


Constructor & Destructor Documentation

BaseClass::BaseClass ( Region  region,
std::set< TilePosition tiles,
bool  startLocation 
)

Definition at line 11 of file Base.cpp.

        : mCenterTilePosition(BWAPI::TilePositions::None)
        , mCenterPosition(region->getCenter())
        , mMinedOut(true)
        , mRegion(region)
        , mIsStartLocation(startLocation)
        , mPlayer(NULL)
        , mBuildings()
        , mTiles(tiles)
        , mIsUnderAttack(false)
        , mIsContested(false)
        , mTechBuildings(0)
{
}
BaseClass::BaseClass ( TilePosition  position,
const UnitGroup resources,
Region  region,
std::set< TilePosition tiles,
bool  startLocation 
)

Definition at line 26 of file Base.cpp.

References UnitGroup::insert(), mGeysers, mMinerals, and BWAPI::UnitTypes::Resource_Mineral_Field.

        : mCenterTilePosition(position)
        , mCenterPosition(Position(position.x()*32+64, position.y()*32+48))
        , mMinedOut(false)
        , mRegion(region)
        , mIsStartLocation(startLocation)
        , mPlayer(NULL)
        , mBuildings()
        , mTiles(tiles)
        , mIsUnderAttack(false)
        , mIsContested(false)
        , mTechBuildings(0)
{
        for each(Unit resource in resources)
        {
                if(resource->getType() == BWAPI::UnitTypes::Resource_Mineral_Field)
                        mMinerals.insert(resource);
                else
                        mGeysers.insert(resource);
        }
}

Here is the call graph for this function:


Member Function Documentation

void BaseClass::addUnit ( Unit  unit) [private]

Definition at line 390 of file Base.cpp.

References BWAPI::Broodwar, depotCompare(), UnitGroup::insert(), BWAPI::UnitType::isBuilding(), BWAPI::UnitType::isRefinery(), BWAPI::UnitType::isResourceDepot(), UnitHelper::isStaticDefense(), mBuildings, mGeysers, mPlayerBuildingNumbers, mRefineries, mResourceDepots, mTechBuildings, mTiles, BWAPI::Game::neutral(), BWAPI::UnitTypes::Resource_Vespene_Geyser, BWAPI::UnitType::supplyProvided(), and updatePlayer().

Referenced by onDiscover(), onMorphRenegade(), and update().

{
        if(mTiles.count(unit->getTilePosition()) == 0)
                return;

        const BWAPI::UnitType &type = unit->getType();

        if(type == BWAPI::UnitTypes::Resource_Vespene_Geyser)
                mGeysers.insert(unit);

        if(type.isBuilding() && unit->getPlayer() != BWAPI::Broodwar->neutral() && !unit->isLifted())
        {
                mBuildings.insert(unit);
                ++mPlayerBuildingNumbers[unit->getPlayer()];

                if(type.isResourceDepot())
                {
                        mResourceDepots.push_front(unit);
                        if(mResourceDepots.size() > 1)
                                std::sort(mResourceDepots.begin(), mResourceDepots.end(), boost::bind<bool>(&BaseClass::depotCompare, this, _1, _2));
                }

                if(!type.isResourceDepot() && type.supplyProvided() == 0 && !UnitHelper::isStaticDefense(type) && !type.isRefinery())
                        ++mTechBuildings;

                updatePlayer();
        }

        if(type.isRefinery())
                mRefineries.insert(unit);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool BaseClass::depotCompare ( const Unit depotOne,
const Unit depotTwo 
)

Definition at line 195 of file Base.cpp.

References mCenterPosition.

Referenced by addUnit().

{
        int thisDistance = depotOne->getPosition().getApproxDistance(mCenterPosition);
        int currentDistance = depotTwo->getPosition().getApproxDistance(mCenterPosition);

        return thisDistance < currentDistance;
}

Here is the caller graph for this function:

void BaseClass::drawDebugInfo ( ) const

Definition at line 219 of file Base.cpp.

References BWAPI::Colors::Blue, BWAPI::Broodwar, BWAPI::Game::drawCircle(), BWAPI::Game::drawCircleMap(), BWAPI::Game::drawLine(), BWAPI::Game::drawLineMap(), BWAPI::Game::drawTextMap(), UnitGroup::empty(), BWAPI::Player::getColor(), BWAPI::Player::getName(), BWAPI::Colors::Green, isAllyBase(), isEnemyBase(), isMyBase(), mActive, mActiveInFuture, mAllThreats, BWAPI::CoordinateType::Map, mBuildings, mCenterPosition, mGeysers, mIsContested, mIsStartLocation, mIsUnderAttack, mMinedOut, mMinerals, mPlayer, mRefineries, mTechBuildings, BWAPI::Game::neutral(), BWAPI::Colors::Orange, BWAPI::Colors::Red, UnitGroup::size(), BWAPI::Position::x(), and BWAPI::Position::y().

{
        if(mPlayer != NULL)
                BWAPI::Broodwar->drawCircle(BWAPI::CoordinateType::Map, mCenterPosition.x(), mCenterPosition.y(), 78, mPlayer->getColor(), false);
        else
                BWAPI::Broodwar->drawCircle(BWAPI::CoordinateType::Map, mCenterPosition.x(), mCenterPosition.y(), 78, BWAPI::Broodwar->neutral()->getColor(), false);

        bool showtitle = false;
        int ypos = 30;

        if(mIsStartLocation)
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Start Location");
                ypos -= 10;
                showtitle = true;
        }

        if(!mBuildings.empty())
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Buildings: %u", mBuildings.size());
                ypos -= 10;
                showtitle = true;
        }

        if(mTechBuildings > 0)
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Number of Tech Buildings: %d", mTechBuildings);
                ypos -= 10;
                showtitle = true;
        }

        if(mPlayer != NULL)
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Owner: %s", mPlayer->getName().c_str());
                ypos -= 10;
                showtitle = true;
        }

        if(isEnemyBase())
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Is Enemy");
                ypos -= 10;
                showtitle = true;
        }

        if(isAllyBase())
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Is Ally");
                ypos -= 10;
                showtitle = true;
        }

        if(isMyBase())
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Is Mine");
                ypos -= 10;
                showtitle = true;
        }

        if(mIsContested)
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Base is Contested");
                ypos -= 10;
                showtitle = true;
        }

        if(mIsUnderAttack)
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Base is Under Attack");
                ypos -= 10;
                showtitle = true;
        }

        if(mActive)
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Base is Active");
                ypos -= 10;
                showtitle = true;
        }
        else if(mActiveInFuture)
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Base is Active In Future");
                ypos -= 10;
                showtitle = true;
        }

        if(mMinedOut)
        {
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - ypos, "Base is mined out");
                ypos -= 10;
                showtitle = true;
        }

        if(showtitle)
                BWAPI::Broodwar->drawTextMap(mCenterPosition.x() + 60, mCenterPosition.y() - 40, "Base Info:");

        for each(Unit unit in mAllThreats)
        {
                BWAPI::Broodwar->drawLineMap(unit->getPosition().x(), unit->getPosition().y(), mCenterPosition.x(), mCenterPosition.y(), BWAPI::Colors::Red);
        }
        for each(Unit building in mBuildings)
        {
                BWAPI::Broodwar->drawLine(BWAPI::CoordinateType::Map, building->getPosition().x(), building->getPosition().y(), mCenterPosition.x(), mCenterPosition.y(), building->getPlayer()->getColor());
        }

        for each(Unit mineral in mMinerals)
        {
                BWAPI::Broodwar->drawCircleMap(mineral->getPosition().x(), mineral->getPosition().y(), 32, BWAPI::Colors::Blue);
                BWAPI::Broodwar->drawLineMap(mineral->getPosition().x(), mineral->getPosition().y(), mCenterPosition.x(), mCenterPosition.y(), BWAPI::Colors::Blue);
        }
        for each(Unit geyser in mGeysers)
        {
                BWAPI::Broodwar->drawCircleMap(geyser->getPosition().x(), geyser->getPosition().y(), 32, BWAPI::Colors::Green);
                BWAPI::Broodwar->drawLineMap(geyser->getPosition().x(), geyser->getPosition().y(), mCenterPosition.x(), mCenterPosition.y(), BWAPI::Colors::Green);
        }
        for each(Unit geyser in mRefineries)
        {
                BWAPI::Broodwar->drawCircleMap(geyser->getPosition().x(), geyser->getPosition().y(), 32, BWAPI::Colors::Orange);
                BWAPI::Broodwar->drawLineMap(geyser->getPosition().x(), geyser->getPosition().y(), mCenterPosition.x(), mCenterPosition.y(), BWAPI::Colors::Green);
        }
}

Here is the call graph for this function:

unsigned int BaseClass::getActivateTime ( ) const [inline]

Definition at line 72 of file Base.h.

References mActivateTime.

{ return mActivateTime; }
const UnitGroup& BaseClass::getBuildings ( ) const [inline]

Definition at line 46 of file Base.h.

References mBuildings.

{ return mBuildings; }

Definition at line 30 of file Base.h.

References mCenterTilePosition.

{ return mCenterTilePosition; }

Definition at line 31 of file Base.h.

References mCenterPosition.

{ return mCenterPosition; }

Definition at line 341 of file Base.cpp.

References BWAPI::Broodwar, and mBuildings.

{
        int minDist = std::numeric_limits<int>::max();
        Unit bestBuilding;

        for each(Unit unit in mBuildings)
        {
                if(!BWAPI::Broodwar->self()->isEnemy(unit->getPlayer()))
                        continue;

                int thisDist = pos.getApproxDistance(unit->getPosition());
                if(thisDist < minDist)
                {
                        minDist = thisDist;
                        bestBuilding = unit;
                }
        }

        return bestBuilding;
}
const UnitGroup BaseClass::getDefenders ( ) const [inline]

Definition at line 68 of file Base.h.

References mAllDefenders.

{ return mAllDefenders; }
const UnitGroup& BaseClass::getEnemyThreats ( ) const [inline]

Definition at line 67 of file Base.h.

References mAllThreats.

{ return mAllThreats; }
const UnitGroup& BaseClass::getGeysers ( ) const [inline]

Definition at line 34 of file Base.h.

References mGeysers.

{ return mGeysers; }
const UnitGroup& BaseClass::getMinerals ( ) const [inline]

Definition at line 33 of file Base.h.

References mMinerals.

{ return mMinerals; }
unsigned int BaseClass::getNumberOfTechBuildings ( ) const [inline]

Definition at line 47 of file Base.h.

References mTechBuildings.

{ return mTechBuildings; }
Player BaseClass::getPlayer ( ) const [inline]

Definition at line 49 of file Base.h.

References mPlayer.

Referenced by updatePlayer().

{ return mPlayer; }

Here is the caller graph for this function:

const UnitGroup& BaseClass::getRefineries ( ) const [inline]

Definition at line 35 of file Base.h.

References mRefineries.

{ return mRefineries; }
Region BaseClass::getRegion ( ) const [inline]

Definition at line 57 of file Base.h.

References mRegion.

{ return mRegion.lock(); }
Unit BaseClass::getResourceDepot ( ) const [inline]

Definition at line 37 of file Base.h.

References mResourceDepots, and StaticUnits::nullunit.

const std::set<TilePosition>& BaseClass::getTiles ( ) const [inline]

Definition at line 59 of file Base.h.

References mTiles.

{ return mTiles; }
bool BaseClass::isActive ( bool  activeInFuture = false) const [inline]

Definition at line 38 of file Base.h.

References mActive, and mActiveInFuture.

{ return (mActive || (activeInFuture && mActiveInFuture)); }
bool BaseClass::isAllyBase ( ) const [inline]

Definition at line 63 of file Base.h.

References BWAPI::Broodwar, BWAPI::Player::isAlly(), mPlayer, and BWAPI::Game::self().

Referenced by drawDebugInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

bool BaseClass::isContested ( ) const [inline]

Definition at line 42 of file Base.h.

References mIsContested.

{ return mIsContested; }
bool BaseClass::isEnemyBase ( ) const [inline]

Definition at line 61 of file Base.h.

References BWAPI::Broodwar, BWAPI::Player::isEnemy(), mPlayer, and BWAPI::Game::self().

Referenced by drawDebugInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

bool BaseClass::isMinedOut ( ) const [inline]

Definition at line 40 of file Base.h.

References mMinedOut.

{ return mMinedOut; }
bool BaseClass::isMyBase ( ) const [inline]

Definition at line 62 of file Base.h.

References BWAPI::Broodwar, mPlayer, and BWAPI::Game::self().

Referenced by drawDebugInfo().

{ return mPlayer == BWAPI::Broodwar->self(); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool BaseClass::isStartLocation ( ) const [inline]

Definition at line 44 of file Base.h.

References mIsStartLocation.

{ return mIsStartLocation; }
bool BaseClass::isUnderAttack ( ) const [inline]

Definition at line 41 of file Base.h.

References mIsUnderAttack.

{ return mIsUnderAttack; }
void BaseClass::onDestroy ( Unit  unit)

Definition at line 214 of file Base.cpp.

References removeUnit().

{
        removeUnit(unit, unit->getPlayer(), unit->getType());
}

Here is the call graph for this function:

void BaseClass::onDiscover ( Unit  unit)

Definition at line 203 of file Base.cpp.

References addUnit().

{
        addUnit(unit);
}

Here is the call graph for this function:

void BaseClass::onMorphRenegade ( Unit  unit,
Player  previousPlayer,
BWAPI::UnitType  previousType 
)

Definition at line 208 of file Base.cpp.

References addUnit(), BWAPI::UnitTypes::None, and removeUnit().

{
        removeUnit(unit, previousPlayer != NULL ? previousPlayer : unit->getPlayer(), previousType != BWAPI::UnitTypes::None ? previousType : unit->getType());
        addUnit(unit);
}

Here is the call graph for this function:

void BaseClass::removeUnit ( Unit  unit,
Player  playerToRemove,
BWAPI::UnitType  typeToRemove 
) [private]

Definition at line 422 of file Base.cpp.

References UnitGroup::end(), UnitGroup::erase(), UnitGroup::find(), BWAPI::UnitType::isRefinery(), BWAPI::UnitType::isResourceDepot(), UnitHelper::isStaticDefense(), mBuildings, mGeysers, mMinerals, mPlayerBuildingNumbers, mRefineries, mResourceDepots, mTechBuildings, BWAPI::UnitType::supplyProvided(), and updatePlayer().

Referenced by onDestroy(), onMorphRenegade(), and update().

{
        mRefineries.erase(unit);
        mGeysers.erase(unit);
        mMinerals.erase(unit);

        std::set<Unit>::iterator it = mBuildings.find(unit);
        if(it != mBuildings.end())
        {
                mBuildings.erase(it);
                --mPlayerBuildingNumbers[playerToRemove];
                if(mPlayerBuildingNumbers[playerToRemove] == 0)
                        mPlayerBuildingNumbers.erase(playerToRemove);

                mResourceDepots.erase(std::remove(mResourceDepots.begin(), mResourceDepots.end(), unit), mResourceDepots.end());

                if(!typeToRemove.isResourceDepot() && typeToRemove.supplyProvided() == 0 && !UnitHelper::isStaticDefense(typeToRemove) && !typeToRemove.isRefinery())
                        --mTechBuildings;

                updatePlayer();
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 48 of file Base.cpp.

References addUnit(), UnitGroup::begin(), BWAPI::Broodwar, UnitGroup::clear(), UnitGroup::empty(), UnitGroup::end(), UnitGroup::insert(), Singleton< T >::Instance(), UnitHelper::isArmyUnit(), BWAPI::UnitType::isWorker(), AccessTypeDef::Lost, mActivateTime, mActive, mActiveInFuture, mAllDefenders, mAllThreats, mBuildings, mGeysers, mIsUnderAttack, mLiftedBuildings, mMinedOut, mMinerals, mPlayer, mRefineries, mResourceDepots, mThreatTypes, mTiles, UnitGroup::ratingDifference(), removeUnit(), and UnitGroup::size().

{
        if(!mMinedOut)
        {
                bool noGas = true;
                for each(Unit geyser in mGeysers)
                {
                        if(geyser->getResources() > 0)
                                noGas = false;
                }
                for each(Unit geyser in mRefineries)
                {
                        if(geyser->getResources() > 0)
                                noGas = false;
                }

                if(mMinerals.empty() && noGas)
                        mMinedOut = true;
        }

        for(UnitGroup::iterator it = mBuildings.begin(); it != mBuildings.end();)
        {
                if((*it)->isLifted() || (*it)->accessibility() == AccessType::Lost)
                {
                        Unit unit = *it;
                        ++it;
                        removeUnit(unit, unit->getPlayer(), unit->getType());
                }
                else
                        ++it;
        }

        // TODO: Move this to the base manager and make a generic add building and remove building
        for each(Unit unit in mLiftedBuildings)
        {
                if(!unit->isLifted() && unit->exists())
                        addUnit(unit);
        }

        mLiftedBuildings.clear();
        for each(Unit unit in UnitTracker::Instance().getAllUnits())
        {
                if(unit->getType().isBuilding() && unit->isLifted())
                        mLiftedBuildings.insert(unit);
        }

        mAllThreats.clear();
        mThreatTypes.clear();
        mAllDefenders.clear();
        int workerCount = 0;

        if(mPlayer && mPlayer != BWAPI::Broodwar->neutral())
        {
                for each(Unit defender in UnitTracker::Instance().selectAllUnits(mPlayer))
                {
                        if(!defender->isCompleted())
                                continue;

                        const BWAPI::UnitType &type = defender->getType();
                        if(!UnitHelper::isArmyUnit(type) && !type.isWorker())
                                continue;

                        if(mTiles.count(defender->getTilePosition()) == 0)
                                continue;

                        if(type.isWorker())
                        {
                                if(workerCount > 14)//Only count 14 as thats the only amount it will pull from the mineral line
                                        continue;
                                else
                                        ++workerCount;
                        }

                        mAllDefenders.insert(defender);
                }

                for each(Unit enemy in UnitTracker::Instance().selectAllEnemy(mPlayer))
                {
                        if(enemy->getType().isBuilding() && !enemy->isLifted())
                                continue;

                        if(enemy->accessibility() == AccessType::Lost)
                                continue;

                        if(mTiles.count(enemy->getTilePosition()) != 0)
                        {
                                mAllThreats.insert(enemy);
                                mThreatTypes[UnitThreatType::Scout].insert(enemy);
                        }

                        if(enemy->getType().isWorker())
                                continue;

                        const int maxRange = std::max(48, 24 + std::max(enemy->getGroundWeaponMaxRange(), enemy->getAirWeaponMaxRange()));

                        for each(Unit building in mBuildings)
                        {
                                if(enemy->getDistance(building) <= maxRange)
                                {
                                        mAllThreats.insert(enemy);

                                        if(enemy->getType().isFlyer() || enemy->isLifted())
                                        {
                                                if(enemy->canAttackGround())
                                                        mThreatTypes[UnitThreatType::AirToGround].insert(enemy);
                                                if(enemy->canAttackAir())
                                                        mThreatTypes[UnitThreatType::AirToAir].insert(enemy);
                                        }
                                        else
                                        {
                                                if(enemy->canAttackGround())
                                                        mThreatTypes[UnitThreatType::GroundToGround].insert(enemy);
                                                if(enemy->canAttackAir())
                                                        mThreatTypes[UnitThreatType::GroundToAir].insert(enemy);
                                        }

                                        break;
                                }
                        }
                }
        }

        mActive = false;
        mActiveInFuture = false;
        mActivateTime = std::numeric_limits<int>::max();
        mIsUnderAttack = !mThreatTypes[UnitThreatType::AirToGround].empty() || !mThreatTypes[UnitThreatType::GroundToGround].empty();
        if(!mResourceDepots.empty())
        {
                if(!mMinedOut)
                {
                        if(!mIsUnderAttack && mResourceDepots[0]->isCompleted())
                        {
                                mActive = true;
                                mActiveInFuture = true;
                                mActivateTime = 0;
                        }
                        else if(!mIsUnderAttack || (mAllDefenders.size() > 6 && mAllDefenders.ratingDifference(mThreatTypes[UnitThreatType::AirToGround] + mThreatTypes[UnitThreatType::GroundToGround]) >= 150))
                        {
                                mActiveInFuture = true;
                                mActivateTime = mResourceDepots[0]->getCompletedTime();
                        }
                }
        }

        //drawDebugInfo();
}

Here is the call graph for this function:

void BaseClass::updatePlayer ( ) [private]

Definition at line 362 of file Base.cpp.

References getPlayer(), mIsContested, mPlayer, mPlayerBuildingNumbers, and mResourceDepots.

Referenced by addUnit(), and removeUnit().

{
        mIsContested = false;
        if(mPlayerBuildingNumbers.empty())
                mPlayer = NULL;
        else if(mPlayerBuildingNumbers.size() == 1)
                mPlayer = mPlayerBuildingNumbers.begin()->first;
        else
        {
                mIsContested = true;
                if(!mResourceDepots.empty())
                        mPlayer = mResourceDepots[0]->getPlayer();
                else
                {
                        mPlayer = NULL;
                        int number = 0;
                        for each(std::pair<Player, int> pair in mPlayerBuildingNumbers)
                        {
                                if(pair.second > number)
                                {
                                        mPlayer = pair.first;
                                        number = pair.second;
                                }
                        }
                }
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

unsigned int BaseClass::mActivateTime [private]

Definition at line 84 of file Base.h.

Referenced by getActivateTime(), and update().

bool BaseClass::mActive [private]

Definition at line 82 of file Base.h.

Referenced by drawDebugInfo(), isActive(), and update().

Definition at line 83 of file Base.h.

Referenced by drawDebugInfo(), isActive(), and update().

Definition at line 106 of file Base.h.

Referenced by getDefenders(), and update().

Definition at line 103 of file Base.h.

Referenced by drawDebugInfo(), getEnemyThreats(), and update().

Definition at line 95 of file Base.h.

Referenced by addUnit(), drawDebugInfo(), getBuildings(), getClosestEnemyBuilding(), removeUnit(), and update().

Definition at line 75 of file Base.h.

Referenced by depotCompare(), drawDebugInfo(), and getCenterLocation().

Definition at line 76 of file Base.h.

Referenced by getCenterBuildLocation().

Definition at line 79 of file Base.h.

Referenced by addUnit(), BaseClass(), drawDebugInfo(), getGeysers(), removeUnit(), and update().

bool BaseClass::mIsContested [private]

Definition at line 88 of file Base.h.

Referenced by drawDebugInfo(), isContested(), and updatePlayer().

Definition at line 91 of file Base.h.

Referenced by drawDebugInfo(), and isStartLocation().

bool BaseClass::mIsUnderAttack [private]

Definition at line 87 of file Base.h.

Referenced by drawDebugInfo(), isUnderAttack(), and update().

Definition at line 108 of file Base.h.

Referenced by update().

bool BaseClass::mMinedOut [private]

Definition at line 86 of file Base.h.

Referenced by drawDebugInfo(), isMinedOut(), and update().

Definition at line 78 of file Base.h.

Referenced by BaseClass(), drawDebugInfo(), getMinerals(), removeUnit(), and update().

Definition at line 93 of file Base.h.

Referenced by drawDebugInfo(), getPlayer(), isAllyBase(), isEnemyBase(), isMyBase(), update(), and updatePlayer().

std::map<Player, int> BaseClass::mPlayerBuildingNumbers [private]

Definition at line 102 of file Base.h.

Referenced by addUnit(), removeUnit(), and updatePlayer().

Definition at line 80 of file Base.h.

Referenced by addUnit(), drawDebugInfo(), getRefineries(), removeUnit(), and update().

Definition at line 99 of file Base.h.

Referenced by getRegion().

std::deque<Unit> BaseClass::mResourceDepots [private]

Definition at line 97 of file Base.h.

Referenced by addUnit(), getResourceDepot(), removeUnit(), update(), and updatePlayer().

unsigned int BaseClass::mTechBuildings [private]

Definition at line 89 of file Base.h.

Referenced by addUnit(), drawDebugInfo(), getNumberOfTechBuildings(), and removeUnit().

Definition at line 104 of file Base.h.

Referenced by update().

std::set<TilePosition> BaseClass::mTiles [private]

Definition at line 100 of file Base.h.

Referenced by addUnit(), getTiles(), and update().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines