mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
* msvc compilation fix
* fixed problem with maximal spell level checking reported by ubuntux
This commit is contained in:
parent
1906060bc6
commit
3c50890d16
@ -5,6 +5,12 @@
|
||||
#include <boost/lambda/bind.hpp>
|
||||
#include <boost/lambda/if.hpp>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
HANDLE handleIn;
|
||||
HANDLE handleOut;
|
||||
#endif
|
||||
|
||||
using namespace GeniusAI::BattleAI;
|
||||
using namespace boost::lambda;
|
||||
using namespace std;
|
||||
|
@ -1984,6 +1984,35 @@ void BattleInfo::calculateCasualties( std::set<std::pair<ui32,si32> > *casualtie
|
||||
}
|
||||
}
|
||||
|
||||
si8 CGameState::battleMaxSpellLevel()
|
||||
{
|
||||
if(!curB) //there is not battle
|
||||
{
|
||||
tlog1 << "si8 CGameState::maxSpellLevel() call when there is no battle!" << std::endl;
|
||||
throw "si8 CGameState::maxSpellLevel() call when there is no battle!";
|
||||
}
|
||||
|
||||
si8 levelLimit = SPELL_LEVELS;
|
||||
|
||||
const CGHeroInstance *h1 = getHero(curB->hero1);
|
||||
if(h1)
|
||||
{
|
||||
for(std::list<HeroBonus>::const_iterator i = h1->bonuses.begin(); i != h1->bonuses.end(); i++)
|
||||
if(i->type == HeroBonus::BLOCK_SPELLS_ABOVE_LEVEL)
|
||||
amin(levelLimit, i->val);
|
||||
}
|
||||
|
||||
const CGHeroInstance *h2 = getHero(curB->hero2);
|
||||
if(h2)
|
||||
{
|
||||
for(std::list<HeroBonus>::const_iterator i = h2->bonuses.begin(); i != h2->bonuses.end(); i++)
|
||||
if(i->type == HeroBonus::BLOCK_SPELLS_ABOVE_LEVEL)
|
||||
amin(levelLimit, i->val);
|
||||
}
|
||||
|
||||
return levelLimit;
|
||||
}
|
||||
|
||||
std::set<CStack*> BattleInfo::getAttackedCreatures(const CSpell * s, const CGHeroInstance * caster, int destinationTile)
|
||||
{
|
||||
std::set<ui16> attackedHexes = s->rangeInHexes(destinationTile, caster->getSpellSchoolLevel(s));
|
||||
|
@ -279,6 +279,7 @@ public:
|
||||
bool battleShootCreatureStack(int ID, int dest);
|
||||
int battleGetStack(int pos); //returns ID of stack at given tile
|
||||
int battleGetBattlefieldType(int3 tile = int3());// 1. sand/shore 2. sand/mesas 3. dirt/birches 4. dirt/hills 5. dirt/pines 6. grass/hills 7. grass/pines 8. lava 9. magic plains 10. snow/mountains 11. snow/trees 12. subterranean 13. swamp/trees 14. fiery fields 15. rock lands 16. magic clouds 17. lucid pools 18. holy ground 19. clover field 20. evil fog 21. "favourable winds" text on magic plains background 22. cursed ground 23. rough 24. ship to ship 25. ship
|
||||
si8 battleMaxSpellLevel(); //calculates maximum spell level possible to be cast on battlefield - takes into account artifacts of both heroes; if no effects are set, SPELL_LEVELS is returned
|
||||
UpgradeInfo getUpgradeInfo(CArmedInstance *obj, int stackPos);
|
||||
float getMarketEfficiency(int player, int mode=0);
|
||||
int canBuildStructure(const CGTownInstance *t, int ID);// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
|
||||
|
@ -2395,7 +2395,7 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
|
||||
|| (gs->curB->castedSpells[ba.side]) //spell has been casted
|
||||
|| (secondHero && secondHero->hasBonusOfType(HeroBonus::SPELL_IMMUNITY, s->id)) //non - casting hero provides immunity for this spell
|
||||
|| (h->valOfBonuses(HeroBonus::BLOCK_SPELLS_ABOVE_LEVEL) <= s->level) //caster's 'bonus' prevents him from casting this spell
|
||||
|| (secondHero && secondHero->valOfBonuses(HeroBonus::BLOCK_SPELLS_ABOVE_LEVEL) <= s->level) //non - casting hero stops caster from casting this spell
|
||||
|| (gs->battleMaxSpellLevel() < s->level) //non - casting hero stops caster from casting this spell
|
||||
)
|
||||
{
|
||||
tlog2 << "Spell cannot be casted!\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user