mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Silenced several "warning: suggest parentheses around ‘&&’ within ‘||’": added some parenthesis, optimized a couple statments and fix a bug in another.
This commit is contained in:
parent
2d3caec79b
commit
ff49b852df
@ -323,9 +323,9 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
|||||||
for(std::map<int, PlayerSettings>::iterator it =si->playerInfos.begin();
|
for(std::map<int, PlayerSettings>::iterator it =si->playerInfos.begin();
|
||||||
it != si->playerInfos.end(); ++it)
|
it != si->playerInfos.end(); ++it)
|
||||||
{
|
{
|
||||||
if(networkMode == SINGLE //single - one client has all player
|
if((networkMode == SINGLE) //single - one client has all player
|
||||||
|| networkMode != SINGLE && serv->connectionID == it->second.human //multi - client has only "its players"
|
|| (networkMode != SINGLE && serv->connectionID == it->second.human) //multi - client has only "its players"
|
||||||
|| networkMode == HOST && it->second.human == false) //multi - host has all AI players
|
|| (networkMode == HOST && it->second.human == false)) //multi - host has all AI players
|
||||||
{
|
{
|
||||||
myPlayers.insert(ui8(it->first)); //add player
|
myPlayers.insert(ui8(it->first)); //add player
|
||||||
}
|
}
|
||||||
|
@ -246,8 +246,8 @@ void CMapHandler::initObjectRects()
|
|||||||
{
|
{
|
||||||
const CGObjectInstance *obj = map->objects[f];
|
const CGObjectInstance *obj = map->objects[f];
|
||||||
if( !obj
|
if( !obj
|
||||||
|| obj->ID==HEROI_TYPE && static_cast<const CGHeroInstance*>(obj)->inTownGarrison //garrisoned hero
|
|| (obj->ID==HEROI_TYPE && static_cast<const CGHeroInstance*>(obj)->inTownGarrison) //garrisoned hero
|
||||||
|| obj->ID==8 && static_cast<const CGBoat*>(obj)->hero //boat wih hero (hero graphics is used)
|
|| (obj->ID==8 && static_cast<const CGBoat*>(obj)->hero) //boat wih hero (hero graphics is used)
|
||||||
|| !obj->defInfo
|
|| !obj->defInfo
|
||||||
|| !obj->defInfo->handler) //no graphic...
|
|| !obj->defInfo->handler) //no graphic...
|
||||||
{
|
{
|
||||||
@ -549,7 +549,7 @@ void CMapHandler::terrainRect( int3 top_tile, unsigned char anim, const std::vec
|
|||||||
: static_cast<const CGHeroInstance*>(obj));
|
: static_cast<const CGHeroInstance*>(obj));
|
||||||
|
|
||||||
//print hero / boat and flag
|
//print hero / boat and flag
|
||||||
if(themp && themp->moveDir && themp->type || obj->ID == 8) //it's hero or boat
|
if((themp && themp->moveDir && themp->type) || (obj->ID == 8)) //it's hero or boat
|
||||||
{
|
{
|
||||||
const int IMGVAL = 8; //frames per group of movement animation
|
const int IMGVAL = 8; //frames per group of movement animation
|
||||||
ui8 dir;
|
ui8 dir;
|
||||||
|
@ -769,7 +769,8 @@ int BattleInfo::calculateSpellDuration( const CSpell * spell, const CGHeroInstan
|
|||||||
CStack * BattleInfo::generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, THex position) const
|
CStack * BattleInfo::generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, THex position) const
|
||||||
{
|
{
|
||||||
int owner = attackerOwned ? sides[0] : sides[1];
|
int owner = attackerOwned ? sides[0] : sides[1];
|
||||||
assert(owner >= PLAYER_LIMIT || base.armyObj && base.armyObj->tempOwner == owner);
|
assert((owner >= PLAYER_LIMIT) ||
|
||||||
|
(base.armyObj && base.armyObj->tempOwner == owner));
|
||||||
|
|
||||||
CStack * ret = new CStack(&base, owner, stackID, attackerOwned, slot);
|
CStack * ret = new CStack(&base, owner, stackID, attackerOwned, slot);
|
||||||
ret->position = position;
|
ret->position = position;
|
||||||
@ -1009,9 +1010,9 @@ void BattleInfo::getStackQueue( std::vector<const CStack *> &out, int howMany, i
|
|||||||
for(unsigned int i=0; i<stacks.size(); ++i)
|
for(unsigned int i=0; i<stacks.size(); ++i)
|
||||||
{
|
{
|
||||||
const CStack * const s = stacks[i];
|
const CStack * const s = stacks[i];
|
||||||
if(turn <= 0 && !s->willMove() //we are considering current round and stack won't move
|
if((turn <= 0 && !s->willMove()) //we are considering current round and stack won't move
|
||||||
|| turn > 0 && !s->canMove(turn) //stack won't be able to move in later rounds
|
|| (turn > 0 && !s->canMove(turn)) //stack won't be able to move in later rounds
|
||||||
|| turn <= 0 && s == active && out.size() && s == out.front()) //it's active stack already added at the beginning of queue
|
|| (turn <= 0 && s == active && out.size() && s == out.front())) //it's active stack already added at the beginning of queue
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ DLL_EXPORT std::string MetaString::buildList () const
|
|||||||
std::string lista;
|
std::string lista;
|
||||||
for (int i = 0; i < message.size(); ++i)
|
for (int i = 0; i < message.size(); ++i)
|
||||||
{
|
{
|
||||||
if (i > 0 && message[i] == TEXACT_STRING || message[i] == TLOCAL_STRING)
|
if (i > 0 && (message[i] == TEXACT_STRING || message[i] == TLOCAL_STRING))
|
||||||
{
|
{
|
||||||
if (exSt == exactStrings.size() - 1)
|
if (exSt == exactStrings.size() - 1)
|
||||||
lista += VLC->generaltexth->allTexts[141]; //" and "
|
lista += VLC->generaltexth->allTexts[141]; //" and "
|
||||||
@ -484,8 +484,8 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, int player, co
|
|||||||
|
|
||||||
for(bmap<ui32, ConstTransitivePtr<CGHeroInstance> >::iterator i=available.begin(); i!=available.end(); i++)
|
for(bmap<ui32, ConstTransitivePtr<CGHeroInstance> >::iterator i=available.begin(); i!=available.end(); i++)
|
||||||
{
|
{
|
||||||
if(pavailable.find(i->first)->second & 1<<player
|
if ((!bannedClass && (pavailable.find(i->first)->second & (1<<player))) ||
|
||||||
&& !bannedClass || i->second->type->heroClass != bannedClass)
|
i->second->type->heroClass != bannedClass)
|
||||||
{
|
{
|
||||||
pool.push_back(i->second);
|
pool.push_back(i->second);
|
||||||
sum += i->second->type->heroClass->selectionProbability[town->typeID]; //total weight
|
sum += i->second->type->heroClass->selectionProbability[town->typeID]; //total weight
|
||||||
@ -975,8 +975,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
|||||||
for(int j = 0; j < ARRAY_COUNT(dp.sides[i].stacks); j++)
|
for(int j = 0; j < ARRAY_COUNT(dp.sides[i].stacks); j++)
|
||||||
{
|
{
|
||||||
int cre = dp.sides[i].stacks[j].type, count = dp.sides[i].stacks[j].count;
|
int cre = dp.sides[i].stacks[j].type, count = dp.sides[i].stacks[j].count;
|
||||||
if(!count && obj->hasStackAtSlot(j)
|
if(count || obj->hasStackAtSlot(j))
|
||||||
|| count)
|
|
||||||
obj->setCreature(j, cre, count);
|
obj->setCreature(j, cre, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3034,4 +3033,4 @@ DuelParameters::DuelParameters()
|
|||||||
TeamState::TeamState()
|
TeamState::TeamState()
|
||||||
{
|
{
|
||||||
nodeType = TEAM;
|
nodeType = TEAM;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ void DLL_EXPORT BonusList::getBonuses(BonusList &out, const CSelector &selector)
|
|||||||
void DLL_EXPORT BonusList::getBonuses(BonusList &out, const CSelector &selector, const CSelector &limit) const
|
void DLL_EXPORT BonusList::getBonuses(BonusList &out, const CSelector &selector, const CSelector &limit) const
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(Bonus *i, *this)
|
BOOST_FOREACH(Bonus *i, *this)
|
||||||
if(selector(i) && (!limit && i->effectRange == Bonus::NO_LIMIT || limit && limit(i))) //add matching bonuses that matches limit predicate or have NO_LIMIT if no given predicate
|
if(selector(i) && ((!limit && i->effectRange == Bonus::NO_LIMIT) || (limit && limit(i)))) //add matching bonuses that matches limit predicate or have NO_LIMIT if no given predicate
|
||||||
out.push_back(i);
|
out.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1064,4 +1064,4 @@ StackOwnerLimiter::StackOwnerLimiter()
|
|||||||
StackOwnerLimiter::StackOwnerLimiter(ui8 Owner)
|
StackOwnerLimiter::StackOwnerLimiter(ui8 Owner)
|
||||||
: owner(Owner)
|
: owner(Owner)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ TStacks CBattleInfoCallback::battleGetStacks(EStackOwnership whose /*= MINE_AND_
|
|||||||
|
|
||||||
BOOST_FOREACH(const CStack *s, gs->curB->stacks)
|
BOOST_FOREACH(const CStack *s, gs->curB->stacks)
|
||||||
{
|
{
|
||||||
bool ownerMatches = whose == MINE_AND_ENEMY || whose == ONLY_MINE && s->owner == player || whose == ONLY_ENEMY && s->owner != player;
|
bool ownerMatches = (whose == MINE_AND_ENEMY) || (whose == ONLY_MINE && s->owner == player) || (whose == ONLY_ENEMY && s->owner != player);
|
||||||
bool alivenessMatches = s->alive() || !onlyAlive;
|
bool alivenessMatches = s->alive() || !onlyAlive;
|
||||||
if(ownerMatches && alivenessMatches)
|
if(ownerMatches && alivenessMatches)
|
||||||
ret.push_back(s);
|
ret.push_back(s);
|
||||||
|
@ -1188,7 +1188,7 @@ void CGameHandler::run(bool resume)
|
|||||||
resume = false;
|
resume = false;
|
||||||
for(; i != gs->players.end(); i++)
|
for(; i != gs->players.end(); i++)
|
||||||
{
|
{
|
||||||
if(i->second.towns.size()==0 && i->second.heroes.size()==0
|
if((i->second.towns.size()==0 && i->second.heroes.size()==0)
|
||||||
|| i->second.color<0
|
|| i->second.color<0
|
||||||
|| i->first>=PLAYER_LIMIT
|
|| i->first>=PLAYER_LIMIT
|
||||||
|| i->second.status)
|
|| i->second.status)
|
||||||
@ -1325,7 +1325,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
|
|||||||
bool blockvis = false;
|
bool blockvis = false;
|
||||||
const CGHeroInstance *h = getHero(hid);
|
const CGHeroInstance *h = getHero(hid);
|
||||||
|
|
||||||
if(!h || asker != 255 && (instant || h->getOwner() != gs->currentPlayer) //not turn of that hero or player can't simply teleport hero (at least not with this function)
|
if(!h || (asker != 255 && (instant || h->getOwner() != gs->currentPlayer)) //not turn of that hero or player can't simply teleport hero (at least not with this function)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
tlog1 << "Illegal call to move hero!\n";
|
tlog1 << "Illegal call to move hero!\n";
|
||||||
@ -3872,7 +3872,8 @@ bool CGameHandler::isAllowedExchange( int id1, int id2 )
|
|||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(gsm);
|
boost::unique_lock<boost::recursive_mutex> lock(gsm);
|
||||||
for(std::map<ui32, std::pair<si32,si32> >::const_iterator i = allowedExchanges.begin(); i!=allowedExchanges.end(); i++)
|
for(std::map<ui32, std::pair<si32,si32> >::const_iterator i = allowedExchanges.begin(); i!=allowedExchanges.end(); i++)
|
||||||
if(id1 == i->second.first && id2 == i->second.second || id2 == i->second.first && id1 == i->second.second)
|
if((id1 == i->second.first && id2 == i->second.second) ||
|
||||||
|
(id2 == i->second.first && id1 == i->second.second))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4646,14 +4647,14 @@ bool CGameHandler::eraseStack(const StackLocation &sl, bool forceRemoval/* = fal
|
|||||||
bool CGameHandler::changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue /*= false*/)
|
bool CGameHandler::changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue /*= false*/)
|
||||||
{
|
{
|
||||||
TQuantity currentCount = sl.army->getStackCount(sl.slot);
|
TQuantity currentCount = sl.army->getStackCount(sl.slot);
|
||||||
if(absoluteValue && count < 0
|
if((absoluteValue && count < 0)
|
||||||
|| !absoluteValue && -count > currentCount)
|
|| (!absoluteValue && -count > currentCount))
|
||||||
{
|
{
|
||||||
COMPLAIN_RET("Cannot take more stacks than present!");
|
COMPLAIN_RET("Cannot take more stacks than present!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentCount == -count && !absoluteValue
|
if((currentCount == -count && !absoluteValue)
|
||||||
|| !count && absoluteValue)
|
|| (!count && absoluteValue))
|
||||||
{
|
{
|
||||||
eraseStack(sl);
|
eraseStack(sl);
|
||||||
}
|
}
|
||||||
@ -5088,4 +5089,4 @@ void CasualtiesAfterBattle::takeFromArmy(CGameHandler *gh)
|
|||||||
else
|
else
|
||||||
gh->eraseStack(ncount.first, true);
|
gh->eraseStack(ncount.first, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user