Yes its still there. I verified that it was introduced with svn checkin 2376.
I think the current attempt to calculate random amounts of path steps is wrong . I tried it with another attempt locally without side effects so far ( too dirty to checkin ):
what I did:
I removed the current random way and used pathFindExtendRefreshNodeCountMax nodes in all places.
Then in PathFinder::findPath() I did this: It should drop the last nodes in a random way and force a new calculation. By this we get differents start moments for the next calculation
TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStuck, int frameIndex) {
if(map == NULL) {
throw runtime_error("map == NULL");
}
if(frameIndex >= 0) {
clearUnitPrecache(unit);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
char szBuf[4096]="";
sprintf(szBuf,"[findPath] unit->getPos() [%s] finalPos [%s]",
unit->getPos().getString().c_str(),finalPos.getString().c_str());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
//route cache
if(finalPos == unit->getPos()) {
if(frameIndex < 0) {
//if arrived
unit->setCurrSkill(scStop);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled == true) {
string commandDesc = "none";
Command *command= unit->getCurrCommand();
if(command != NULL && command->getCommandType() != NULL) {
commandDesc = command->getCommandType()->toString();
}
char szBuf[1024]="";
sprintf(szBuf,"State: arrived#1 at pos: %s, command [%s]",finalPos.getString().c_str(),commandDesc.c_str());
unit->setCurrentUnitTitle(szBuf);
}
return tsArrived;
}
!!!!!!!!!!!!!!!!!!! new part here
UnitPathInterface *path= unit->getPath();
if(path->getQueueCount() > pathFindExtendRefreshNodeCountMin){
if(factions[unit->getFactionIndex()].random.randRange(pathFindExtendRefreshNodeCountMin,
pathFindExtendRefreshNodeCountMax) == pathFindExtendRefreshNodeCountMin){
// empty path and recalculate
if(dynamic_cast<UnitPathBasic *> (path) != NULL){
UnitPathBasic *basicPath= dynamic_cast<UnitPathBasic *> (path);
while(!path->isEmpty()){
basicPath->pop(true);
}
}
else if(dynamic_cast<UnitPath *> (path) != NULL){
UnitPath *advPath= dynamic_cast<UnitPath *> (path);
while(!path->isEmpty()){
advPath->pop();
}
}
}
}
!!!!!!!!!!!!!!!!!!!!! new part end
if(path->isEmpty() == false) {
if(dynamic_cast<UnitPathBasic *>(path) != NULL) {
//route cache
UnitPathBasic *basicPath = dynamic_cast<UnitPathBasic *>(path);
Vec2i pos= basicPath->pop(frameIndex < 0);
if(map->canMove(unit, unit->getPos(), pos)) {
if(frameIndex < 0) {
unit->setTargetPos(pos);
}
return tsMoving;
}
}
else if(dynamic_cast<UnitPath *>(path) != NULL) {
UnitPath *advPath = dynamic_cast<UnitPath *>(path);
//route cache
Vec2i pos= advPath->peek();
if(map->canMove(unit, unit->getPos(), pos)) {
if(frameIndex < 0) {
advPath->pop();
unit->setTargetPos(pos);
}
return tsMoving;
}
}
else {
throw runtime_error("unsupported or missing path finder detected!");
}
}
if(path->isStuck() == true && unit->getLastStuckPos() == finalPos &&
unit->isLastStuckFrameWithinCurrentFrameTolerance() == true) {
//printf("$$$$ Unit STILL BLOCKED for [%d - %s]\n",unit->getId(),unit->getFullName().c_str());
return tsBlocked;
}