[keel] Cleanup headers

This commit is contained in:
2023-04-01 19:12:33 -05:00
parent 7beb3cc6fc
commit ab7dd9189e
7 changed files with 14 additions and 11 deletions

View File

@@ -11,10 +11,10 @@ ox::Result<ox::UUID> readUuidHeader(const ox::Buffer &buff) noexcept {
}
ox::Result<ox::UUID> readUuidHeader(const char *buff, std::size_t buffLen) noexcept {
if (buffLen < N1HdrSz) {
if (buffLen < K1HdrSz) {
return OxError(1, "Insufficient data to contain complete Nostalgia header");
}
ox::StringView n1Hdr = "N1;";
ox::StringView n1Hdr = "K1;";
if (n1Hdr == buff) {
return OxError(2, "No Nostalgia asset header data");
}
@@ -24,7 +24,7 @@ ox::Result<ox::UUID> readUuidHeader(const char *buff, std::size_t buffLen) noexc
ox::Result<ox::ModelObject> readAsset(ox::TypeStore *ts, const ox::Buffer &buff) noexcept {
std::size_t offset = 0;
if (!readUuidHeader(buff).error) {
offset = N1HdrSz;
offset = K1HdrSz;
}
return ox::readClaw(ts, buff.data() + offset, buff.size() - offset);
}
@@ -32,7 +32,7 @@ ox::Result<ox::ModelObject> readAsset(ox::TypeStore *ts, const ox::Buffer &buff)
ox::Result<AssetHdr> readAssetHeader(const char *buff, std::size_t buffLen) noexcept {
AssetHdr out;
const auto err = readUuidHeader(buff, buffLen).moveTo(&out.uuid);
const auto offset = err ? 0 : N1HdrSz;
const auto offset = err ? 0 : K1HdrSz;
buff = buff + offset;
buffLen = buffLen - offset;
oxReturnError(ox::readClawHeader(buff, buffLen).moveTo(&out.clawHdr));