diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index bc8673ce..17c8139f 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -111,6 +111,14 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu clearUnitPrecache(unit); } +// if(frameIndex != factions[unit->getFactionIndex()].lastFromToNodeListFrame) { +// if(factions[unit->getFactionIndex()].mapFromToNodeList.size() > 0) { +// printf("clear duplicate list = %lu for faction = %d frameIndex = %d\n",factions[unit->getFactionIndex()].mapFromToNodeList.size(),unit->getFactionIndex(),frameIndex); +// factions[unit->getFactionIndex()].mapFromToNodeList.clear(); +// } +// factions[unit->getFactionIndex()].lastFromToNodeListFrame = frameIndex; +// } + if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) { char szBuf[4096]=""; sprintf(szBuf,"[findPath] unit->getPos() [%s] finalPos [%s]", @@ -394,8 +402,23 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu bool PathFinder::processNode(Unit *unit, Node *node,const Vec2i finalPos, int i, int j, bool &nodeLimitReached,int maxNodeCount) { bool result = false; Vec2i sucPos= node->pos + Vec2i(i, j); - bool canUnitMoveToCell = map->aproxCanMove(unit, node->pos, sucPos); - if(canUnitMoveToCell == true && openPos(sucPos, factions[unit->getFactionIndex()]) == false) { + +// std::map > >::iterator iterFind1 = factions[unit->getFactionIndex()].mapFromToNodeList.find(unit->getType()->getId()); +// if(iterFind1 != factions[unit->getFactionIndex()].mapFromToNodeList.end()) { +// std::map >::iterator iterFind2 = iterFind1->second.find(node->pos); +// if(iterFind2 != iterFind1->second.end()) { +// std::map::iterator iterFind3 = iterFind2->second.find(sucPos); +// if(iterFind3 != iterFind2->second.end()) { +// //printf("found duplicate check in processNode\n"); +// return iterFind3->second; +// } +// } +// } + + //bool canUnitMoveToCell = map->aproxCanMove(unit, node->pos, sucPos); + //bool canUnitMoveToCell = map->aproxCanMoveSoon(unit, node->pos, sucPos); + if(openPos(sucPos, factions[unit->getFactionIndex()]) == false && + map->aproxCanMoveSoon(unit, node->pos, sucPos) == true) { //if node is not open and canMove then generate another node Node *sucNode= newNode(factions[unit->getFactionIndex()],maxNodeCount); if(sucNode != NULL) { @@ -416,6 +439,8 @@ bool PathFinder::processNode(Unit *unit, Node *node,const Vec2i finalPos, int i, nodeLimitReached= true; } } + +// factions[unit->getFactionIndex()].mapFromToNodeList[unit->getType()->getId()][node->pos][sucPos] = result; return result; } diff --git a/source/glest_game/ai/path_finder.h b/source/glest_game/ai/path_finder.h index 195c8efe..fb11ac64 100644 --- a/source/glest_game/ai/path_finder.h +++ b/source/glest_game/ai/path_finder.h @@ -74,6 +74,8 @@ public: useMaxNodeCount = 0; precachedTravelState.clear(); precachedPath.clear(); + //mapFromToNodeList.clear(); + //lastFromToNodeListFrame = -100; } std::map openPosList; std::map openNodesList; @@ -85,6 +87,9 @@ public: std::map precachedTravelState; std::map > precachedPath; + + //int lastFromToNodeListFrame; + //std::map > > mapFromToNodeList; }; typedef vector FactionStateList; diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index bf3869c7..aaa038b7 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -380,6 +380,15 @@ public: static void handleRuntimeError(const char *msg) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + static bool inErrorNow = false; + if(inErrorNow == true) { + printf("\n** Already in error handler, msg [%s]\n",msg); + fflush(stdout); + abort(); + return; + } + inErrorNow = true; + logError(msg,true); Program *program = Program::getInstance(); @@ -497,6 +506,8 @@ public: //program->getState()->render(); Window::handleEvent(); program->loop(); + + //printf("\nhandle error #1\n"); } } else { @@ -507,6 +518,8 @@ public: //program->renderProgramMsgBox(); Window::handleEvent(); program->loop(); + + //printf("\nhandle error #2\n"); } } if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -547,6 +560,7 @@ public: } runtimeErrorMsg = errMsg; + inErrorNow = false; throw runtimeErrorMsg; #endif //printf("In [%s::%s Line: %d] [%s] gameInitialized = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,gameInitialized); @@ -564,6 +578,8 @@ public: if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + inErrorNow = false; + abort(); }