[keel] Fix loading assets by path
This commit is contained in:
		@@ -64,12 +64,16 @@ ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::UUID const&uuid) noexce
 | 
				
			|||||||
namespace detail {
 | 
					namespace detail {
 | 
				
			||||||
template<typename T>
 | 
					template<typename T>
 | 
				
			||||||
constexpr auto makeLoader(Context &ctx) {
 | 
					constexpr auto makeLoader(Context &ctx) {
 | 
				
			||||||
	return [&ctx](ox::StringViewCR assetId) -> ox::Result<T> {
 | 
						return [&ctx](ox::StringView assetId) -> ox::Result<T> {
 | 
				
			||||||
 | 
							if (!beginsWith(assetId, "/")) {
 | 
				
			||||||
			auto const p = ctx.uuidToPath.at(assetId);
 | 
								auto const p = ctx.uuidToPath.at(assetId);
 | 
				
			||||||
			if (p.error) {
 | 
								if (p.error) {
 | 
				
			||||||
 | 
									oxErrf("Could not find asset: {}", assetId);
 | 
				
			||||||
				return ox::Error{1, "Asset ID not found"};
 | 
									return ox::Error{1, "Asset ID not found"};
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		OX_REQUIRE(buff, ctx.rom->read(*p.value));
 | 
								assetId = *p.value;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							OX_REQUIRE(buff, ctx.rom->read(assetId));
 | 
				
			||||||
		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) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user