Fix grid layers with z_index=0 rendering on top of entities, closes #257

Layers with z_index <= 0 now render below entities (ground level), and
only layers with z_index > 0 render above entities. Previously z_index=0
was treated as "above entities" which was unintuitive -- entities stand
on ground level (z=0) with their feet, so z=0 layers should be beneath.

Changed in both UIGrid.cpp and UIGridView.cpp render methods:
- "z_index >= 0" to "z_index > 0" for break condition
- "z_index < 0" to "z_index <= 0" for skip condition

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-04-10 01:07:08 -04:00
commit 9ca79baec8
3 changed files with 9 additions and 9 deletions

View file

@ -182,10 +182,10 @@ void UIGrid::render(sf::Vector2f offset, sf::RenderTarget& target)
if (y_limit > grid_h) y_limit = grid_h;
// #150 - Layers are now the sole source of grid rendering (base layer removed)
// Render layers with z_index < 0 (below entities)
// Render layers with z_index <= 0 (below entities)
sortLayers();
for (auto& layer : layers) {
if (layer->z_index >= 0) break; // Stop at layers that go above entities
if (layer->z_index > 0) break; // Stop at layers that go above entities (#257)
layer->render(*activeTexture, left_spritepixels, top_spritepixels,
left_edge, top_edge, x_limit, y_limit, zoom, cell_width, cell_height);
}
@ -222,9 +222,9 @@ void UIGrid::render(sf::Vector2f offset, sf::RenderTarget& target)
Resources::game->metrics.totalEntities += totalEntities;
}
// #147 - Render dynamic layers with z_index >= 0 (above entities)
// #147 - Render dynamic layers with z_index > 0 (above entities)
for (auto& layer : layers) {
if (layer->z_index < 0) continue; // Skip layers below entities
if (layer->z_index <= 0) continue; // Skip layers at or below entities (#257)
layer->render(*activeTexture, left_spritepixels, top_spritepixels,
left_edge, top_edge, x_limit, y_limit, zoom, cell_width, cell_height);
}