Stabilize city rendering and water/collision behavior

This commit is contained in:
Kelsi 2026-02-03 21:11:10 -08:00
parent d0dac0df07
commit c825dbd752
5 changed files with 94 additions and 57 deletions

View file

@ -507,10 +507,10 @@ void ADTLoader::parseMH2O(const uint8_t* data, size_t size, ADTTerrain& terrain)
if (layer.x + layer.width > 8) layer.width = 8 - layer.x;
if (layer.y + layer.height > 8) layer.height = 8 - layer.y;
// Read exists bitmap (which tiles have water)
// The bitmap is (width * height) bits, packed into bytes
size_t numTiles = layer.width * layer.height;
size_t bitmapBytes = (numTiles + 7) / 8;
// Read exists bitmap (which tiles have water).
// In WotLK MH2O this is chunk-wide 8x8 tile flags (64 bits = 8 bytes),
// even when the layer covers a sub-rect.
constexpr size_t bitmapBytes = 8;
// Note: offsets in SMLiquidInstance are relative to MH2O chunk start
if (offsetExistsBitmap > 0) {
@ -520,7 +520,7 @@ void ADTLoader::parseMH2O(const uint8_t* data, size_t size, ADTTerrain& terrain)
std::memcpy(layer.mask.data(), data + bitmapOffset, bitmapBytes);
}
} else {
// No bitmap means all tiles have water
// No bitmap means all tiles in chunk are valid for this layer.
layer.mask.resize(bitmapBytes, 0xFF);
}