From b975dc2938a97a5c69b6a0d70d9c72f255584f9e Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 10 Aug 2019 22:46:41 -0400 Subject: [PATCH] Make water equalization fill in areas slightly more naturally --- src/simulation/Simulation.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index f007eaef5..f7c952a71 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -900,9 +900,16 @@ bool Simulation::flood_water(int x, int y, int i) } for (int x = x1; x <= x2; x++) { - // Check above, maybe around other sides too? - if (((y - 1) > originalY) && !pmap[y - 1][x] && eval_move(parts[i].type, x, y - 1, nullptr)) + if ((y - 1) > originalY && !pmap[y - 1][x]) { + // Try to move the water to a random position on this line, because there's probably a free location somewhere + int randPos = RNG::Ref().between(x, x2); + if (!pmap[y - 1][randPos] && eval_move(parts[i].type, randPos, y - 1, nullptr)) + x = randPos; + // Couldn't move to random position, so try the original position on the left + else if (!eval_move(parts[i].type, x, y - 1, nullptr)) + continue; + int oldx = (int)(parts[i].x + 0.5f); int oldy = (int)(parts[i].y + 0.5f); pmap[y - 1][x] = pmap[oldy][oldx];