- try to avoid a hang when multiple runtime errors occur at the same time.
- attempt at small speed boost in pathfinder
This commit is contained in:
parent
e036d820d2
commit
6aa079390d
|
@ -111,6 +111,14 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
clearUnitPrecache(unit);
|
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) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
char szBuf[4096]="";
|
char szBuf[4096]="";
|
||||||
sprintf(szBuf,"[findPath] unit->getPos() [%s] finalPos [%s]",
|
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 PathFinder::processNode(Unit *unit, Node *node,const Vec2i finalPos, int i, int j, bool &nodeLimitReached,int maxNodeCount) {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
Vec2i sucPos= node->pos + Vec2i(i, j);
|
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<int, std::map<Vec2i,std::map<Vec2i, bool> > >::iterator iterFind1 = factions[unit->getFactionIndex()].mapFromToNodeList.find(unit->getType()->getId());
|
||||||
|
// if(iterFind1 != factions[unit->getFactionIndex()].mapFromToNodeList.end()) {
|
||||||
|
// std::map<Vec2i,std::map<Vec2i, bool> >::iterator iterFind2 = iterFind1->second.find(node->pos);
|
||||||
|
// if(iterFind2 != iterFind1->second.end()) {
|
||||||
|
// std::map<Vec2i, bool>::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
|
//if node is not open and canMove then generate another node
|
||||||
Node *sucNode= newNode(factions[unit->getFactionIndex()],maxNodeCount);
|
Node *sucNode= newNode(factions[unit->getFactionIndex()],maxNodeCount);
|
||||||
if(sucNode != NULL) {
|
if(sucNode != NULL) {
|
||||||
|
@ -416,6 +439,8 @@ bool PathFinder::processNode(Unit *unit, Node *node,const Vec2i finalPos, int i,
|
||||||
nodeLimitReached= true;
|
nodeLimitReached= true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// factions[unit->getFactionIndex()].mapFromToNodeList[unit->getType()->getId()][node->pos][sucPos] = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,8 @@ public:
|
||||||
useMaxNodeCount = 0;
|
useMaxNodeCount = 0;
|
||||||
precachedTravelState.clear();
|
precachedTravelState.clear();
|
||||||
precachedPath.clear();
|
precachedPath.clear();
|
||||||
|
//mapFromToNodeList.clear();
|
||||||
|
//lastFromToNodeListFrame = -100;
|
||||||
}
|
}
|
||||||
std::map<Vec2i, bool> openPosList;
|
std::map<Vec2i, bool> openPosList;
|
||||||
std::map<float, Nodes> openNodesList;
|
std::map<float, Nodes> openNodesList;
|
||||||
|
@ -85,6 +87,9 @@ public:
|
||||||
|
|
||||||
std::map<int,TravelState> precachedTravelState;
|
std::map<int,TravelState> precachedTravelState;
|
||||||
std::map<int,std::vector<Vec2i> > precachedPath;
|
std::map<int,std::vector<Vec2i> > precachedPath;
|
||||||
|
|
||||||
|
//int lastFromToNodeListFrame;
|
||||||
|
//std::map<int, std::map<Vec2i,std::map<Vec2i, bool> > > mapFromToNodeList;
|
||||||
};
|
};
|
||||||
typedef vector<FactionState> FactionStateList;
|
typedef vector<FactionState> FactionStateList;
|
||||||
|
|
||||||
|
|
|
@ -380,6 +380,15 @@ public:
|
||||||
static void handleRuntimeError(const char *msg) {
|
static void handleRuntimeError(const char *msg) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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);
|
logError(msg,true);
|
||||||
|
|
||||||
Program *program = Program::getInstance();
|
Program *program = Program::getInstance();
|
||||||
|
@ -497,6 +506,8 @@ public:
|
||||||
//program->getState()->render();
|
//program->getState()->render();
|
||||||
Window::handleEvent();
|
Window::handleEvent();
|
||||||
program->loop();
|
program->loop();
|
||||||
|
|
||||||
|
//printf("\nhandle error #1\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -507,6 +518,8 @@ public:
|
||||||
//program->renderProgramMsgBox();
|
//program->renderProgramMsgBox();
|
||||||
Window::handleEvent();
|
Window::handleEvent();
|
||||||
program->loop();
|
program->loop();
|
||||||
|
|
||||||
|
//printf("\nhandle error #2\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -547,6 +560,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeErrorMsg = errMsg;
|
runtimeErrorMsg = errMsg;
|
||||||
|
inErrorNow = false;
|
||||||
throw runtimeErrorMsg;
|
throw runtimeErrorMsg;
|
||||||
#endif
|
#endif
|
||||||
//printf("In [%s::%s Line: %d] [%s] gameInitialized = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,gameInitialized);
|
//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__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
inErrorNow = false;
|
||||||
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue