- removed debug code
This commit is contained in:
parent
d48d63b1fa
commit
3671bd0617
|
@ -129,7 +129,6 @@ void PathFinder::removeUnitPrecache(Unit *unit) {
|
||||||
TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStuck, int frameIndex) {
|
TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStuck, int frameIndex) {
|
||||||
TravelState ts = tsImpossible;
|
TravelState ts = tsImpossible;
|
||||||
|
|
||||||
string codeLocation = "1";
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
int factionIndex = unit->getFactionIndex();
|
int factionIndex = unit->getFactionIndex();
|
||||||
|
@ -143,18 +142,14 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
|
|
||||||
unit->setCurrentPathFinderDesiredFinalPos(finalPos);
|
unit->setCurrentPathFinderDesiredFinalPos(finalPos);
|
||||||
|
|
||||||
codeLocation = "2";
|
|
||||||
|
|
||||||
if(frameIndex >= 0) {
|
if(frameIndex >= 0) {
|
||||||
codeLocation = "2";
|
|
||||||
clearUnitPrecache(unit);
|
clearUnitPrecache(unit);
|
||||||
}
|
}
|
||||||
if(unit->getFaction()->canUnitsPathfind() == true) {
|
if(unit->getFaction()->canUnitsPathfind() == true) {
|
||||||
codeLocation = "3";
|
|
||||||
unit->getFaction()->addUnitToPathfindingList(unit->getId());
|
unit->getFaction()->addUnitToPathfindingList(unit->getId());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "4";
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"canUnitsPathfind() == false");
|
snprintf(szBuf,8096,"canUnitsPathfind() == false");
|
||||||
|
@ -173,9 +168,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
|
|
||||||
//route cache
|
//route cache
|
||||||
if(finalPos == unit->getPos()) {
|
if(finalPos == unit->getPos()) {
|
||||||
codeLocation = "5";
|
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "6";
|
|
||||||
//if arrived
|
//if arrived
|
||||||
unit->setCurrSkill(scStop);
|
unit->setCurrSkill(scStop);
|
||||||
|
|
||||||
|
@ -200,20 +193,15 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
return tsArrived;
|
return tsArrived;
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "7";
|
|
||||||
UnitPathInterface *path= unit->getPath();
|
UnitPathInterface *path= unit->getPath();
|
||||||
if(path->isEmpty() == false) {
|
if(path->isEmpty() == false) {
|
||||||
codeLocation = "8";
|
|
||||||
if(dynamic_cast<UnitPathBasic *>(path) != NULL) {
|
if(dynamic_cast<UnitPathBasic *>(path) != NULL) {
|
||||||
codeLocation = "9";
|
|
||||||
//route cache
|
//route cache
|
||||||
UnitPathBasic *basicPath = dynamic_cast<UnitPathBasic *>(path);
|
UnitPathBasic *basicPath = dynamic_cast<UnitPathBasic *>(path);
|
||||||
Vec2i pos= basicPath->pop(frameIndex < 0);
|
Vec2i pos= basicPath->pop(frameIndex < 0);
|
||||||
|
|
||||||
if(map->canMove(unit, unit->getPos(), pos)) {
|
if(map->canMove(unit, unit->getPos(), pos)) {
|
||||||
codeLocation = "10";
|
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "11";
|
|
||||||
unit->setTargetPos(pos);
|
unit->setTargetPos(pos);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
|
||||||
|
@ -228,12 +216,10 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(dynamic_cast<UnitPath *>(path) != NULL) {
|
else if(dynamic_cast<UnitPath *>(path) != NULL) {
|
||||||
codeLocation = "12";
|
|
||||||
UnitPath *advPath = dynamic_cast<UnitPath *>(path);
|
UnitPath *advPath = dynamic_cast<UnitPath *>(path);
|
||||||
//route cache
|
//route cache
|
||||||
Vec2i pos= advPath->peek();
|
Vec2i pos= advPath->peek();
|
||||||
if(map->canMove(unit, unit->getPos(), pos)) {
|
if(map->canMove(unit, unit->getPos(), pos)) {
|
||||||
codeLocation = "13";
|
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
advPath->pop();
|
advPath->pop();
|
||||||
unit->setTargetPos(pos);
|
unit->setTargetPos(pos);
|
||||||
|
@ -247,11 +233,9 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "14";
|
|
||||||
if(path->isStuck() == true &&
|
if(path->isStuck() == true &&
|
||||||
(unit->getLastStuckPos() == finalPos || path->getBlockCount() > 500) &&
|
(unit->getLastStuckPos() == finalPos || path->getBlockCount() > 500) &&
|
||||||
unit->isLastStuckFrameWithinCurrentFrameTolerance(frameIndex >= 0) == true) {
|
unit->isLastStuckFrameWithinCurrentFrameTolerance(frameIndex >= 0) == true) {
|
||||||
codeLocation = "15";
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"path->isStuck() == true unit->getLastStuckPos() [%s] finalPos [%s] path->getBlockCount() [%d]",unit->getLastStuckPos().getString().c_str(),finalPos.getString().c_str(),path->getBlockCount());
|
snprintf(szBuf,8096,"path->isStuck() == true unit->getLastStuckPos() [%s] finalPos [%s] path->getBlockCount() [%d]",unit->getLastStuckPos().getString().c_str(),finalPos.getString().c_str(),path->getBlockCount());
|
||||||
|
@ -262,10 +246,8 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
|
|
||||||
//route cache miss
|
//route cache miss
|
||||||
codeLocation = "16";
|
|
||||||
int maxNodeCount=-1;
|
int maxNodeCount=-1;
|
||||||
if(unit->getUsePathfinderExtendedMaxNodes() == true) {
|
if(unit->getUsePathfinderExtendedMaxNodes() == true) {
|
||||||
codeLocation = "17";
|
|
||||||
|
|
||||||
maxNodeCount= PathFinder::pathFindNodesAbsoluteMax;
|
maxNodeCount= PathFinder::pathFindNodesAbsoluteMax;
|
||||||
|
|
||||||
|
@ -276,7 +258,6 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "18";
|
|
||||||
bool minorDebugPathfinderPerformance = false;
|
bool minorDebugPathfinderPerformance = false;
|
||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
if(minorDebugPathfinderPerformance) chrono.start();
|
if(minorDebugPathfinderPerformance) chrono.start();
|
||||||
|
@ -291,20 +272,16 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
|
unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "19";
|
|
||||||
ts = aStar(unit, finalPos, false, frameIndex, maxNodeCount,&searched_node_count);
|
ts = aStar(unit, finalPos, false, frameIndex, maxNodeCount,&searched_node_count);
|
||||||
codeLocation = "20";
|
|
||||||
//post actions
|
//post actions
|
||||||
switch(ts) {
|
switch(ts) {
|
||||||
case tsBlocked:
|
case tsBlocked:
|
||||||
case tsArrived:
|
case tsArrived:
|
||||||
codeLocation = "21";
|
|
||||||
// The unit is stuck (not only blocked but unable to go anywhere for a while)
|
// The unit is stuck (not only blocked but unable to go anywhere for a while)
|
||||||
// We will try to bail out of the immediate area
|
// We will try to bail out of the immediate area
|
||||||
if( ts == tsBlocked && unit->getInBailOutAttempt() == false &&
|
if( ts == tsBlocked && unit->getInBailOutAttempt() == false &&
|
||||||
path->isStuck() == true) {
|
path->isStuck() == true) {
|
||||||
|
|
||||||
codeLocation = "22";
|
|
||||||
if(minorDebugPathfinder) printf("Pathfind Unit [%d - %s] START BAILOUT ATTEMPT frameIndex = %d\n",unit->getId(),unit->getType()->getName(false).c_str(),frameIndex);
|
if(minorDebugPathfinder) printf("Pathfind Unit [%d - %s] START BAILOUT ATTEMPT frameIndex = %d\n",unit->getId(),unit->getType()->getName(false).c_str(),frameIndex);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
|
@ -319,7 +296,6 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
unit->setInBailOutAttempt(true);
|
unit->setInBailOutAttempt(true);
|
||||||
|
|
||||||
codeLocation = "23";
|
|
||||||
bool unitImmediatelyBlocked = false;
|
bool unitImmediatelyBlocked = false;
|
||||||
|
|
||||||
// First check if unit currently blocked all around them, if so don't try to pathfind
|
// First check if unit currently blocked all around them, if so don't try to pathfind
|
||||||
|
@ -327,7 +303,6 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
int failureCount = 0;
|
int failureCount = 0;
|
||||||
int cellCount = 0;
|
int cellCount = 0;
|
||||||
|
|
||||||
codeLocation = "24";
|
|
||||||
for(int i = -1; i <= 1; ++i) {
|
for(int i = -1; i <= 1; ++i) {
|
||||||
for(int j = -1; j <= 1; ++j) {
|
for(int j = -1; j <= 1; ++j) {
|
||||||
Vec2i pos = unitPos + Vec2i(i, j);
|
Vec2i pos = unitPos + Vec2i(i, j);
|
||||||
|
@ -342,7 +317,6 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
unitImmediatelyBlocked = (failureCount == cellCount);
|
unitImmediatelyBlocked = (failureCount == cellCount);
|
||||||
if(unitImmediatelyBlocked == false) {
|
if(unitImmediatelyBlocked == false) {
|
||||||
codeLocation = "25";
|
|
||||||
|
|
||||||
int factionIndex = unit->getFactionIndex();
|
int factionIndex = unit->getFactionIndex();
|
||||||
FactionState &faction = factions.getFactionState(factionIndex);
|
FactionState &faction = factions.getFactionState(factionIndex);
|
||||||
|
@ -353,7 +327,6 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
if(tryRadius > 0) {
|
if(tryRadius > 0) {
|
||||||
for(int bailoutX = -PathFinder::pathFindBailoutRadius; bailoutX <= PathFinder::pathFindBailoutRadius && ts == tsBlocked; ++bailoutX) {
|
for(int bailoutX = -PathFinder::pathFindBailoutRadius; bailoutX <= PathFinder::pathFindBailoutRadius && ts == tsBlocked; ++bailoutX) {
|
||||||
for(int bailoutY = -PathFinder::pathFindBailoutRadius; bailoutY <= PathFinder::pathFindBailoutRadius && ts == tsBlocked; ++bailoutY) {
|
for(int bailoutY = -PathFinder::pathFindBailoutRadius; bailoutY <= PathFinder::pathFindBailoutRadius && ts == tsBlocked; ++bailoutY) {
|
||||||
codeLocation = "26";
|
|
||||||
const Vec2i newFinalPos = finalPos + Vec2i(bailoutX,bailoutY);
|
const Vec2i newFinalPos = finalPos + Vec2i(bailoutX,bailoutY);
|
||||||
bool canUnitMove = map->canMove(unit, unit->getPos(), newFinalPos);
|
bool canUnitMove = map->canMove(unit, unit->getPos(), newFinalPos);
|
||||||
|
|
||||||
|
@ -365,7 +338,6 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canUnitMove) {
|
if(canUnitMove) {
|
||||||
codeLocation = "27";
|
|
||||||
|
|
||||||
int maxBailoutNodeCount = (PathFinder::pathFindBailoutRadius * 2);
|
int maxBailoutNodeCount = (PathFinder::pathFindBailoutRadius * 2);
|
||||||
|
|
||||||
|
@ -376,16 +348,13 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
|
|
||||||
ts= aStar(unit, newFinalPos, true, frameIndex, maxBailoutNodeCount,&searched_node_count);
|
ts= aStar(unit, newFinalPos, true, frameIndex, maxBailoutNodeCount,&searched_node_count);
|
||||||
codeLocation = "28";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "29";
|
|
||||||
for(int bailoutX = PathFinder::pathFindBailoutRadius; bailoutX >= -PathFinder::pathFindBailoutRadius && ts == tsBlocked; --bailoutX) {
|
for(int bailoutX = PathFinder::pathFindBailoutRadius; bailoutX >= -PathFinder::pathFindBailoutRadius && ts == tsBlocked; --bailoutX) {
|
||||||
for(int bailoutY = PathFinder::pathFindBailoutRadius; bailoutY >= -PathFinder::pathFindBailoutRadius && ts == tsBlocked; --bailoutY) {
|
for(int bailoutY = PathFinder::pathFindBailoutRadius; bailoutY >= -PathFinder::pathFindBailoutRadius && ts == tsBlocked; --bailoutY) {
|
||||||
codeLocation = "30";
|
|
||||||
const Vec2i newFinalPos = finalPos + Vec2i(bailoutX,bailoutY);
|
const Vec2i newFinalPos = finalPos + Vec2i(bailoutX,bailoutY);
|
||||||
bool canUnitMove = map->canMove(unit, unit->getPos(), newFinalPos);
|
bool canUnitMove = map->canMove(unit, unit->getPos(), newFinalPos);
|
||||||
|
|
||||||
|
@ -397,7 +366,6 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canUnitMove) {
|
if(canUnitMove) {
|
||||||
codeLocation = "31";
|
|
||||||
int maxBailoutNodeCount = (PathFinder::pathFindBailoutRadius * 2);
|
int maxBailoutNodeCount = (PathFinder::pathFindBailoutRadius * 2);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
|
@ -407,40 +375,33 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
|
|
||||||
ts= aStar(unit, newFinalPos, true, frameIndex, maxBailoutNodeCount,&searched_node_count);
|
ts= aStar(unit, newFinalPos, true, frameIndex, maxBailoutNodeCount,&searched_node_count);
|
||||||
codeLocation = "32";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codeLocation = "33";
|
|
||||||
unit->setInBailOutAttempt(false);
|
unit->setInBailOutAttempt(false);
|
||||||
|
|
||||||
if(ts == tsBlocked) {
|
if(ts == tsBlocked) {
|
||||||
codeLocation = "34";
|
|
||||||
unit->setLastStuckFrameToCurrentFrame();
|
unit->setLastStuckFrameToCurrentFrame();
|
||||||
unit->setLastStuckPos(finalPos);
|
unit->setLastStuckPos(finalPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ts == tsArrived || ts == tsBlocked) {
|
if(ts == tsArrived || ts == tsBlocked) {
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "35";
|
|
||||||
unit->setCurrSkill(scStop);
|
unit->setCurrSkill(scStop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tsMoving:
|
case tsMoving:
|
||||||
{
|
{
|
||||||
codeLocation = "36";
|
|
||||||
if(dynamic_cast<UnitPathBasic *>(path) != NULL) {
|
if(dynamic_cast<UnitPathBasic *>(path) != NULL) {
|
||||||
UnitPathBasic *basicPath = dynamic_cast<UnitPathBasic *>(path);
|
UnitPathBasic *basicPath = dynamic_cast<UnitPathBasic *>(path);
|
||||||
Vec2i pos;
|
Vec2i pos;
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "37";
|
|
||||||
pos = basicPath->pop(frameIndex < 0);
|
pos = basicPath->pop(frameIndex < 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "38";
|
|
||||||
|
|
||||||
if(faction.precachedPath[unit->getId()].size() <= 0) {
|
if(faction.precachedPath[unit->getId()].size() <= 0) {
|
||||||
throw megaglest_runtime_error("factions[unit->getFactionIndex()].precachedPath[unit->getId()].size() <= 0!");
|
throw megaglest_runtime_error("factions[unit->getFactionIndex()].precachedPath[unit->getId()].size() <= 0!");
|
||||||
|
@ -448,20 +409,15 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
|
|
||||||
pos = faction.precachedPath[unit->getId()][0];
|
pos = faction.precachedPath[unit->getId()][0];
|
||||||
|
|
||||||
codeLocation = "39";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "40";
|
|
||||||
if(map->canMove(unit, unit->getPos(), pos)) {
|
if(map->canMove(unit, unit->getPos(), pos)) {
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "41";
|
|
||||||
unit->setTargetPos(pos);
|
unit->setTargetPos(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "42";
|
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "43";
|
|
||||||
unit->setCurrSkill(scStop);
|
unit->setCurrSkill(scStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,19 +433,16 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(dynamic_cast<UnitPath *>(path) != NULL) {
|
else if(dynamic_cast<UnitPath *>(path) != NULL) {
|
||||||
codeLocation = "44";
|
|
||||||
UnitPath *advPath = dynamic_cast<UnitPath *>(path);
|
UnitPath *advPath = dynamic_cast<UnitPath *>(path);
|
||||||
Vec2i pos= advPath->peek();
|
Vec2i pos= advPath->peek();
|
||||||
if(map->canMove(unit, unit->getPos(), pos)) {
|
if(map->canMove(unit, unit->getPos(), pos)) {
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "45";
|
|
||||||
advPath->pop();
|
advPath->pop();
|
||||||
unit->setTargetPos(pos);
|
unit->setTargetPos(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "46";
|
|
||||||
unit->setCurrSkill(scStop);
|
unit->setCurrSkill(scStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,21 +458,20 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
codeLocation = "47";
|
|
||||||
if(minorDebugPathfinderPerformance && chrono.getMillis() >= 1) printf("Unit [%d - %s] astar took [%lld] msecs, ts = %d searched_node_count = %d.\n",unit->getId(),unit->getType()->getName(false).c_str(),(long long int)chrono.getMillis(),ts,searched_node_count);
|
if(minorDebugPathfinderPerformance && chrono.getMillis() >= 1) printf("Unit [%d - %s] astar took [%lld] msecs, ts = %d searched_node_count = %d.\n",unit->getId(),unit->getType()->getName(false).c_str(),(long long int)chrono.getMillis(),ts,searched_node_count);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
//setRunningStatus(false);
|
//setRunningStatus(false);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Loc [%s] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str(),ex.what());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
throw megaglest_runtime_error(ex.what());
|
throw megaglest_runtime_error(ex.what());
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error Loc [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str());
|
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
@ -534,7 +486,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
int frameIndex, int maxNodeCount, uint32 *searched_node_count) {
|
int frameIndex, int maxNodeCount, uint32 *searched_node_count) {
|
||||||
TravelState ts = tsImpossible;
|
TravelState ts = tsImpossible;
|
||||||
|
|
||||||
string codeLocation = "1";
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
int unitFactionIndex = unit->getFactionIndex();
|
int unitFactionIndex = unit->getFactionIndex();
|
||||||
|
@ -554,10 +505,8 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
throw megaglest_runtime_error("map == NULL");
|
throw megaglest_runtime_error("map == NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "2";
|
|
||||||
|
|
||||||
if(maxNodeCount < 0) {
|
if(maxNodeCount < 0) {
|
||||||
codeLocation = "3";
|
|
||||||
|
|
||||||
int factionIndex = unit->getFactionIndex();
|
int factionIndex = unit->getFactionIndex();
|
||||||
FactionState &faction = factions.getFactionState(factionIndex);
|
FactionState &faction = factions.getFactionState(factionIndex);
|
||||||
|
@ -569,7 +518,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
maxNodeCount = 200;
|
maxNodeCount = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "4";
|
|
||||||
UnitPathInterface *path= unit->getPath();
|
UnitPathInterface *path= unit->getPath();
|
||||||
|
|
||||||
faction.nodePoolCount= 0;
|
faction.nodePoolCount= 0;
|
||||||
|
@ -577,14 +525,11 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
faction.openPosList.clear();
|
faction.openPosList.clear();
|
||||||
faction.closedNodesList.clear();
|
faction.closedNodesList.clear();
|
||||||
|
|
||||||
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) {
|
||||||
codeLocation = "6";
|
|
||||||
|
|
||||||
bool foundPrecacheTravelState = (faction.precachedTravelState.find(unit->getId()) != faction.precachedTravelState.end());
|
bool foundPrecacheTravelState = (faction.precachedTravelState.find(unit->getId()) != faction.precachedTravelState.end());
|
||||||
if(foundPrecacheTravelState == true) {
|
if(foundPrecacheTravelState == true) {
|
||||||
codeLocation = "7";
|
|
||||||
|
|
||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
// char szBuf[8096]="";
|
// char szBuf[8096]="";
|
||||||
|
@ -594,7 +539,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
|
|
||||||
bool foundPrecacheTravelStateIsMoving = (faction.precachedTravelState[unit->getId()] == tsMoving);
|
bool foundPrecacheTravelStateIsMoving = (faction.precachedTravelState[unit->getId()] == tsMoving);
|
||||||
if(foundPrecacheTravelStateIsMoving == true) {
|
if(foundPrecacheTravelStateIsMoving == true) {
|
||||||
codeLocation = "8";
|
|
||||||
bool canMoveToCells = true;
|
bool canMoveToCells = true;
|
||||||
|
|
||||||
Vec2i lastPos = unit->getPos();
|
Vec2i lastPos = unit->getPos();
|
||||||
|
@ -602,7 +546,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
int unitPrecachePathSize = (int)faction.precachedPath[unit->getId()].size();
|
int unitPrecachePathSize = (int)faction.precachedPath[unit->getId()].size();
|
||||||
|
|
||||||
for(int i=0; i < unitPrecachePathSize; i++) {
|
for(int i=0; i < unitPrecachePathSize; i++) {
|
||||||
codeLocation = "9";
|
|
||||||
|
|
||||||
Vec2i nodePos = faction.precachedPath[unit->getId()][i];
|
Vec2i nodePos = faction.precachedPath[unit->getId()][i];
|
||||||
|
|
||||||
|
@ -613,7 +556,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
if(i < unit->getPathFindRefreshCellCount() ||
|
if(i < unit->getPathFindRefreshCellCount() ||
|
||||||
(unitPrecachePathSize >= pathFindExtendRefreshForNodeCount &&
|
(unitPrecachePathSize >= pathFindExtendRefreshForNodeCount &&
|
||||||
i < getPathFindExtendRefreshNodeCount(faction))) {
|
i < getPathFindExtendRefreshNodeCount(faction))) {
|
||||||
codeLocation = "10";
|
|
||||||
|
|
||||||
if(canUnitMoveSoon(unit, lastPos, nodePos) == false) {
|
if(canUnitMoveSoon(unit, lastPos, nodePos) == false) {
|
||||||
canMoveToCells = false;
|
canMoveToCells = false;
|
||||||
|
@ -626,16 +568,13 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "11";
|
|
||||||
if(canMoveToCells == true) {
|
if(canMoveToCells == true) {
|
||||||
codeLocation = "12";
|
|
||||||
path->clear();
|
path->clear();
|
||||||
UnitPathBasic *basicPathFinder = dynamic_cast<UnitPathBasic *>(path);
|
UnitPathBasic *basicPathFinder = dynamic_cast<UnitPathBasic *>(path);
|
||||||
|
|
||||||
int unitPrecachePathSize = (int)faction.precachedPath[unit->getId()].size();
|
int unitPrecachePathSize = (int)faction.precachedPath[unit->getId()].size();
|
||||||
|
|
||||||
for(int i=0; i < unitPrecachePathSize; i++) {
|
for(int i=0; i < unitPrecachePathSize; i++) {
|
||||||
codeLocation = "13";
|
|
||||||
|
|
||||||
Vec2i nodePos = faction.precachedPath[unit->getId()][i];
|
Vec2i nodePos = faction.precachedPath[unit->getId()][i];
|
||||||
|
|
||||||
|
@ -647,11 +586,9 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
if(i < unit->getPathFindRefreshCellCount() ||
|
if(i < unit->getPathFindRefreshCellCount() ||
|
||||||
(unitPrecachePathSize >= pathFindExtendRefreshForNodeCount &&
|
(unitPrecachePathSize >= pathFindExtendRefreshForNodeCount &&
|
||||||
i < getPathFindExtendRefreshNodeCount(faction))) {
|
i < getPathFindExtendRefreshNodeCount(faction))) {
|
||||||
codeLocation = "14";
|
|
||||||
path->add(nodePos);
|
path->add(nodePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codeLocation = "16";
|
|
||||||
unit->setUsePathfinderExtendedMaxNodes(false);
|
unit->setUsePathfinderExtendedMaxNodes(false);
|
||||||
|
|
||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
|
@ -660,21 +597,17 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
// unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
|
// unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
codeLocation = "17";
|
|
||||||
return faction.precachedTravelState[unit->getId()];
|
return faction.precachedTravelState[unit->getId()];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "18";
|
|
||||||
clearUnitPrecache(unit);
|
clearUnitPrecache(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "19";
|
|
||||||
|
|
||||||
bool foundPrecacheTravelStateIsBlocked = (faction.precachedTravelState[unit->getId()] == tsBlocked);
|
bool foundPrecacheTravelStateIsBlocked = (faction.precachedTravelState[unit->getId()] == tsBlocked);
|
||||||
|
|
||||||
if(foundPrecacheTravelStateIsBlocked == true) {
|
if(foundPrecacheTravelStateIsBlocked == true) {
|
||||||
codeLocation = "20";
|
|
||||||
path->incBlockCount();
|
path->incBlockCount();
|
||||||
unit->setUsePathfinderExtendedMaxNodes(false);
|
unit->setUsePathfinderExtendedMaxNodes(false);
|
||||||
|
|
||||||
|
@ -684,14 +617,12 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
// unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
|
// unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
codeLocation = "21";
|
|
||||||
return faction.precachedTravelState[unit->getId()];
|
return faction.precachedTravelState[unit->getId()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "22";
|
|
||||||
clearUnitPrecache(unit);
|
clearUnitPrecache(unit);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
|
@ -701,11 +632,9 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "23";
|
|
||||||
const Vec2i unitPos = unit->getPos();
|
const Vec2i unitPos = unit->getPos();
|
||||||
const Vec2i finalPos= computeNearestFreePos(unit, targetPos);
|
const Vec2i finalPos= computeNearestFreePos(unit, targetPos);
|
||||||
|
|
||||||
codeLocation = "24";
|
|
||||||
float dist= unitPos.dist(finalPos);
|
float dist= unitPos.dist(finalPos);
|
||||||
|
|
||||||
faction.useMaxNodeCount = PathFinder::pathFindNodesMax;
|
faction.useMaxNodeCount = PathFinder::pathFindNodesMax;
|
||||||
|
@ -713,7 +642,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
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());
|
||||||
|
|
||||||
//path find algorithm
|
//path find algorithm
|
||||||
codeLocation = "26";
|
|
||||||
|
|
||||||
//a) push starting pos into openNodes
|
//a) push starting pos into openNodes
|
||||||
Node *firstNode= newNode(faction,maxNodeCount);
|
Node *firstNode= newNode(faction,maxNodeCount);
|
||||||
|
@ -732,7 +660,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
faction.openNodesList[firstNode->heuristic].push_back(firstNode);
|
faction.openNodesList[firstNode->heuristic].push_back(firstNode);
|
||||||
faction.openPosList[firstNode->pos] = true;
|
faction.openPosList[firstNode->pos] = true;
|
||||||
|
|
||||||
codeLocation = "27";
|
|
||||||
//b) loop
|
//b) loop
|
||||||
bool pathFound = true;
|
bool pathFound = true;
|
||||||
bool nodeLimitReached = false;
|
bool nodeLimitReached = false;
|
||||||
|
@ -742,7 +669,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
|
|
||||||
// First check if unit currently blocked all around them, if so don't try to pathfind
|
// First check if unit currently blocked all around them, if so don't try to pathfind
|
||||||
if(inBailout == false && unitPos != finalPos) {
|
if(inBailout == false && unitPos != finalPos) {
|
||||||
codeLocation = "28";
|
|
||||||
int failureCount = 0;
|
int failureCount = 0;
|
||||||
int cellCount = 0;
|
int cellCount = 0;
|
||||||
|
|
||||||
|
@ -769,9 +695,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] **Check if dest blocked, distance for unit [%d - %s] from [%s] to [%s] is %.2f took msecs: %lld nodeLimitReached = %d, failureCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unit->getId(),unit->getFullName(false).c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,failureCount);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] **Check if dest blocked, distance for unit [%d - %s] from [%s] to [%s] is %.2f took msecs: %lld nodeLimitReached = %d, failureCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unit->getId(),unit->getFullName(false).c_str(), unitPos.getString().c_str(), finalPos.getString().c_str(), dist,(long long int)chrono.getMillis(),nodeLimitReached,failureCount);
|
||||||
|
|
||||||
codeLocation = "29";
|
|
||||||
if(nodeLimitReached == false) {
|
if(nodeLimitReached == false) {
|
||||||
codeLocation = "30";
|
|
||||||
// First check if final destination blocked
|
// First check if final destination blocked
|
||||||
failureCount = 0;
|
failureCount = 0;
|
||||||
cellCount = 0;
|
cellCount = 0;
|
||||||
|
@ -809,7 +733,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
codeLocation = "31";
|
|
||||||
// START
|
// START
|
||||||
std::map<std::pair<Vec2i,Vec2i> ,bool> canAddNode;
|
std::map<std::pair<Vec2i,Vec2i> ,bool> canAddNode;
|
||||||
std::map<Vec2i,bool> closedNodes;
|
std::map<Vec2i,bool> closedNodes;
|
||||||
|
@ -819,7 +742,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
// Do the a-star base pathfind work if required
|
// Do the a-star base pathfind work if required
|
||||||
int whileLoopCount = 0;
|
int whileLoopCount = 0;
|
||||||
if(nodeLimitReached == false) {
|
if(nodeLimitReached == false) {
|
||||||
codeLocation = "32";
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
|
@ -832,22 +754,18 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
pathFound, node, finalPos,
|
pathFound, node, finalPos,
|
||||||
closedNodes, cameFrom, canAddNode, unit, maxNodeCount,frameIndex);
|
closedNodes, cameFrom, canAddNode, unit, maxNodeCount,frameIndex);
|
||||||
|
|
||||||
codeLocation = "33";
|
|
||||||
if(searched_node_count != NULL) {
|
if(searched_node_count != NULL) {
|
||||||
*searched_node_count = whileLoopCount;
|
*searched_node_count = whileLoopCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now see if the unit is eligible for pathfind max nodes boost?
|
// Now see if the unit is eligible for pathfind max nodes boost?
|
||||||
if(nodeLimitReached == true) {
|
if(nodeLimitReached == true) {
|
||||||
codeLocation = "34";
|
|
||||||
unit->incrementPathfindFailedConsecutiveFrameCount();
|
unit->incrementPathfindFailedConsecutiveFrameCount();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "35";
|
|
||||||
unit->resetPathfindFailedConsecutiveFrameCount();
|
unit->resetPathfindFailedConsecutiveFrameCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "36";
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"Calling doAStarPathSearch nodeLimitReached: %d whileLoopCount: %d unitFactionIndex: %d pathFound: %d finalPos [%s] maxNodeCount: %d pathFindNodesAbsoluteMax: %d frameIndex: %d",nodeLimitReached, whileLoopCount, unitFactionIndex,
|
snprintf(szBuf,8096,"Calling doAStarPathSearch nodeLimitReached: %d whileLoopCount: %d unitFactionIndex: %d pathFound: %d finalPos [%s] maxNodeCount: %d pathFindNodesAbsoluteMax: %d frameIndex: %d",nodeLimitReached, whileLoopCount, unitFactionIndex,
|
||||||
|
@ -856,11 +774,8 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nodeLimitReached == true && maxNodeCount != pathFindNodesAbsoluteMax) {
|
if(nodeLimitReached == true && maxNodeCount != pathFindNodesAbsoluteMax) {
|
||||||
codeLocation = "37";
|
|
||||||
if(unit->isLastPathfindFailedFrameWithinCurrentFrameTolerance() == true) {
|
if(unit->isLastPathfindFailedFrameWithinCurrentFrameTolerance() == true) {
|
||||||
codeLocation = "38";
|
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "39";
|
|
||||||
unit->setLastPathfindFailedFrameToCurrentFrame();
|
unit->setLastPathfindFailedFrameToCurrentFrame();
|
||||||
unit->setLastPathfindFailedPos(finalPos);
|
unit->setLastPathfindFailedPos(finalPos);
|
||||||
}
|
}
|
||||||
|
@ -883,19 +798,15 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "40";
|
|
||||||
|
|
||||||
Node *lastNode= node;
|
Node *lastNode= node;
|
||||||
|
|
||||||
//if consumed all nodes find best node (to avoid strange behaviour)
|
//if consumed all nodes find best node (to avoid strange behaviour)
|
||||||
if(nodeLimitReached == true) {
|
if(nodeLimitReached == true) {
|
||||||
codeLocation = "41";
|
|
||||||
|
|
||||||
if(faction.closedNodesList.empty() == false) {
|
if(faction.closedNodesList.empty() == false) {
|
||||||
codeLocation = "42";
|
|
||||||
float bestHeuristic = faction.closedNodesList.begin()->first;
|
float bestHeuristic = faction.closedNodesList.begin()->first;
|
||||||
if(bestHeuristic < lastNode->heuristic) {
|
if(bestHeuristic < lastNode->heuristic) {
|
||||||
codeLocation = "43";
|
|
||||||
lastNode= faction.closedNodesList.begin()->second[0];
|
lastNode= faction.closedNodesList.begin()->second[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -903,11 +814,9 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
codeLocation = "44";
|
|
||||||
//check results of path finding
|
//check results of path finding
|
||||||
ts = tsImpossible;
|
ts = tsImpossible;
|
||||||
if(pathFound == false || lastNode == firstNode) {
|
if(pathFound == false || lastNode == firstNode) {
|
||||||
codeLocation = "45";
|
|
||||||
if(minorDebugPathfinder) printf("Legacy Pathfind Unit [%d - %s] NOT FOUND PATH count = %d frameIndex = %d\n",unit->getId(),unit->getType()->getName().c_str(),whileLoopCount,frameIndex);
|
if(minorDebugPathfinder) printf("Legacy Pathfind Unit [%d - %s] NOT FOUND PATH count = %d frameIndex = %d\n",unit->getId(),unit->getType()->getName().c_str(),whileLoopCount,frameIndex);
|
||||||
|
|
||||||
//blocked
|
//blocked
|
||||||
|
@ -926,20 +835,17 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
|
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "46";
|
|
||||||
unit->setUsePathfinderExtendedMaxNodes(false);
|
unit->setUsePathfinderExtendedMaxNodes(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ts= tsBlocked;
|
ts= tsBlocked;
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "47";
|
|
||||||
path->incBlockCount();
|
path->incBlockCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "48";
|
|
||||||
if(minorDebugPathfinder) printf("Legacy Pathfind Unit [%d - %s] FOUND PATH count = %d frameIndex = %d\n",unit->getId(),unit->getType()->getName().c_str(),whileLoopCount,frameIndex);
|
if(minorDebugPathfinder) printf("Legacy Pathfind Unit [%d - %s] FOUND PATH count = %d frameIndex = %d\n",unit->getId(),unit->getType()->getName().c_str(),whileLoopCount,frameIndex);
|
||||||
//on the way
|
//on the way
|
||||||
ts= tsMoving;
|
ts= tsMoving;
|
||||||
|
@ -951,34 +857,27 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
currNode= currNode->prev;
|
currNode= currNode->prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "49";
|
|
||||||
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());
|
||||||
|
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "50";
|
|
||||||
if(maxNodeCount == pathFindNodesAbsoluteMax) {
|
if(maxNodeCount == pathFindNodesAbsoluteMax) {
|
||||||
codeLocation = "51";
|
|
||||||
unit->setUsePathfinderExtendedMaxNodes(true);
|
unit->setUsePathfinderExtendedMaxNodes(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "52";
|
|
||||||
unit->setUsePathfinderExtendedMaxNodes(false);
|
unit->setUsePathfinderExtendedMaxNodes(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//store path
|
//store path
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
codeLocation = "53";
|
|
||||||
path->clear();
|
path->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "54";
|
|
||||||
UnitPathBasic *basicPathFinder = dynamic_cast<UnitPathBasic *>(path);
|
UnitPathBasic *basicPathFinder = dynamic_cast<UnitPathBasic *>(path);
|
||||||
|
|
||||||
currNode= firstNode;
|
currNode= firstNode;
|
||||||
|
|
||||||
for(int i=0; currNode->next != NULL; currNode= currNode->next, i++) {
|
for(int i=0; currNode->next != NULL; currNode= currNode->next, i++) {
|
||||||
codeLocation = "55";
|
|
||||||
Vec2i nodePos = currNode->next->pos;
|
Vec2i nodePos = currNode->next->pos;
|
||||||
if(map->isInside(nodePos) == false || map->isInsideSurface(map->toSurfCoords(nodePos)) == false) {
|
if(map->isInside(nodePos) == false || map->isInsideSurface(map->toSurfCoords(nodePos)) == false) {
|
||||||
throw megaglest_runtime_error("Pathfinder invalid node path position = " + nodePos.getString() + " i = " + intToStr(i));
|
throw megaglest_runtime_error("Pathfinder invalid node path position = " + nodePos.getString() + " i = " + intToStr(i));
|
||||||
|
@ -987,16 +886,13 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
if(minorDebugPathfinder) printf("nodePos [%s]\n",nodePos.getString().c_str());
|
if(minorDebugPathfinder) printf("nodePos [%s]\n",nodePos.getString().c_str());
|
||||||
|
|
||||||
if(frameIndex >= 0) {
|
if(frameIndex >= 0) {
|
||||||
codeLocation = "56";
|
|
||||||
|
|
||||||
faction.precachedPath[unit->getId()].push_back(nodePos);
|
faction.precachedPath[unit->getId()].push_back(nodePos);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeLocation = "57";
|
|
||||||
if(i < unit->getPathFindRefreshCellCount() ||
|
if(i < unit->getPathFindRefreshCellCount() ||
|
||||||
(whileLoopCount >= pathFindExtendRefreshForNodeCount &&
|
(whileLoopCount >= pathFindExtendRefreshForNodeCount &&
|
||||||
i < getPathFindExtendRefreshNodeCount(faction))) {
|
i < getPathFindExtendRefreshNodeCount(faction))) {
|
||||||
codeLocation = "58";
|
|
||||||
path->add(nodePos);
|
path->add(nodePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1034,7 +930,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "60";
|
|
||||||
|
|
||||||
faction.openNodesList.clear();
|
faction.openNodesList.clear();
|
||||||
faction.openPosList.clear();
|
faction.openPosList.clear();
|
||||||
|
@ -1043,7 +938,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\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 --------------------------- [END OF METHOD] ---------------------------\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
if(frameIndex >= 0) {
|
if(frameIndex >= 0) {
|
||||||
codeLocation = "61";
|
|
||||||
|
|
||||||
FactionState &faction = factions.getFactionState(factionIndex);
|
FactionState &faction = factions.getFactionState(factionIndex);
|
||||||
faction.precachedTravelState[unit->getId()] = ts;
|
faction.precachedTravelState[unit->getId()] = ts;
|
||||||
|
@ -1061,14 +955,14 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Loc [%s] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str(),ex.what());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
throw megaglest_runtime_error(ex.what());
|
throw megaglest_runtime_error(ex.what());
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error Loc [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str());
|
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
@ -1077,45 +971,37 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathFinder::processNearestFreePos(const Vec2i &finalPos, int i, int j, int size, Field field, int teamIndex,Vec2i unitPos, Vec2i &nearestPos, float &nearestDist) {
|
void PathFinder::processNearestFreePos(const Vec2i &finalPos, int i, int j, int size, Field field, int teamIndex,Vec2i unitPos, Vec2i &nearestPos, float &nearestDist) {
|
||||||
string codeLocation = "1";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Vec2i currPos= finalPos + Vec2i(i, j);
|
Vec2i currPos= finalPos + Vec2i(i, j);
|
||||||
|
|
||||||
codeLocation = "2";
|
|
||||||
if(map->isAproxFreeCells(currPos, size, field, teamIndex)) {
|
if(map->isAproxFreeCells(currPos, size, field, teamIndex)) {
|
||||||
codeLocation = "3";
|
|
||||||
float dist= currPos.dist(finalPos);
|
float dist= currPos.dist(finalPos);
|
||||||
|
|
||||||
codeLocation = "4";
|
|
||||||
//if nearer from finalPos
|
//if nearer from finalPos
|
||||||
if(dist < nearestDist){
|
if(dist < nearestDist){
|
||||||
codeLocation = "5";
|
|
||||||
nearestPos= currPos;
|
nearestPos= currPos;
|
||||||
nearestDist= dist;
|
nearestDist= dist;
|
||||||
}
|
}
|
||||||
//if the distance is the same compare distance to unit
|
//if the distance is the same compare distance to unit
|
||||||
else if(dist == nearestDist){
|
else if(dist == nearestDist){
|
||||||
codeLocation = "6";
|
|
||||||
if(currPos.dist(unitPos) < nearestPos.dist(unitPos)) {
|
if(currPos.dist(unitPos) < nearestPos.dist(unitPos)) {
|
||||||
codeLocation = "7";
|
|
||||||
nearestPos= currPos;
|
nearestPos= currPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codeLocation = "8";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Loc [%s] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str(),ex.what());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
throw megaglest_runtime_error(ex.what());
|
throw megaglest_runtime_error(ex.what());
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error Loc [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str());
|
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
@ -1123,7 +1009,6 @@ void PathFinder::processNearestFreePos(const Vec2i &finalPos, int i, int j, int
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2i PathFinder::computeNearestFreePos(const Unit *unit, const Vec2i &finalPos) {
|
Vec2i PathFinder::computeNearestFreePos(const Unit *unit, const Vec2i &finalPos) {
|
||||||
string codeLocation = "1";
|
|
||||||
|
|
||||||
Vec2i nearestPos(0,0);
|
Vec2i nearestPos(0,0);
|
||||||
try {
|
try {
|
||||||
|
@ -1132,47 +1017,39 @@ Vec2i PathFinder::computeNearestFreePos(const Unit *unit, const Vec2i &finalPos)
|
||||||
throw megaglest_runtime_error("map == NULL");
|
throw megaglest_runtime_error("map == NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "2";
|
|
||||||
//unit data
|
//unit data
|
||||||
int size= unit->getType()->getSize();
|
int size= unit->getType()->getSize();
|
||||||
Field field= unit->getCurrField();
|
Field field= unit->getCurrField();
|
||||||
int teamIndex= unit->getTeam();
|
int teamIndex= unit->getTeam();
|
||||||
|
|
||||||
codeLocation = "3";
|
|
||||||
//if finalPos is free return it
|
//if finalPos is free return it
|
||||||
if(map->isAproxFreeCells(finalPos, size, field, teamIndex)) {
|
if(map->isAproxFreeCells(finalPos, size, field, teamIndex)) {
|
||||||
codeLocation = "4";
|
|
||||||
return finalPos;
|
return finalPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "5";
|
|
||||||
//find nearest pos
|
//find nearest pos
|
||||||
Vec2i unitPos= unit->getPosNotThreadSafe();
|
Vec2i unitPos= unit->getPosNotThreadSafe();
|
||||||
nearestPos= unitPos;
|
nearestPos= unitPos;
|
||||||
|
|
||||||
codeLocation = "6";
|
|
||||||
float nearestDist= unitPos.dist(finalPos);
|
float nearestDist= unitPos.dist(finalPos);
|
||||||
|
|
||||||
codeLocation = "7";
|
|
||||||
for(int i= -maxFreeSearchRadius; i <= maxFreeSearchRadius; ++i) {
|
for(int i= -maxFreeSearchRadius; i <= maxFreeSearchRadius; ++i) {
|
||||||
for(int j= -maxFreeSearchRadius; j <= maxFreeSearchRadius; ++j) {
|
for(int j= -maxFreeSearchRadius; j <= maxFreeSearchRadius; ++j) {
|
||||||
codeLocation = "8";
|
|
||||||
processNearestFreePos(finalPos, i, j, size, field, teamIndex, unitPos, nearestPos, nearestDist);
|
processNearestFreePos(finalPos, i, j, size, field, teamIndex, unitPos, nearestPos, nearestDist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codeLocation = "9";
|
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Loc [%s] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str(),ex.what());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
throw megaglest_runtime_error(ex.what());
|
throw megaglest_runtime_error(ex.what());
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error Loc [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str());
|
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
@ -1211,20 +1088,16 @@ int PathFinder::findNodeIndex(Node *node, std::vector<Node> &nodeList) {
|
||||||
bool PathFinder::unitCannotMove(Unit *unit) {
|
bool PathFinder::unitCannotMove(Unit *unit) {
|
||||||
bool unitImmediatelyBlocked = false;
|
bool unitImmediatelyBlocked = false;
|
||||||
|
|
||||||
string codeLocation = "1";
|
|
||||||
try {
|
try {
|
||||||
// First check if unit currently blocked all around them, if so don't try to pathfind
|
// First check if unit currently blocked all around them, if so don't try to pathfind
|
||||||
const Vec2i unitPos = unit->getPos();
|
const Vec2i unitPos = unit->getPos();
|
||||||
int failureCount = 0;
|
int failureCount = 0;
|
||||||
int cellCount = 0;
|
int cellCount = 0;
|
||||||
|
|
||||||
codeLocation = "2";
|
|
||||||
for(int i = -1; i <= 1; ++i) {
|
for(int i = -1; i <= 1; ++i) {
|
||||||
for(int j = -1; j <= 1; ++j) {
|
for(int j = -1; j <= 1; ++j) {
|
||||||
codeLocation = "3";
|
|
||||||
Vec2i pos = unitPos + Vec2i(i, j);
|
Vec2i pos = unitPos + Vec2i(i, j);
|
||||||
if(pos != unitPos) {
|
if(pos != unitPos) {
|
||||||
codeLocation = "4";
|
|
||||||
bool canUnitMoveToCell = map->aproxCanMove(unit, unitPos, pos);
|
bool canUnitMoveToCell = map->aproxCanMove(unit, unitPos, pos);
|
||||||
if(canUnitMoveToCell == false) {
|
if(canUnitMoveToCell == false) {
|
||||||
failureCount++;
|
failureCount++;
|
||||||
|
@ -1233,21 +1106,20 @@ bool PathFinder::unitCannotMove(Unit *unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codeLocation = "5";
|
|
||||||
unitImmediatelyBlocked = (failureCount == cellCount);
|
unitImmediatelyBlocked = (failureCount == cellCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
//setRunningStatus(false);
|
//setRunningStatus(false);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Loc [%s] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str(),ex.what());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
throw megaglest_runtime_error(ex.what());
|
throw megaglest_runtime_error(ex.what());
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error Loc [%s]\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str());
|
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue