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

Merge branch 'develop' of https://github.com/vcmi/vcmi into develop

This commit is contained in:
DjWarmonger 2015-04-11 07:59:01 +02:00
commit f7387becb4
10 changed files with 45 additions and 29 deletions

View File

@ -40,7 +40,7 @@ namespace fl {
FL_DEFAULT_COPY_AND_MOVE(SNorm)
virtual SNorm* clone() const = 0;
virtual SNorm* clone() const FL_IOVERRIDE = 0;
};
}
#endif /* FL_SNORM_H */

View File

@ -40,7 +40,7 @@ namespace fl {
FL_DEFAULT_COPY_AND_MOVE(TNorm)
virtual TNorm* clone() const = 0;
virtual TNorm* clone() const FL_IOVERRIDE = 0;
};
}
#endif /* TNORM_H */

View File

@ -105,13 +105,10 @@ if(NOT WIN32)
if(HAVE_RT_LIB)
set(SYSTEM_LIBS ${SYSTEM_LIBS} rt)
endif()
CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_DL_LIB)
if(HAVE_DL_LIB)
set(SYSTEM_LIBS ${SYSTEM_LIBS} dl)
endif()
endif()
set(SYSTEM_LIBS ${SYSTEM_LIBS} ${CMAKE_DL_LIBS})
set(FFmpeg_FIND_COMPONENTS AVFORMAT SWSCALE)
find_package(Boost 1.48.0 COMPONENTS filesystem locale program_options system thread REQUIRED)
find_package(ZLIB REQUIRED)

View File

