1 /* GemRB - Infinity Engine Emulator 2 * Copyright (C) 2003 The GemRB Project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 * 19 */ 20 #ifndef PATHFINDER_H 21 #define PATHFINDER_H 22 23 #include "Region.h" 24 25 namespace GemRB { 26 27 //searchmap conversion bits 28 29 enum class PathMapFlags : uint8_t { 30 UNMARKED = 0, 31 IMPASSABLE = 0, 32 PASSABLE = 1, 33 TRAVEL = 2, 34 NO_SEE = 4, 35 SIDEWALL = 8, 36 AREAMASK = 15, 37 DOOR_OPAQUE = 16, 38 DOOR_IMPASSABLE = 32, 39 PC = 64, 40 NPC = 128, 41 ACTOR = (PC | NPC), 42 DOOR = (DOOR_OPAQUE | DOOR_IMPASSABLE), 43 NOTAREA = (ACTOR | DOOR), 44 NOTDOOR = (ACTOR | AREAMASK), 45 NOTACTOR = (DOOR | AREAMASK) 46 }; 47 48 struct PathNode { 49 PathNode* Parent; 50 PathNode* Next; 51 unsigned int x; 52 unsigned int y; 53 unsigned int orient; 54 }; 55 56 using NavmapPoint = Point; 57 using SearchmapPoint = Point; 58 59 enum { 60 PF_SIGHT = 1, 61 PF_BACKAWAY = 2, 62 PF_ACTORS_ARE_BLOCKING = 4 63 }; 64 65 66 // Point-distance pair, used by the pathfinder's priority queue 67 // to sort nodes by their (heuristic) distance from the destination 68 class PQNode { 69 public: PQNode(Point p,double l)70 PQNode(Point p, double l) : point(p), dist(l) {}; PQNode()71 PQNode() : point(Point(0, 0)), dist(0) {}; 72 73 Point point; 74 double dist; 75 76 friend bool operator < (const PQNode &lhs, const PQNode &rhs) { return lhs.dist < rhs.dist;} 77 friend bool operator > (const PQNode &lhs, const PQNode &rhs){ return rhs < lhs; } 78 friend bool operator <= (const PQNode &lhs, const PQNode &rhs){ return !(lhs > rhs); } 79 friend bool operator >= (const PQNode &lhs, const PQNode &rhs){ return !(lhs < rhs); } 80 friend bool operator == (const PQNode &lhs, const PQNode &rhs) { return lhs.point == rhs.point; } 81 friend bool operator != (const PQNode &lhs, const PQNode &rhs) { return !(lhs == rhs); } 82 83 }; 84 85 } 86 87 #endif 88