avatar
forged_in_fire
REGULAR
1Issues
0Score
  • Relevant Vanilla Implementation

    The implementation appears to assume that sorting the array produces an ascending rank hierarchy.

    That assumption requires verification.

    Supporting Experiment

    Using the Workbench Script Editor's Run Console, I created an array of five SCR_EntityBudgetValue objects with different budget values.

    The objects were inserted in a fixed order:

    I executed array.Sort() and printed the resulting order.

    Three executions produced the following results:

    Execution 1:

    Execution 2:

    Execution 3:

    The results demonstrate that sorting these objects does not produce an ordering based on their budget values or enum identifiers.

    The results also differ between executions despite identical insertion order.

    Although this experiment uses SCR_EntityBudgetValue rather than SCR_RankInfo, it demonstrates why an object array should not be assumed to sort according to an application's intended numerical hierarchy.

    Potential Impact

    If SCR_RankInfo objects exhibit the same sorting behavior, selecting the last element may return an arbitrary configured rank rather than the highest rank.

    This could affect construction budget calculations that depend on m_eHighestRank.

    The potential issue exists independently of modifications to the game's rank hierarchy.