瀏覽代碼

Fixed small error in nearest town finding algorithm.

karol57 11 年之前
父節點
當前提交
c676c5da82
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      server/CGameHandler.cpp

+ 4 - 4
server/CGameHandler.cpp

@@ -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)