From c4f6ee0026452b1ad8dc7edda010ec7dd786de74 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 10 May 2024 19:50:48 -0500 Subject: [PATCH] [nostalgia,olympic] Make performPackTransforms update type id when needed --- .../modules/core/src/keel/keelmodule.cpp | 18 ++++++++++-------- src/olympic/keel/include/keel/context.hpp | 2 +- src/olympic/keel/include/keel/typeconv.hpp | 5 +++-- src/olympic/keel/src/media.cpp | 8 ++++++-- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/nostalgia/modules/core/src/keel/keelmodule.cpp b/src/nostalgia/modules/core/src/keel/keelmodule.cpp index 43221940..140dfa71 100644 --- a/src/nostalgia/modules/core/src/keel/keelmodule.cpp +++ b/src/nostalgia/modules/core/src/keel/keelmodule.cpp @@ -58,23 +58,25 @@ static class: public keel::Module { ox::Vector packTransforms() const noexcept final { return { // convert tilesheets to CompactTileSheets - [](keel::Context &ctx, ox::Buffer &buff, ox::StringView typeId) -> ox::Error { + [](keel::Context &ctx, ox::Buffer &buff, ox::StringView typeId) -> ox::Result { if (typeId == ox::ModelTypeId_v || typeId == ox::ModelTypeId_v || typeId == ox::ModelTypeId_v || typeId == ox::ModelTypeId_v) { - return keel::convertBuffToBuff( - ctx, buff, ox::ClawFormat::Metal).moveTo(buff); + oxReturnError(keel::convertBuffToBuff( + ctx, buff, ox::ClawFormat::Metal).moveTo(buff)); + return true; } - return {}; + return false; }, - [](keel::Context &ctx, ox::Buffer &buff, ox::StringView typeId) -> ox::Error { + [](keel::Context &ctx, ox::Buffer &buff, ox::StringView typeId) -> ox::Result { if (typeId == ox::ModelTypeId_v || typeId == ox::ModelTypeId_v) { - return keel::convertBuffToBuff( - ctx, buff, ox::ClawFormat::Metal).moveTo(buff); + oxReturnError(keel::convertBuffToBuff( + ctx, buff, ox::ClawFormat::Metal).moveTo(buff)); + return true; } - return {}; + return false; }, }; } diff --git a/src/olympic/keel/include/keel/context.hpp b/src/olympic/keel/include/keel/context.hpp index 30847cb6..a34d8a18 100644 --- a/src/olympic/keel/include/keel/context.hpp +++ b/src/olympic/keel/include/keel/context.hpp @@ -12,7 +12,7 @@ namespace keel { class Context; -using PackTransform = ox::Error(*)(Context&, ox::Buffer &clawData, ox::StringView); +using PackTransform = ox::Result(*)(Context&, ox::Buffer &clawData, ox::StringView); class Context { public: diff --git a/src/olympic/keel/include/keel/typeconv.hpp b/src/olympic/keel/include/keel/typeconv.hpp index 2ece88c1..b2c51a65 100644 --- a/src/olympic/keel/include/keel/typeconv.hpp +++ b/src/olympic/keel/include/keel/typeconv.hpp @@ -162,11 +162,12 @@ ox::Result convertBuffToBuff( } template -auto transformRule(keel::Context &ctx, ox::Buffer &buff, ox::StringView typeId) noexcept -> ox::Error { +ox::Result transformRule(keel::Context &ctx, ox::Buffer &buff, ox::StringView typeId) noexcept { if (typeId == ox::ModelTypeId_v) { oxReturnError(keel::convertBuffToBuff(ctx, buff, fmt).moveTo(buff)); + return true; } - return {}; + return false; }; diff --git a/src/olympic/keel/src/media.cpp b/src/olympic/keel/src/media.cpp index 682f34a4..29572f1f 100644 --- a/src/olympic/keel/src/media.cpp +++ b/src/olympic/keel/src/media.cpp @@ -102,9 +102,13 @@ ox::Result uuidToPath(Context &ctx, ox::UUID const&uuid) noexcept { } ox::Error performPackTransforms(Context &ctx, ox::Buffer &clawData) noexcept { - oxRequire(typeId, readAssetTypeId(clawData).to()); + oxRequireM(typeId, readAssetTypeId(clawData)); for (auto const tr : packTransforms(ctx)) { - oxReturnError(tr(ctx, clawData, typeId)); + bool changed{}; + oxReturnError(tr(ctx, clawData, typeId).moveTo(changed)); + if (changed) { + oxReturnError(readAssetTypeId(clawData).moveTo(typeId)); + } } return {}; }