Browse Source

Simplify PlaceMiniSetRandom

pull/2820/head
Vladimir Olteanu 5 years ago committed by Anders Jenbo
parent
commit
f530535a58
  1. 21
      Source/drlg_l2.cpp

21
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 sy = 0; sy < DMAXY - sh; sy++) {
for (int sx = 0; sx < DMAXX - sw; sx++) { 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; bool found = true;
if (sx >= nSx1 && sx <= nSx2 && sy >= nSy1 && sy <= nSy2) { for (int yy = std::max(sy - sh, 0); yy < std::min(sy + 2 * sh, DMAXY) && found; yy++) {
found = false; 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 (found) if (dungeon[xx][yy] == miniset.replace[0][0]) {
found = miniset.matches({ sx, sy }); found = false;
if (found) { break;
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;
} }
} }
} }

Loading…
Cancel
Save