TheSuperHackers/GeneralsGameCode

Crash when too many units are moving

Igoorx opened this issue · 2 comments

At some point, when too many units are moving, the game tries to allocate a pathfinder cell info but crashes because the info pool is empty. I encountered this crash while spamming "Angry Mob". It happened in the file AIPathfind.cpp, in the following section:

if (found) {
    return;
}

newCell->allocateInfo(scanCell);
if (!newCell->getClosed() && !newCell->getOpen()) {
    m_closedList = newCell->putOnClosedList(m_closedList);
}

adjNewCell->allocateInfo(adjacentCell);
cellCount++;
Int curCost = adjNewCell->costToHierGoal(parentCell);
Int remCost = adjNewCell->costToHierGoal(goalCell);
if (adjNewCell->getPinched() || newCell->getPinched()) {

Link

A possible fix could be to return early if allocateInfo fails, which is already done in other places that use allocateInfo. For example:

if (!newCell->allocateInfo(scanCell)) {
    // Out of cells for pathing...
    return;
}
if (!newCell->getClosed() && !newCell->getOpen()) {
    m_closedList = newCell->putOnClosedList(m_closedList);
}

if (!adjNewCell->allocateInfo(adjacentCell)) {
    // Out of cells for pathing...
    return;
}

Alternatively, increasing the size of the cell info pool is also possible, but there needs to be a sane limit for that.

so to test this what? spam angry mob (20 units? ) and then make them move somewhere?