[keel] Fix loading assets by path
This commit is contained in:
parent
cb21ff3f04
commit
202595b2a6
@ -64,12 +64,16 @@ ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::UUID const&uuid) noexce
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
constexpr auto makeLoader(Context &ctx) {
|
||||
return [&ctx](ox::StringViewCR assetId) -> ox::Result<T> {
|
||||
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<T> {
|
||||
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<T>(buff);
|
||||
if (err) {
|
||||
if (err != ox::Error_ClawTypeVersionMismatch && err != ox::Error_ClawTypeMismatch) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user