diff --git a/bigstuff.cpp b/bigstuff.cpp index 7478366e..17608c7d 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -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; iwall = waMineMine; } diff --git a/complex.cpp b/complex.cpp index 7db92443..34b0a7b3 100644 --- a/complex.cpp +++ b/complex.cpp @@ -1847,7 +1847,7 @@ EX namespace hive { } } - hrandom_shuffle(&bugtomove[0], isize(bugtomove)); + hrandom_shuffle(bugtomove); sort(bugtomove.begin(), bugtomove.end()); int battlecount = 0; @@ -3611,7 +3611,7 @@ EX namespace windmap { vector inqueue(N, true); vector tocheck; for(int i=0; i= 200*N) { printf("does not converge\n"); break; } diff --git a/complex2.cpp b/complex2.cpp index c865e3e0..9ca6c34d 100644 --- a/complex2.cpp +++ b/complex2.cpp @@ -852,7 +852,7 @@ EX void ambush(cell *c, int dogs) { int v = valence(); if(v > 4) { for(cell *c: cl.lst) if(cl.getdist(c) == d) around.push_back(c); - hrandom_shuffle(&around[0], isize(around)); + hrandom_shuffle(around); } else { for(int tries=0; tries<10000; tries++) { diff --git a/game.cpp b/game.cpp index 193fbc68..c99b74d2 100644 --- a/game.cpp +++ b/game.cpp @@ -44,7 +44,7 @@ EX int hrand(int i) { #if HDR template T pick(T x, U... u) { std::initializer_list i = {x,u...}; return *(i.begin() + hrand(1+sizeof...(u))); } template void hrandom_shuffle(T* x, int n) { for(int k=1; k void hrandom_shuffle(T& container) { hrandom_shuffle(&container[0], isize(container)); } +template void hrandom_shuffle(T& container) { hrandom_shuffle(container.data(), isize(container)); } template auto hrand_elt(U& container) -> decltype(container[0]) { return container[hrand(isize(container))]; } template T hrand_elt(U& container, T default_value) { if(container.empty()) return default_value; diff --git a/racing.cpp b/racing.cpp index cab55d8b..43dcb029 100644 --- a/racing.cpp +++ b/racing.cpp @@ -331,7 +331,7 @@ void find_track(cell *start, int sign, int len) { } EX void block_cells(vector to_block, function blockbound) { - hrandom_shuffle(&to_block[0], isize(to_block)); + hrandom_shuffle(to_block); for(cell *c: to_block) switch(specialland) { case laIce: diff --git a/rogueviz/kohonen.cpp b/rogueviz/kohonen.cpp index ad1a7943..77beba65 100644 --- a/rogueviz/kohonen.cpp +++ b/rogueviz/kohonen.cpp @@ -1253,7 +1253,7 @@ void fillgroups() { do_classify(); vector samples_to_sort; for(int i=0; i