From 3f83a254d2c00a20f3899cf557398b04516608f3 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 3 Dec 2023 22:02:00 -0600 Subject: [PATCH] [keel] Fix UUID to path lookups to fail properly --- src/keel/media.cpp | 15 +++++++-------- src/keel/media.hpp | 6 ++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/keel/media.cpp b/src/keel/media.cpp index 8d202cc3..46a36d93 100644 --- a/src/keel/media.cpp +++ b/src/keel/media.cpp @@ -37,10 +37,6 @@ void unloadRom(char *rom) noexcept { ox::safeDelete(rom); } -ox::Result findPreloadSection() noexcept { - return OxError(1, "findPreloadSection is unsupported on this platform"); -} - static void clearUuidMap(Context &ctx) noexcept { ctx.uuidToPath.clear(); ctx.pathToUuid.clear(); @@ -48,7 +44,7 @@ static void clearUuidMap(Context &ctx) noexcept { void createUuidMapping(Context &ctx, ox::StringView filePath, ox::UUID const&uuid) noexcept { ctx.pathToUuid[filePath] = uuid; - ctx.uuidToPath[uuid.toString()] = std::move(filePath); + ctx.uuidToPath[uuid.toString()] = filePath; } static ox::Error buildUuidMap(Context &ctx, ox::CRStringView path) noexcept { @@ -80,7 +76,8 @@ ox::Error buildUuidMap(Context &ctx) noexcept { ox::Result pathToUuid(Context &ctx, ox::CRStringView path) noexcept { #ifndef OX_BARE_METAL - return ctx.pathToUuid[path]; + oxRequire(out, ctx.pathToUuid.at(path)); + return *out; #else return OxError(1, "UUID to path conversion not supported on this platform"); #endif @@ -88,7 +85,8 @@ ox::Result pathToUuid(Context &ctx, ox::CRStringView path) noexcept { ox::Result uuidToPath(Context &ctx, ox::CRStringView uuid) noexcept { #ifndef OX_BARE_METAL - return ctx.uuidToPath[uuid]; + oxRequire(out, ctx.uuidToPath.at(uuid)); + return *out; #else return OxError(1, "UUID to path conversion not supported on this platform"); #endif @@ -96,7 +94,8 @@ ox::Result uuidToPath(Context &ctx, ox::CRStringView uuid) noexcept ox::Result uuidToPath(Context &ctx, ox::UUID const&uuid) noexcept { #ifndef OX_BARE_METAL - return ctx.uuidToPath[uuid.toString()]; + oxRequire(out, ctx.uuidToPath.at(uuid.toString())); + return *out; #else return OxError(1, "UUID to path conversion not supported on this platform"); #endif diff --git a/src/keel/media.hpp b/src/keel/media.hpp index bd6ae6f4..db203c8a 100644 --- a/src/keel/media.hpp +++ b/src/keel/media.hpp @@ -50,14 +50,12 @@ ox::Result> readObjFile( return std::move(obj); }; ox::StringView path; - ox::UUIDStr uuidStr; if (beginsWith(assetId, "uuid://")) { assetId = substr(assetId, 7); - path = ctx.uuidToPath[assetId]; + oxRequire(p, ctx.uuidToPath.at(assetId)); + path = *p; } else { path = assetId; - uuidStr = ctx.pathToUuid[path].toString(); - assetId = uuidStr; } if (forceLoad) { oxRequire(buff, ctx.rom->read(path));