1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2026-01-10 21:29:03 +00:00

Fix UB when sorting empty vecs

This commit is contained in:
Jesse Ruderman
2021-07-11 20:54:25 -07:00
parent 08cbe8e4e0
commit 123994bdc2
6 changed files with 7 additions and 7 deletions

View File

@@ -2001,8 +2001,8 @@ EX void generate_mines() {
for(cell *c: currentmap->allcells())
if(c->wall == waMineUnknown)
candidates.push_back(c);
hrandom_shuffle(candidates);
bounded_mine_max = isize(candidates);
hrandom_shuffle(&candidates[0], bounded_mine_max);
bounded_mine_quantity = int(bounded_mine_max * bounded_mine_percentage + 0.5);
for(int i=0; i<bounded_mine_quantity; i++) candidates[i]->wall = waMineMine;
}