From 8798d2d718928aa7f36c1d8b3b03b34036ce6961 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 3 Jun 2024 23:17:50 -0500 Subject: [PATCH] [nostalgia/core] Fix getTileIdx(TileSheet, SubSheetId) --- src/nostalgia/modules/core/src/tilesheet.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/nostalgia/modules/core/src/tilesheet.cpp b/src/nostalgia/modules/core/src/tilesheet.cpp index 18b62d04..fb336f79 100644 --- a/src/nostalgia/modules/core/src/tilesheet.cpp +++ b/src/nostalgia/modules/core/src/tilesheet.cpp @@ -52,7 +52,7 @@ TileSheet::SubSheet const *getSubsheet(TileSheet const&ts, SubSheetId const id) static ox::Optional getPixelIdx( TileSheet::SubSheet const&ss, SubSheetId const id, - size_t idx, + size_t &idx, int8_t const bpp) noexcept { for (auto const&child: ss.subsheets) { if (child.id == id) { @@ -63,11 +63,12 @@ static ox::Optional getPixelIdx( } idx += pixelCnt(child, bpp); } - return {}; + return ox::Optional{}; } size_t getTileIdx(TileSheet const&ts, SubSheetId const id) noexcept { - auto const out = getPixelIdx(ts.subsheet, id, 0, ts.bpp); + size_t idx{}; + auto const out = getPixelIdx(ts.subsheet, id, idx, ts.bpp); return out.or_value(0) / PixelsPerTile; }