1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-20 00:22:54 +02:00

int3 dist2d microoptimization

This commit is contained in:
karol57
2014-05-25 20:42:25 +02:00
parent df8cce0d61
commit dd33fd51a8
5 changed files with 18 additions and 17 deletions

View File

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