From f79222defa17b8f76f628b85cc5966cbdfd53b29 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 5 May 2012 04:38:49 +0000 Subject: [PATCH] - more pathfinder in progress changes, nothing to test yet --- source/glest_game/ai/fast_path_finder.cpp | 10 +++++----- source/glest_game/ai/path_finder.cpp | 14 +++++++------- source/glest_game/ai/path_finder.h | 3 +++ source/glest_game/world/map.cpp | 6 ++++++ source/shared_lib/include/graphics/vec.h | 12 ++++++++++++ 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/source/glest_game/ai/fast_path_finder.cpp b/source/glest_game/ai/fast_path_finder.cpp index 4d6bcbe1..e902d820 100644 --- a/source/glest_game/ai/fast_path_finder.cpp +++ b/source/glest_game/ai/fast_path_finder.cpp @@ -627,11 +627,11 @@ public: // methods // heap now unsorted m_OpenList.push_back( (*successor) ); - if (m_OpenList[0]->f == m_OpenList[m_OpenList.size()-1]->f) { - Node *aux = m_OpenList[0]; - m_OpenList[0] = m_OpenList[m_OpenList.size()-1]; - m_OpenList[m_OpenList.size()-1] = aux; - } +// if (m_OpenList[0]->f == m_OpenList[m_OpenList.size()-1]->f) { +// Node *aux = m_OpenList[0]; +// m_OpenList[0] = m_OpenList[m_OpenList.size()-1]; +// m_OpenList[m_OpenList.size()-1] = aux; +// } // sort back element into heap push_heap( m_OpenList.begin(), m_OpenList.end(), HeapCompare_f() ); diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index 161f3a8b..9292b0a9 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -860,15 +860,15 @@ TravelState PathFinder::aStarFast(Unit *unit, Vec2i finalPos, bool inBailout, in factions[unitFactionIndex].precachedPath[unit->getId()].push_back(nodePos); } else { - if(i < pathFindRefresh) { - //if(i < pathFindRefresh || - // (whileLoopCount >= pathFindExtendRefreshForNodeCount && - // i < getPathFindExtendRefreshNodeCount(unitFactionIndex))) { + //if(i < pathFindRefresh) { + if(i < pathFindRefresh || + (nodeSearchCount >= pathFindExtendRefreshForNodeCount && + i < getPathFindExtendRefreshNodeCount(unitFactionIndex))) { path->add(nodePos); } - //else if(tryLastPathCache == false) { - // break; - //} + else if(tryLastPathCache == false) { + break; + } //if(tryLastPathCache == true && basicPathFinder) { if(basicPathFinder) { diff --git a/source/glest_game/ai/path_finder.h b/source/glest_game/ai/path_finder.h index 2f012939..46a0af78 100644 --- a/source/glest_game/ai/path_finder.h +++ b/source/glest_game/ai/path_finder.h @@ -25,6 +25,9 @@ #include "map.h" #include "unit.h" #include "fast_path_finder.h" +//#include +//using namespace std::tr1; + #include "leak_dumper.h" using std::vector; diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 6cf6d501..91f3f0c6 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -341,6 +341,12 @@ float FastAINode::getDistance(const AI_Node *node,void *userData) { } float FastAINode::getCost(void *userData) { float result = 1.0f; + +// FastAINodeCache *nodeCache = (FastAINodeCache *)userData; +// if(map->aproxCanMoveSoon(nodeCache->unit, pos, pos) == false) { +// result = 100000; +// } + // bool checkCellObjects = true; // if(checkCellObjects == true) { // FastAINode *resultNode = map->getCellNode(pos,false); diff --git a/source/shared_lib/include/graphics/vec.h b/source/shared_lib/include/graphics/vec.h index d8835ea3..37cbe850 100644 --- a/source/shared_lib/include/graphics/vec.h +++ b/source/shared_lib/include/graphics/vec.h @@ -20,6 +20,9 @@ #include #include #include +//#include +//using namespace std::tr1; + #include "leak_dumper.h" namespace Shared{ namespace Graphics{ @@ -102,6 +105,15 @@ public: this->y= y; } + //template + //size_t operator()(const Vec2 &v) const { + // return hash()(v.x) ^ hash()(v.y); + //} + //template + //bool operator()(const Vec2 &a, const Vec2 &b) const { + // return a == b; + //} + T *ptr(){ return reinterpret_cast(this); }