- more pathfinder in progress changes, nothing to test yet

This commit is contained in:
Mark Vejvoda 2012-05-05 04:38:49 +00:00
parent 3ff0796bec
commit f79222defa
5 changed files with 33 additions and 12 deletions

View File

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

View File

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

View File

@ -25,6 +25,9 @@
#include "map.h"
#include "unit.h"
#include "fast_path_finder.h"
//#include <tr1/unordered_map>
//using namespace std::tr1;
#include "leak_dumper.h"
using std::vector;

View File

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

View File

@ -20,6 +20,9 @@
#include <stdexcept>
#include <stdlib.h>
#include <stdio.h>
//#include <tr1/unordered_map>
//using namespace std::tr1;
#include "leak_dumper.h"
namespace Shared{ namespace Graphics{
@ -102,6 +105,15 @@ public:
this->y= y;
}
//template<typename S>
//size_t operator()(const Vec2<S> &v) const {
// return hash<T>()(v.x) ^ hash<T>()(v.y);
//}
//template<typename S>
//bool operator()(const Vec2<S> &a, const Vec2<S> &b) const {
// return a == b;
//}
T *ptr(){
return reinterpret_cast<T*>(this);
}