From f530535a58bbc3357983c590afa43e8b122dc54d Mon Sep 17 00:00:00 2001 From: Vladimir Olteanu Date: Sun, 5 Sep 2021 00:02:14 +0300 Subject: [PATCH] Simplify PlaceMiniSetRandom --- Source/drlg_l2.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 9b0f810df..a9c6d6ada 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -1744,18 +1744,17 @@ void PlaceMiniSetRandom(const Miniset &miniset, int rndper) for (int sy = 0; sy < DMAXY - sh; sy++) { for (int sx = 0; sx < DMAXX - sw; sx++) { + if (sx >= nSx1 && sx <= nSx2 && sy >= nSy1 && sy <= nSy2) + continue; + if (!miniset.matches({ sx, sy })) + continue; bool found = true; - if (sx >= nSx1 && sx <= nSx2 && sy >= nSy1 && sy <= nSy2) { - found = false; - } - if (found) - found = miniset.matches({ sx, sy }); - if (found) { - for (int yy = std::max(sy - sh, 0); yy < std::min(sy + 2 * sh, DMAXY) && found; yy++) { - for (int xx = std::max(sx - sw, 0); xx < std::min(sx + 2 * sw, DMAXX); xx++) { - // BUGFIX: yy and xx can go out of bounds (fixed) - if (dungeon[xx][yy] == miniset.replace[0][0]) - found = false; + for (int yy = std::max(sy - sh, 0); yy < std::min(sy + 2 * sh, DMAXY) && found; yy++) { + for (int xx = std::max(sx - sw, 0); xx < std::min(sx + 2 * sw, DMAXX); xx++) { + // BUGFIX: yy and xx can go out of bounds (fixed) + if (dungeon[xx][yy] == miniset.replace[0][0]) { + found = false; + break; } } }