bugfix for nig's issue
This commit is contained in:
parent
96d2723646
commit
22b230a5b3
|
@ -947,11 +947,16 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
UnitPathInterface *path= unit->getPath();
|
UnitPathInterface *path= unit->getPath();
|
||||||
int unitFactionIndex = unit->getFactionIndex();
|
int unitFactionIndex = unit->getFactionIndex();
|
||||||
|
|
||||||
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
|
MutexSafeWrapper safeMutexFaction(factionMutex,mutexOwnerId);
|
||||||
|
|
||||||
factions[unitFactionIndex].nodePoolCount= 0;
|
factions[unitFactionIndex].nodePoolCount= 0;
|
||||||
factions[unitFactionIndex].openNodesList.clear();
|
factions[unitFactionIndex].openNodesList.clear();
|
||||||
factions[unitFactionIndex].openPosList.clear();
|
factions[unitFactionIndex].openPosList.clear();
|
||||||
factions[unitFactionIndex].closedNodesList.clear();
|
factions[unitFactionIndex].closedNodesList.clear();
|
||||||
|
|
||||||
|
safeMutexFaction.ReleaseLock(true);
|
||||||
|
|
||||||
codeLocation = "5";
|
codeLocation = "5";
|
||||||
// check the pre-cache to see if we can re-use a cached path
|
// check the pre-cache to see if we can re-use a cached path
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
|
@ -1083,7 +1088,10 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
|
|
||||||
codeLocation = "24";
|
codeLocation = "24";
|
||||||
float dist= unitPos.dist(finalPos);
|
float dist= unitPos.dist(finalPos);
|
||||||
|
|
||||||
|
safeMutexFaction.Lock();
|
||||||
factions[unitFactionIndex].useMaxNodeCount = PathFinder::pathFindNodesMax;
|
factions[unitFactionIndex].useMaxNodeCount = PathFinder::pathFindNodesMax;
|
||||||
|
safeMutexFaction.ReleaseLock(true);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
|
@ -1260,6 +1268,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
codeLocation = "26";
|
codeLocation = "26";
|
||||||
|
|
||||||
//a) push starting pos into openNodes
|
//a) push starting pos into openNodes
|
||||||
|
safeMutexFaction.Lock();
|
||||||
Node *firstNode= newNode(factions[unitFactionIndex],maxNodeCount);
|
Node *firstNode= newNode(factions[unitFactionIndex],maxNodeCount);
|
||||||
if(firstNode == NULL) {
|
if(firstNode == NULL) {
|
||||||
throw megaglest_runtime_error("firstNode == NULL");
|
throw megaglest_runtime_error("firstNode == NULL");
|
||||||
|
@ -1276,6 +1285,8 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
factions[unitFactionIndex].openNodesList[firstNode->heuristic].push_back(firstNode);
|
factions[unitFactionIndex].openNodesList[firstNode->heuristic].push_back(firstNode);
|
||||||
factions[unitFactionIndex].openPosList[firstNode->pos] = true;
|
factions[unitFactionIndex].openPosList[firstNode->pos] = true;
|
||||||
|
|
||||||
|
safeMutexFaction.ReleaseLock(true);
|
||||||
|
|
||||||
codeLocation = "27";
|
codeLocation = "27";
|
||||||
//b) loop
|
//b) loop
|
||||||
bool pathFound = true;
|
bool pathFound = true;
|
||||||
|
@ -1619,6 +1630,8 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "60";
|
codeLocation = "60";
|
||||||
|
|
||||||
|
safeMutexFaction.Lock();
|
||||||
factions[unitFactionIndex].openNodesList.clear();
|
factions[unitFactionIndex].openNodesList.clear();
|
||||||
factions[unitFactionIndex].openPosList.clear();
|
factions[unitFactionIndex].openPosList.clear();
|
||||||
factions[unitFactionIndex].closedNodesList.clear();
|
factions[unitFactionIndex].closedNodesList.clear();
|
||||||
|
@ -1632,7 +1645,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED && chrono.getMillis() >= 5) printf("In [%s::%s Line: %d] astar took [%lld] msecs, ts = %d.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(long long int)chrono.getMillis(),ts);
|
if(SystemFlags::VERBOSE_MODE_ENABLED && chrono.getMillis() >= 5) printf("In [%s::%s Line: %d] astar took [%lld] msecs, ts = %d.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(long long int)chrono.getMillis(),ts);
|
||||||
}
|
}
|
||||||
|
safeMutexFaction.ReleaseLock();
|
||||||
//printf("$$$$ Path for Unit [%d - %s] return value = %d inBailout = %d\n",unit->getId(),unit->getFullName().c_str(),ts,inBailout);
|
//printf("$$$$ Path for Unit [%d - %s] return value = %d inBailout = %d\n",unit->getId(),unit->getFullName().c_str(),ts,inBailout);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
|
|
Loading…
Reference in New Issue