Squashed 'deps/nostalgia/' changes from 804d78e1..2a8e3c2d
2a8e3c2d [nostalgia/gfx] Remove unnecessary cast 998066d3 [ox/std] Add comparison functions fefb876f [nostalgia/gfx] Add checks for GCC version for warning suppression 5979e988 [jsoncpp] Up required CMake version a17abe46 [nfde] Up required CMake version d62f9138 [nostalgia/gfx] Suppress some superfluous warnings 12bb7475 [nostalgia/gfx/studio/tilesheet] Adjust pixel line size on Windows df2c7e2b [nostalgia] Update release notes 713aec88 [buildcore] Change mypy invokation 3089cd7a Change builder type to olympic 00638bc8 [nostalgia/gfx/studio/tilesheet] Mark DrawCommands as obsolete if no changes e0021098 [studio] Make undo/redo skip over obsolete commands b4798fd2 [nostalgia/gfx/studio/tilesheet] Make rotate only available for square subsheets or selections 3c804bf6 [studio] Give MakeCopy popup an error message for files that already exist d39d552b [nostalgia/studio] Update icon to higher resolution b7202a2b [nostalgia/player] Disable Keel mods on GBA 4e27a4c1 [nostalgia/core/studio/tilesheet] Fix palette path display update 4ef31762 [nostalgia/core/studio/tilesheet] Cleanup 8b22a8f3 [keel] Make buildUuidMap only read the first 40 bytes of each file d45ff05b [ox/fs] Add new partial file read functions 671dd862 [keel,studio] Add Make Copy option to ProjectExplorer 0abadc18 [studio] Fix QuestionPopup to only emit a response when there is a response 4e068d62 [studio] Fix misrender flash on tab close 4461f99f [studio] Add Ctrl-W shortcut for closing active tab cd1f4bda [studio] Add confirmation for closing file with unsaved changes 47286995 [studio] Add combobox that will take string views 105a1e55 [nostalgia/core/studio/tilesheet] Rework operation ctrls into a dropbox 1bc18e34 [nostalgia/core/studio/tilesheet] Add ability to rotate a selection fb8d295f [nostalgia/core/studio/tilesheet] Add rotate functionality git-subtree-dir: deps/nostalgia git-subtree-split: 2a8e3c2dc44642fd9fef6bc8b645ad966f0277da
This commit is contained in:
@@ -15,6 +15,8 @@ constexpr auto K1HdrSz = 40;
|
||||
|
||||
ox::Result<ox::UUID> readUuidHeader(ox::BufferView buff) noexcept;
|
||||
|
||||
ox::Result<ox::UUID> regenerateUuidHeader(ox::Buffer &buff) noexcept;
|
||||
|
||||
ox::Error writeUuidHeader(ox::Writer_c auto &writer, ox::UUID const&uuid) noexcept {
|
||||
OX_RETURN_ERROR(write(writer, "K1;"));
|
||||
OX_RETURN_ERROR(uuid.toString(writer));
|
||||
|
@@ -8,15 +8,25 @@ namespace keel {
|
||||
|
||||
ox::Result<ox::UUID> readUuidHeader(ox::BufferView buff) noexcept {
|
||||
if (buff.size() < K1HdrSz) [[unlikely]] {
|
||||
return ox::Error(1, "Insufficient data to contain complete Keel header");
|
||||
return ox::Error{1, "Insufficient data to contain complete Keel header"};
|
||||
}
|
||||
constexpr ox::StringView k1Hdr = "K1;";
|
||||
if (k1Hdr != ox::StringView(buff.data(), k1Hdr.bytes())) [[unlikely]] {
|
||||
return ox::Error(2, "No Keel asset header data");
|
||||
if (k1Hdr != ox::StringView{buff.data(), k1Hdr.bytes()}) [[unlikely]] {
|
||||
return ox::Error{2, "No Keel asset header data"};
|
||||
}
|
||||
return ox::UUID::fromString(ox::StringView(&buff[k1Hdr.bytes()], 36));
|
||||
}
|
||||
|
||||
ox::Result<ox::UUID> regenerateUuidHeader(ox::Buffer &buff) noexcept {
|
||||
OX_RETURN_ERROR(readUuidHeader(buff));
|
||||
OX_REQUIRE(id, ox::UUID::generate());
|
||||
auto const str = id.toString();
|
||||
for (size_t i = 0; i < ox::UUIDStr::cap(); ++i) {
|
||||
buff[i + 3] = str[i];
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::BufferView buff) noexcept {
|
||||
std::size_t offset = 0;
|
||||
if (!readUuidHeader(buff).error) {
|
||||
|
@@ -53,10 +53,12 @@ static ox::Error buildUuidMap(Context &ctx, ox::StringViewCR path) noexcept {
|
||||
OX_REQUIRE_M(filePath, ox::join("/", ox::Array<ox::StringView, 2>{path, f}));
|
||||
OX_REQUIRE(stat, ctx.rom->stat(filePath));
|
||||
if (stat.fileType == ox::FileType::NormalFile) {
|
||||
OX_REQUIRE(data, ctx.rom->read(filePath));
|
||||
auto const [hdr, err] = readAssetHeader(data);
|
||||
ox::Array<char, K1HdrSz> buff;
|
||||
OX_RETURN_ERROR(
|
||||
ctx.rom->read(filePath, 0, buff.size(), buff));
|
||||
auto const [uuid, err] = readUuidHeader(buff);
|
||||
if (!err) {
|
||||
createUuidMapping(ctx, filePath, hdr.uuid);
|
||||
createUuidMapping(ctx, filePath, uuid);
|
||||
}
|
||||
} else if (stat.fileType == ox::FileType::Directory) {
|
||||
if (!beginsWith(f, ".")) {
|
||||
|
Reference in New Issue
Block a user