From 202595b2a62578b5d61851c0a915a01c80c96171 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 19 Feb 2025 21:47:00 -0600 Subject: [PATCH] [keel] Fix loading assets by path --- src/olympic/keel/include/keel/media.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/olympic/keel/include/keel/media.hpp b/src/olympic/keel/include/keel/media.hpp index 7faa272e..1b2040ed 100644 --- a/src/olympic/keel/include/keel/media.hpp +++ b/src/olympic/keel/include/keel/media.hpp @@ -64,12 +64,16 @@ ox::Result uuidToPath(Context &ctx, ox::UUID const&uuid) noexce namespace detail { template constexpr auto makeLoader(Context &ctx) { - return [&ctx](ox::StringViewCR assetId) -> ox::Result { - auto const p = ctx.uuidToPath.at(assetId); - if (p.error) { - return ox::Error{1, "Asset ID not found"}; + return [&ctx](ox::StringView assetId) -> ox::Result { + if (!beginsWith(assetId, "/")) { + auto const p = ctx.uuidToPath.at(assetId); + if (p.error) { + oxErrf("Could not find asset: {}", assetId); + return ox::Error{1, "Asset ID not found"}; + } + assetId = *p.value; } - OX_REQUIRE(buff, ctx.rom->read(*p.value)); + OX_REQUIRE(buff, ctx.rom->read(assetId)); auto [obj, err] = readAsset(buff); if (err) { if (err != ox::Error_ClawTypeVersionMismatch && err != ox::Error_ClawTypeMismatch) {