Skip to content

Crash when too many units are moving #330

Open
@Igoorx

Description

@Igoorx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is not working rightCriticalSeverity: Minor < Major < Critical < BlockerPerformanceIs a performance concern

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions