Skip to content

Commit ee87fc6

Browse files
committed
add safety
1 parent ace92b4 commit ee87fc6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎src/Battlescape/BattlescapeGenerator.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,9 +1073,13 @@ BattleUnit *BattlescapeGenerator::addAlien(Unit *rules, int alienRank, bool outs
10731073
BattleUnit *unit = new BattleUnit(rules, FACTION_HOSTILE, _unitSequence++, _game->getRuleset()->getArmor(rules->getArmor()), difficulty, _save->getDepth());
10741074
Node *node = 0;
10751075

1076+
// safety to avoid index out of bounds errors
1077+
if (alienRank > 7)
1078+
alienRank = 7;
10761079
/* following data is the order in which certain alien ranks spawn on certain node ranks */
10771080
/* note that they all can fall back to rank 0 nodes - which is scout (outside ufo) */
10781081

1082+
10791083
for (int i = 0; i < 7 && node == 0; ++i)
10801084
{
10811085
if (outside)

0 commit comments

Comments
 (0)