1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

gcc-4.5 compatibility

This commit is contained in:
Ivan Savenko 2012-06-23 17:19:50 +00:00
parent 770a6e077c
commit 47945383da
7 changed files with 10 additions and 9 deletions

View File

@ -331,7 +331,8 @@ namespace vstd
{
assert(r.size());
index %= r.size();
auto itr = std::begin(r);
// auto itr = std::begin(r); //not available in gcc-4.5
auto itr = r.begin();
std::advance(itr, index);
return *itr;
}

View File

@ -2597,7 +2597,7 @@ shared_ptr<CObstacleInstance> BattleInfo::getObstacleOnTile(BattleHex tile) cons
if(vstd::contains(obs->getAffectedTiles(), tile))
return obs;
return NULL;
return shared_ptr<CObstacleInstance>();
}
const CStack * BattleInfo::getStackIf(boost::function<bool(const CStack*)> pred) const

View File

@ -592,7 +592,7 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
//golem factory is not in list of cregens but can be placed as random object
static const int factoryCreatures[] = {32, 33, 116, 117};
std::vector<int> factory(std::begin(factoryCreatures), std::end(factoryCreatures));
std::vector<int> factory(factoryCreatures, factoryCreatures + ARRAY_COUNT(factoryCreatures));
if (vstd::contains(factory, cid))
result = std::pair<int,int>(20, 1);

View File

@ -2360,7 +2360,7 @@ void CGTownInstance::recreateBuildingsBonuses()
bool CGTownInstance::addBonusIfBuilt(int building, int type, int val, int subtype /*= -1*/)
{
return addBonusIfBuilt(building, type, val, NULL, subtype);
return addBonusIfBuilt(building, type, val, TPropagatorPtr(), subtype);
}
bool CGTownInstance::addBonusIfBuilt(int building, int type, int val, TPropagatorPtr prop, int subtype /*= -1*/)

View File

@ -134,5 +134,5 @@ std::vector<BattleHex> MoatObstacle::getAffectedTiles() const
{
//rrr... need initializer lists
static const BattleHex moatHexes[] = {11, 28, 44, 61, 77, 111, 129, 146, 164, 181};
return std::vector<BattleHex>(std::begin(moatHexes), std::end(moatHexes));
return std::vector<BattleHex>(moatHexes, moatHexes + ARRAY_COUNT(moatHexes));
}

View File

@ -416,7 +416,7 @@ const CGHeroInstance * CBattleInfoCallback::battleGetFightingHero(ui8 side) cons
shared_ptr<const CObstacleInstance> CBattleInfoCallback::battleGetObstacleOnPos(BattleHex tile, bool onlyBlocking /*= true*/)
{
if(!gs->curB)
return NULL;
return shared_ptr<const CObstacleInstance>();
BOOST_FOREACH(auto &obs, battleGetAllObstacles())
{
@ -426,7 +426,7 @@ shared_ptr<const CObstacleInstance> CBattleInfoCallback::battleGetObstacleOnPos(
return obs;
}
}
return NULL;
return shared_ptr<const CObstacleInstance>();
}
int CBattleInfoCallback::battleGetMoatDmg()

View File

@ -999,7 +999,7 @@ int CGameHandler::moveStack(int stack, BattleHex dest)
{
// send one package with the creature path information
shared_ptr<const CObstacleInstance> obstacle = NULL; //obstacle that interrupted movement
shared_ptr<const CObstacleInstance> obstacle; //obstacle that interrupted movement
std::vector<BattleHex> tiles;
int tilesToMove = std::max((int)(path.first.size() - creSpeed), 0);
int v = path.first.size()-1;
@ -1036,7 +1036,7 @@ startWalking:
//if stack didn't die in explosion, continue movement
if(!obstacle->stopsMovement() && curStack->alive())
{
obstacle = NULL;
obstacle.reset();
tiles.clear();
v--;
goto startWalking; //TODO it's so evil