[keel] Cleanup
All checks were successful
Build / build (push) Successful in 2m42s

This commit is contained in:
Gary Talent 2024-11-15 19:57:07 -06:00
parent 72f4db3d5e
commit df44fe235b

View File

@ -63,10 +63,8 @@ namespace detail {
template<typename T> template<typename T>
constexpr auto makeLoader(Context &ctx) { constexpr auto makeLoader(Context &ctx) {
return [&ctx](ox::StringView assetId) -> ox::Result<T> { return [&ctx](ox::StringView assetId) -> ox::Result<T> {
ox::StringView path;
oxRequire(p, ctx.uuidToPath.at(assetId)); oxRequire(p, ctx.uuidToPath.at(assetId));
path = *p; oxRequire(buff, ctx.rom->read(*p));
oxRequire(buff, ctx.rom->read(path));
auto [obj, err] = readAsset<T>(buff); auto [obj, err] = readAsset<T>(buff);
if (err) { if (err) {
if (err != ox::Error_ClawTypeVersionMismatch && err != ox::Error_ClawTypeMismatch) { if (err != ox::Error_ClawTypeVersionMismatch && err != ox::Error_ClawTypeMismatch) {
@ -84,21 +82,17 @@ ox::Result<keel::AssetRef<T>> readObjFile(
keel::Context &ctx, keel::Context &ctx,
ox::StringView assetId, ox::StringView assetId,
bool forceLoad) noexcept { bool forceLoad) noexcept {
ox::UUIDStr uuidStr;
if (beginsWith(assetId, "uuid://")) { if (beginsWith(assetId, "uuid://")) {
assetId = substr(assetId, 7); assetId = substr(assetId, 7);
oxRequire(p, keel::uuidToPath(ctx, assetId));
} else { } else {
auto const [uuid, uuidErr] = getUuid(ctx, assetId); auto const [uuid, uuidErr] = getUuid(ctx, assetId);
if (!uuidErr) { if (!uuidErr) {
uuidStr = uuid.toString(); assetId = uuid.toString();
assetId = uuidStr;
} }
} }
if (forceLoad) { if (forceLoad) {
ctx.assetManager.initTypeManager<T>(detail::makeLoader<T>, ctx); ctx.assetManager.initTypeManager<T>(detail::makeLoader<T>, ctx);
oxRequire(cached, ctx.assetManager.loadAsset<T>(assetId)); return ctx.assetManager.loadAsset<T>(assetId);
return cached;
} else { } else {
auto [cached, err] = ctx.assetManager.getAsset<T>(assetId); auto [cached, err] = ctx.assetManager.getAsset<T>(assetId);
if (err) { if (err) {