|
|
|
@ -102,51 +102,76 @@ std::optional<Size> GetSizeForThemeRoom(int floor, Point origin, int minSize, in |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int maxWidth = std::min(DMAXX - origin.x, maxSize); |
|
|
|
bool yFlag = true; |
|
|
|
int maxHeight = std::min(DMAXY - origin.y, maxSize); |
|
|
|
bool xFlag = true; |
|
|
|
|
|
|
|
int xCount = 0; |
|
|
|
// Start out looking for the widest area at least as tall as minSize
|
|
|
|
int yCount = 0; |
|
|
|
for (int yOffset = 0; yOffset < minSize; yOffset++) { |
|
|
|
|
|
|
|
for (int xOffset = 0; xOffset < maxWidth; xOffset++) { |
|
|
|
int xArray[20] = {}; |
|
|
|
if (dungeon[origin.x + xOffset][origin.y + yOffset] == floor) |
|
|
|
int yArray[20] = {}; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
for (int ii = 0; ii < maxSize; ii++) { |
|
|
|
// found a non-floor tile earlier than the previous max width
|
|
|
|
if (xFlag && origin.y + ii < DMAXY) { |
|
|
|
|
|
|
|
for (int xx = origin.x; xx < origin.x + maxSize && xx < DMAXX; xx++) { |
|
|
|
if (xOffset < minSize) { |
|
|
|
if (dungeon[xx][origin.y + ii] != floor) { |
|
|
|
// area is too small to hold a room of the desired size
|
|
|
|
if (xx >= /* origin.x + */ minSize) { |
|
|
|
return {}; |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
xFlag = false; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
xCount++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (xFlag) { |
|
|
|
|
|
|
|
xArray[ii] = xCount; |
|
|
|
|
|
|
|
xCount = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (yFlag && origin.x + ii < DMAXX) { |
|
|
|
|
|
|
|
for (int yy = origin.y; yy < origin.y + maxSize && yy < DMAXY; yy++) { |
|
|
|
|
|
|
|
if (dungeon[origin.x + ii][yy] != floor) { |
|
|
|
|
|
|
|
if (yy >= /* origin.y + */ minSize) { |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
yFlag = false; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
yCount++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (yFlag) { |
|
|
|
|
|
|
|
yArray[ii] = yCount; |
|
|
|
|
|
|
|
yCount = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// update the max width since we can't make a room larger than this
|
|
|
|
|
|
|
|
maxWidth = xOffset; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Work out the tallest area we could potentially fill
|
|
|
|
for (int ii = 0; ii < minSize; ii++) { |
|
|
|
for (int xOffset = 0; xOffset < minSize; xOffset++) { |
|
|
|
if (xArray[ii] < minSize || yArray[ii] < minSize) { |
|
|
|
for (int yOffset = minSize; yOffset < maxHeight; yOffset++) { |
|
|
|
return {}; |
|
|
|
if (dungeon[origin.x + xOffset][origin.y + yOffset] == floor) |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
maxHeight = yOffset; |
|
|
|
for (int ii = 0; ii < minSize; ii++) { |
|
|
|
|
|
|
|
if (xArray[ii] < minSize || yArray[ii] < minSize) { |
|
|
|
|
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Then replicate the original dungeon generation constraints and find the "squarest" region
|
|
|
|
int xSmallest = xArray[0]; |
|
|
|
for (int yOffset = minSize; yOffset < maxHeight; yOffset++) { |
|
|
|
int ySmallest = yArray[0]; |
|
|
|
for (int xOffset = minSize; xOffset < maxWidth; xOffset++) { |
|
|
|
|
|
|
|
if (dungeon[origin.x + xOffset][origin.y + yOffset] == floor) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (xOffset > yOffset) |
|
|
|
for (int ii = 0; ii < maxSize; ii++) { |
|
|
|
maxWidth = xOffset; |
|
|
|
if (xArray[ii] < minSize || yArray[ii] < minSize) { |
|
|
|
if (yOffset > xOffset) |
|
|
|
break; |
|
|
|
maxHeight = yOffset; |
|
|
|
} |
|
|
|
|
|
|
|
if (xArray[ii] < xSmallest) { |
|
|
|
|
|
|
|
xSmallest = xArray[ii]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (yArray[ii] < ySmallest) { |
|
|
|
|
|
|
|
ySmallest = yArray[ii]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return Size { xSmallest, ySmallest } - 2; |
|
|
|
return Size { maxWidth, maxHeight } - 2; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CreateThemeRoom(int themeIndex) |
|
|
|
void CreateThemeRoom(int themeIndex) |
|
|
|
|