mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-14 08:23:52 +00:00
refactor: replace goto with structured control flow
- spell_handler.cpp: replace goto-done with do/while(false) for pet spell packet parsing — bail on truncated data while always firing events afterward - water_renderer.cpp: replace goto-found_neighbor with immediately invoked lambda to break out of nested neighbor search loops
This commit is contained in:
parent
76d29ad669
commit
76f493f7d9
2 changed files with 40 additions and 42 deletions
|
|
@ -1295,38 +1295,36 @@ void WaterRenderer::createWaterMesh(WaterSurface& surface) {
|
|||
renderTile = lsbOrder || msbOrder;
|
||||
}
|
||||
|
||||
// Render masked-out tiles if any adjacent neighbor is visible,
|
||||
// to avoid seam gaps at water surface edges.
|
||||
if (!renderTile) {
|
||||
for (int dy = -1; dy <= 1; dy++) {
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
if (dx == 0 && dy == 0) continue;
|
||||
int nx = x + dx, ny = y + dy;
|
||||
if (nx < 0 || ny < 0 || nx >= gridWidth-1 || ny >= gridHeight-1) continue;
|
||||
int neighborIdx;
|
||||
if (surface.wmoId == 0 && surface.width <= 8 && surface.mask.size() >= 8) {
|
||||
neighborIdx = (static_cast<int>(surface.yOffset) + ny) * 8 +
|
||||
(static_cast<int>(surface.xOffset) + nx);
|
||||
} else {
|
||||
neighborIdx = ny * surface.width + nx;
|
||||
}
|
||||
int nByteIdx = neighborIdx / 8;
|
||||
int nBitIdx = neighborIdx % 8;
|
||||
if (nByteIdx < static_cast<int>(surface.mask.size())) {
|
||||
uint8_t nMask = surface.mask[nByteIdx];
|
||||
if (isMergedTerrain) {
|
||||
if (nMask & (1 << nBitIdx)) {
|
||||
renderTile = true;
|
||||
goto found_neighbor;
|
||||
}
|
||||
renderTile = [&]() {
|
||||
for (int dy = -1; dy <= 1; dy++) {
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
if (dx == 0 && dy == 0) continue;
|
||||
int nx = x + dx, ny = y + dy;
|
||||
if (nx < 0 || ny < 0 || nx >= gridWidth-1 || ny >= gridHeight-1) continue;
|
||||
int neighborIdx;
|
||||
if (surface.wmoId == 0 && surface.width <= 8 && surface.mask.size() >= 8) {
|
||||
neighborIdx = (static_cast<int>(surface.yOffset) + ny) * 8 +
|
||||
(static_cast<int>(surface.xOffset) + nx);
|
||||
} else {
|
||||
if ((nMask & (1 << nBitIdx)) || (nMask & (1 << (7 - nBitIdx)))) {
|
||||
renderTile = true;
|
||||
goto found_neighbor;
|
||||
neighborIdx = ny * surface.width + nx;
|
||||
}
|
||||
int nByteIdx = neighborIdx / 8;
|
||||
int nBitIdx = neighborIdx % 8;
|
||||
if (nByteIdx < static_cast<int>(surface.mask.size())) {
|
||||
uint8_t nMask = surface.mask[nByteIdx];
|
||||
if (isMergedTerrain) {
|
||||
if (nMask & (1 << nBitIdx)) return true;
|
||||
} else {
|
||||
if ((nMask & (1 << nBitIdx)) || (nMask & (1 << (7 - nBitIdx)))) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
found_neighbor:;
|
||||
return false;
|
||||
}();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue