From 62bff261a102b5f5014f5c8a85e364faa1893e9f Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Wed, 19 Apr 2017 16:32:35 -0400 Subject: [PATCH] Small cleanup in map generator - The shuffle previously only shuffled the first four elements - The intermediary index array isn't needed since map_locations are assignable - Use range-for --- src/generators/default_map_generator_job.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/generators/default_map_generator_job.cpp b/src/generators/default_map_generator_job.cpp index defd0bd08b4b..04ea47e2cf48 100644 --- a/src/generators/default_map_generator_job.cpp +++ b/src/generators/default_map_generator_job.cpp @@ -458,14 +458,12 @@ bool default_map_generator_job::generate_river_internal(const height_map& height map_location current_loc(x,y); map_location adj[6]; get_adjacent_tiles(current_loc,adj); - int items[6] = {0,1,2,3,4,5}; - std::shuffle(items, items + 4, rng_); + std::shuffle(std::begin(adj), std::end(adj), rng_); // Mark that we have attempted from this map_location seen_locations.insert(current_loc); river.push_back(current_loc); - for(int a = 0; a != 6; ++a) { - const map_location& loc = adj[items[a]]; + for(const map_location& loc : adj) { if(seen_locations.count(loc) == 0) { const bool res = generate_river_internal(heights,terrain,loc.x,loc.y,river,seen_locations,river_uphill); if(res) {