@ -2153,9 +2153,9 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
case WALK_AND_ATTACK:
case ATTACK_AND_RETURN:
{
if (shere && !ourStack && shere->alive())
if (curInt->cb->battleCanAttack(sactive, shere, myNumber))
{
if (isTileAttackable(myNumber))
if (isTileAttackable(myNumber)) // move isTileAttackable to be part of battleCanAttack?
{
setBattleCursor(myNumber); // temporary - needed for following function :(
BattleHex attackFromHex = fromWhichHexAttack(myNumber);

View File

@ -775,6 +775,29 @@ std::vector<BattleHex> CBattleInfoCallback::battleGetAvailableHexes(const CStack
return ret;
}
bool CBattleInfoCallback::battleCanAttack(const CStack * stack, const CStack * target, BattleHex dest) const
{
RETURN_IF_NOT_BATTLE(false);
if(battleTacticDist())
return false;
if (!stack || !target)
return false;
if (stack->owner == target->owner)
return false;
auto &id = stack->getCreature()->idNumber;
if (id == CreatureID::FIRST_AID_TENT || id == CreatureID::CATAPULT)
return false;
if (!target->alive())
return false;
return true;
}
bool CBattleInfoCallback::battleCanShoot(const CStack * stack, BattleHex dest) const
{
RETURN_IF_NOT_BATTLE(false);

View File

@ -252,6 +252,8 @@ public:
int battleGetSurrenderCost(PlayerColor Player) const; //returns cost of surrendering battle, -1 if surrendering is not possible
ReachabilityInfo::TDistances battleGetDistances(const CStack * stack, BattleHex hex = BattleHex::INVALID, BattleHex * predecessors = nullptr) const; //returns vector of distances to [dest hex number]
std::set<BattleHex> battleGetAttackedHexes(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos = BattleHex::INVALID) const;
bool battleCanAttack(const CStack * stack, const CStack * target, BattleHex dest) const; //determines if stack with given ID can attack target at the selected destination
bool battleCanShoot(const CStack * stack, BattleHex dest) const; //determines if stack with given ID shoot at the selected destination
bool battleIsStackBlocked(const CStack * stack) const; //returns true if there is neighboring enemy stack
std::set<const CStack*> batteAdjacentCreatures (const CStack * stack) const;

View File

@ -712,7 +712,7 @@ void CCommanderInstance::setAlive (bool Alive)
alive = Alive;
if (!alive)
{
getBonusList().remove_if (Bonus::UntilCommanderKilled);
popBonuses(Bonus::UntilCommanderKilled);
}
}

View File

@ -273,13 +273,13 @@ void BonusList::push_back(Bonus* const &x)
bonuses.push_back(x);
if (belongsToTree)
CBonusSystemNode::incrementTreeChangedNum();
CBonusSystemNode::treeHasChanged();
}
std::vector<Bonus*>::iterator BonusList::erase(const int position)
{
if (belongsToTree)
CBonusSystemNode::incrementTreeChangedNum();
CBonusSystemNode::treeHasChanged();
return bonuses.erase(bonuses.begin() + position);
}
@ -288,7 +288,7 @@ void BonusList::clear()
bonuses.clear();
if (belongsToTree)
CBonusSystemNode::incrementTreeChangedNum();
CBonusSystemNode::treeHasChanged();
}
std::vector<BonusList*>::size_type BonusList::operator-=(Bonus* const &i)
@ -299,7 +299,7 @@ std::vector<BonusList*>::size_type BonusList::operator-=(Bonus* const &i)
bonuses.erase(itr);
if (belongsToTree)
CBonusSystemNode::incrementTreeChangedNum();
CBonusSystemNode::treeHasChanged();
return true;
}
@ -308,7 +308,7 @@ void BonusList::resize(std::vector<Bonus*>::size_type sz, Bonus* c )
bonuses.resize(sz, c);
if (belongsToTree)
CBonusSystemNode::incrementTreeChangedNum();
CBonusSystemNode::treeHasChanged();
}
void BonusList::insert(std::vector<Bonus*>::iterator position, std::vector<Bonus*>::size_type n, Bonus* const &x)
@ -316,7 +316,7 @@ void BonusList::insert(std::vector<Bonus*>::iterator position, std::vector<Bonus
bonuses.insert(position, n, x);
if (belongsToTree)
CBonusSystemNode::incrementTreeChangedNum();
CBonusSystemNode::treeHasChanged();
}
int IBonusBearer::valOfBonuses(Bonus::BonusType type, const CSelector &selector) const
@ -754,7 +754,7 @@ void CBonusSystemNode::attachTo(CBonusSystemNode *parent)
newRedDescendant(parent);
parent->newChildAttached(this);
CBonusSystemNode::treeChanged++;
CBonusSystemNode::treeHasChanged();
}
void CBonusSystemNode::detachFrom(CBonusSystemNode *parent)
@ -768,7 +768,7 @@ void CBonusSystemNode::detachFrom(CBonusSystemNode *parent)
parents -= parent;
parent->childDetached(this);
CBonusSystemNode::treeChanged++;
CBonusSystemNode::treeHasChanged();
}
void CBonusSystemNode::popBonuses(const CSelector &s)
@ -792,7 +792,7 @@ void CBonusSystemNode::addNewBonus(Bonus *b)
assert(!vstd::contains(exportedBonuses,b));
exportedBonuses.push_back(b);
exportBonus(b);
CBonusSystemNode::treeChanged++;
CBonusSystemNode::treeHasChanged();
}
void CBonusSystemNode::accumulateBonus(Bonus &b)
@ -812,7 +812,7 @@ void CBonusSystemNode::removeBonus(Bonus *b)
else
bonuses -= b;
vstd::clear_pointer(b);
CBonusSystemNode::treeChanged++;
CBonusSystemNode::treeHasChanged();
}
bool CBonusSystemNode::actsAsBonusSourceOnly() const
@ -995,7 +995,7 @@ void CBonusSystemNode::exportBonus(Bonus * b)
else
bonuses.push_back(b);
CBonusSystemNode::treeChanged++;
CBonusSystemNode::treeHasChanged();
}
void CBonusSystemNode::exportBonuses()
@ -1049,11 +1049,6 @@ void CBonusSystemNode::setDescription(const std::string &description)
this->description = description;
}
void CBonusSystemNode::incrementTreeChangedNum()
{
treeChanged++;
}
void CBonusSystemNode::limitBonuses(const BonusList &allBonuses, BonusList &out) const
{
assert(&allBonuses != &out); //todo should it work in-place?

View File

@ -683,7 +683,6 @@ public:
void exportBonus(Bonus * b);
void exportBonuses();
static void incrementTreeChangedNum();
BonusList &getBonusList();
const BonusList &getBonusList() const;
BonusList &getExportedBonusList();
@ -981,7 +980,7 @@ void BonusList::insert(const int position, InputIterator first, InputIterator la
bonuses.insert(bonuses.begin() + position, first, last);
if (belongsToTree)
CBonusSystemNode::incrementTreeChangedNum();
CBonusSystemNode::treeHasChanged();
}
// Extensions for BOOST_FOREACH to enable iterating of BonusList objects

View File

@ -1175,7 +1175,7 @@ void BattleResult::applyGs( CGameState *gs )
{
if(auto h = gs->curB->battleGetFightingHero(i))
{
h->getBonusList().remove_if(Bonus::OneBattle); //remove any "until next battle" bonuses
h->popBonuses(Bonus::OneBattle); //remove any "until next battle" bonuses
if (h->commander && h->commander->alive)
{
for (auto art : h->commander->artifactsWorn) //increment bonuses for commander artifacts