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

Little more development for duel mode.

This commit is contained in:
Michał W. Urbańczyk
2010-12-23 00:33:48 +00:00
parent cde0e8933f
commit 2fe8b07f4f
9 changed files with 112 additions and 51 deletions

View File

@ -1947,6 +1947,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
armies[1] = c;
curB = ::setupBattle(tile, terrain, terType, armies, heroes, false, town);
curB->localInit();
return;
}
break;
@ -4795,6 +4796,28 @@ si8 BattleInfo::getDistance( int hex1, int hex2 )
return std::max(xDst, yDst) + std::min(xDst, yDst) - (yDst + 1)/2;
}
void BattleInfo::localInit()
{
belligerents[0]->battle = belligerents[1]->battle = this;
//TODO: attach battle to belligerents
BOOST_FOREACH(CStack *s, stacks)
{
if(s->base) //stack originating from "real" stack in garrison -> attach to it
{
s->attachTo(const_cast<CStackInstance*>(s->base));
}
else //attach directly to obj to which stack belongs and creature type
{
CArmedInstance *army = belligerents[!s->attackerOwned];
s->attachTo(army);
assert(s->type);
s->attachTo(const_cast<CCreature*>(s->type));
}
s->postInit();
}
}
int3 CPath::startPos() const
{
return nodes[nodes.size()-1].coord;