1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

* cleaner code is better :)

This commit is contained in:
mateuszb
2011-07-03 19:10:36 +00:00
parent ecf33cca91
commit aac1c0b4e7
5 changed files with 10 additions and 23 deletions

View File

@ -2280,29 +2280,16 @@ std::vector<THex> CStack::getHexes() const
{ {
std::vector<THex> hexes; std::vector<THex> hexes;
hexes.push_back(THex(position)); hexes.push_back(THex(position));
if (doubleWide()) THex occupied = occupiedHex();
{ if(occupied.isValid())
if (attackerOwned) hexes.push_back(occupied);
hexes.push_back(THex(position - 1));
else
hexes.push_back(THex(position + 1));
}
return hexes; return hexes;
} }
bool CStack::coversPos(ui16 pos) const bool CStack::coversPos(THex pos) const
{ {
if (pos == position) return vstd::contains(getHexes(), pos);
return true;
if (doubleWide())
{
if (attackerOwned)
return (pos == position - 1);
else
return (pos == position + 1);
}
else
return false;
} }
std::vector<si32> CStack::activeSpells() const std::vector<si32> CStack::activeSpells() const

View File

@ -184,7 +184,7 @@ public:
bool doubleWide() const; bool doubleWide() const;
THex occupiedHex() const; //returns number of occupied hex (not the position) if stack is double wide; otherwise -1 THex occupiedHex() const; //returns number of occupied hex (not the position) if stack is double wide; otherwise -1
std::vector<THex> getHexes() const; //up to two occupied hexes, starting from front std::vector<THex> getHexes() const; //up to two occupied hexes, starting from front
bool coversPos(ui16 position) const; //checks also if unit is double-wide bool coversPos(THex position) const; //checks also if unit is double-wide
void prepareAttacked(BattleStackAttacked &bsa) const; //requires bsa.damageAmout filled void prepareAttacked(BattleStackAttacked &bsa) const; //requires bsa.damageAmout filled

View File

@ -1372,7 +1372,7 @@ struct BattleSpellCast : public CPackForClient//3009
ui8 side; //which hero did cast spell: 0 - attacker, 1 - defender ui8 side; //which hero did cast spell: 0 - attacker, 1 - defender
ui32 id; //id of spell ui32 id; //id of spell
ui8 skill; //caster's skill level ui8 skill; //caster's skill level
ui16 tile; //destination tile (may not be set in some global/mass spells THex tile; //destination tile (may not be set in some global/mass spells
std::vector<ui32> resisted; //ids of creatures that resisted this spell std::vector<ui32> resisted; //ids of creatures that resisted this spell
std::set<ui32> affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure) std::set<ui32> affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure)
TCreature attackerType;//id of caster to generate console message; -1 if not set (eg. spell casted by artifact) TCreature attackerType;//id of caster to generate console message; -1 if not set (eg. spell casted by artifact)

View File

@ -3433,7 +3433,7 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message )
} }
} }
void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, SpellCasting::ECastingMode mode, const CStack * stack) void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, SpellCasting::ECastingMode mode, const CStack * stack)
{ {
const CSpell *spell = VLC->spellh->spells[spellID]; const CSpell *spell = VLC->spellh->spells[spellID];

View File

@ -193,7 +193,7 @@ public:
void playerMessage( ui8 player, const std::string &message); void playerMessage( ui8 player, const std::string &message);
bool makeBattleAction(BattleAction &ba); bool makeBattleAction(BattleAction &ba);
void handleSpellCasting(int spellID, int spellLvl, int destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, SpellCasting::ECastingMode mode, const CStack * stack); void handleSpellCasting(int spellID, int spellLvl, THex destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, SpellCasting::ECastingMode mode, const CStack * stack);
bool makeCustomAction(BattleAction &ba); bool makeCustomAction(BattleAction &ba);
bool queryReply( ui32 qid, ui32 answer ); bool queryReply( ui32 qid, ui32 answer );
bool hireHero( const CGObjectInstance *obj, ui8 hid, ui8 player ); bool hireHero( const CGObjectInstance *obj, ui8 hid, ui8 player );