Since pathAdd is a function that will clearly need adjustments, I think I'd set a debugger breakpoint there to see what exactly is going wrong. Here's the bulk of that function (NB - the K-Mod version on Erik's pathfinder branch looks quite a bit different):I am not really getting a hold of the "pathfinding".
Could you give me some hints how to adapt it?
Never really worked on pathfinding in the past. [...]
Spoiler :
Code:
if (data == ASNC_INITIALADD)
{
iMoves = MAX_INT;
iTurns = 1;
pUnitNode = pSelectionGroup->headUnitNode();
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = pSelectionGroup->nextUnitNode(pUnitNode);
iMoves = std::min(iMoves, pLoopUnit->movesLeft());
}
}
else
{
pFromPlot = GC.getMapINLINE().plotSorenINLINE(parent->m_iX, parent->m_iY);
pToPlot = GC.getMapINLINE().plotSorenINLINE(node->m_iX, node->m_iY);
iStartMoves = parent->m_iData1;
iTurns = parent->m_iData2;
if (iStartMoves == 0)
iTurns++;
iMoves = MAX_INT;
pUnitNode = pSelectionGroup->headUnitNode();
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = pSelectionGroup->nextUnitNode(pUnitNode);
iMoves = std::min(iMoves, std::max(0,
((iStartMoves > 0) ? iStartMoves :
pLoopUnit->maxMoves()) - pToPlot->movementCost(pLoopUnit, pFromPlot)));
}
}
FAssertMsg(iMoves >= 0, "iMoves is expected to be non-negative (invalid Index)");
The iStartMoves == 0 conditional (i.e. when movement points are already exhausted before adding the current step to the path) may have to handle iStartMoves < 0 as well. And the min/ max stuff and assertion at the end probably need to be changed too. Further changes may be needed in other pathfinding functions, but addressing these issues would be a start.