summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/map.cpp b/src/map.cpp
index e706f120b..2209cf997 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -2,7 +2,7 @@
* The ManaPlus Client
* Copyright (C) 2004-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011 The ManaPlus Developers
+ * Copyright (C) 2011-2012 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
@@ -1383,17 +1383,20 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
if (startX >= mWidth || startY >= mHeight)
return path;
- // Declare open list, a list with open tiles sorted on F cost
- std::priority_queue<Location> openList;
-
// Return when destination not walkable
if (!getWalk(destX, destY, walkmask))
return path;
// Reset starting tile's G cost to 0
MetaTile *startTile = &mMetaTiles[startX + startY * mWidth];
+ if (!startTile)
+ return path;
+
startTile->Gcost = 0;
+ // Declare open list, a list with open tiles sorted on F cost
+ std::priority_queue<Location> openList;
+
// Add the start point to the open list
openList.push(Location(startX, startY, startTile));