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

Fixed small error in nearest town finding algorithm.

This commit is contained in:
karol57 2014-05-25 21:53:25 +02:00
parent dd33fd51a8
commit c676c5da82

View File

@ -5596,11 +5596,11 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, SpellID spellID, const int
ObjectInstanceID nearest = town->id; //nearest town's ID
for(const CGTownInstance * currTown : gs->getPlayer(h->tempOwner)->towns)
{
si32 curDist = currTown->pos.dist2dSQ(h->pos);
if (nearest == ObjectInstanceID() || curDist < dist)
si32 currDist = currTown->pos.dist2dSQ(h->pos);
if (currDist < dist)
{
nearest = town->id;
dist = curDist;
nearest = currTown->id;
dist = currDist;
}
}
if (town->id != nearest)