[keel] Cleanup headers

This commit is contained in:
Gary Talent 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));

View File

@ -11,14 +11,14 @@
namespace keel {
constexpr auto N1HdrSz = 40;
constexpr auto K1HdrSz = 40;
ox::Result<ox::UUID> readUuidHeader(const ox::Buffer &buff) noexcept;
ox::Result<ox::UUID> readUuidHeader(const char *buff, std::size_t buffLen) noexcept;
ox::Error writeUuidHeader(ox::Writer_c auto *writer, const ox::UUID &uuid) noexcept {
const auto hdr = ox::sfmt<ox::BString<N1HdrSz>>("N1;{};", uuid.toString());
const auto hdr = ox::sfmt<ox::BString<K1HdrSz>>("K1;{};", uuid.toString());
return write(writer, hdr);
}
@ -27,7 +27,7 @@ ox::Result<T> readAsset(const ox::Buffer &buff) noexcept {
std::size_t offset = 0;
const auto err = readUuidHeader(buff).error;
if (!err) {
offset = N1HdrSz; // the size of N1 headers
offset = K1HdrSz; // the size of K1 headers
}
return ox::readClaw<T>(buff.data() + offset, buff.size() - offset);
}

View File

@ -8,10 +8,8 @@
#include <ox/preloader/preloader.hpp>
namespace keel {
class Context;
}
namespace keel {
class Context;
struct GbaPlatSpec {
using PtrType = uint32_t;

View File

@ -10,8 +10,8 @@
#include <ox/claw/read.hpp>
#include <ox/claw/write.hpp>
#include "asset.hpp"
#include "context.hpp"
#include "media.hpp"
namespace keel {

View File

@ -2,6 +2,8 @@
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <keel/media.hpp>
#include <nostalgia/core/core.hpp>
#include <nostalgia/scene/scene.hpp>

View File

@ -4,6 +4,8 @@
#include <ox/logconn/logconn.hpp>
#include <keel/media.hpp>
#include <nostalgia/core/core.hpp>
#include <nostalgia/appmodules/appmodules.hpp>

View File

@ -9,6 +9,7 @@
#include <ox/logconn/logconn.hpp>
#include <keel/keel.hpp>
#include <nostalgia/appmodules/appmodules.hpp>
#include <nostalgia/core/typestore.hpp>