From b107dc756ba4a9394a0e3ad49c97179341751f8b Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 28 Jul 2019 00:32:42 -0500 Subject: [PATCH] [nostalgia] Switch to strong int Error --- .gdblogger.json | 2 +- src/nostalgia/common/bounds.hpp | 2 +- src/nostalgia/common/point.hpp | 2 +- src/nostalgia/core/CMakeLists.txt | 2 - src/nostalgia/core/core.cpp | 2 +- src/nostalgia/core/qt/gfx.cpp | 6 +- src/nostalgia/player/CMakeLists.txt | 17 ++- src/nostalgia/player/main.cpp | 10 +- src/nostalgia/studio/lib/json_read.cpp | 24 ++--- src/nostalgia/studio/lib/json_read.hpp | 12 +-- src/nostalgia/studio/lib/json_test.cpp | 25 ++--- src/nostalgia/studio/lib/json_write.cpp | 12 +-- src/nostalgia/studio/lib/json_write.hpp | 6 +- src/nostalgia/studio/mainwindow.hpp | 22 ++-- src/nostalgia/tools/lib/CMakeLists.txt | 4 +- src/nostalgia/tools/lib/pack.cpp | 27 +++++ src/nostalgia/tools/lib/pack.hpp | 20 ++++ src/nostalgia/tools/lib/tilesetimport.cpp | 124 +++++++++++++--------- src/nostalgia/tools/lib/tilesetimport.hpp | 6 +- src/nostalgia/tools/pack/pack.cpp | 2 +- src/nostalgia/world/world.hpp | 10 +- 21 files changed, 204 insertions(+), 133 deletions(-) create mode 100644 src/nostalgia/tools/lib/pack.cpp create mode 100644 src/nostalgia/tools/lib/pack.hpp diff --git a/.gdblogger.json b/.gdblogger.json index 5ef494d8..d0e5f1a8 100644 --- a/.gdblogger.json +++ b/.gdblogger.json @@ -1,7 +1,7 @@ { "log_functions": [ { - "function": "ox::trace::gdblogger::captureLogFunc", + "function": "oxTraceHook", "ignore_frames": 3, "file_var": "file", "line_var": "line", diff --git a/src/nostalgia/common/bounds.hpp b/src/nostalgia/common/bounds.hpp index 3c8f5793..e8e81d90 100644 --- a/src/nostalgia/common/bounds.hpp +++ b/src/nostalgia/common/bounds.hpp @@ -38,7 +38,7 @@ class Bounds { template ox::Error model(T *io, Bounds *obj) { - ox::Error err = 0; + auto err = OxError(0); io->setTypeInfo("nostalgia::common::Bounds", 4); err |= io->field("x", &obj->x); err |= io->field("y", &obj->y); diff --git a/src/nostalgia/common/point.hpp b/src/nostalgia/common/point.hpp index d5efba82..5f0ee73e 100644 --- a/src/nostalgia/common/point.hpp +++ b/src/nostalgia/common/point.hpp @@ -60,7 +60,7 @@ class Point { template ox::Error model(T *io, Point *obj) { - ox::Error err = 0; + auto err = OxError(0); io->setTypeInfo("nostalgia::common::Bounds", 2); err |= io->field("x", &obj->x); err |= io->field("y", &obj->y); diff --git a/src/nostalgia/core/CMakeLists.txt b/src/nostalgia/core/CMakeLists.txt index 841daa46..1a753972 100644 --- a/src/nostalgia/core/CMakeLists.txt +++ b/src/nostalgia/core/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 2.8.11) - if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA") enable_language(C ASM) set( diff --git a/src/nostalgia/core/core.cpp b/src/nostalgia/core/core.cpp index 8e8d40c1..cdd057ef 100644 --- a/src/nostalgia/core/core.cpp +++ b/src/nostalgia/core/core.cpp @@ -12,7 +12,7 @@ namespace nostalgia::core { ox::Error init(Context *ctx) { - ox::Error err = 0; + auto err = OxError(0); err = initGfx(ctx); initHeap(); // this does nothing in userland builds return err; diff --git a/src/nostalgia/core/qt/gfx.cpp b/src/nostalgia/core/qt/gfx.cpp index 42935a17..461c2ddd 100644 --- a/src/nostalgia/core/qt/gfx.cpp +++ b/src/nostalgia/core/qt/gfx.cpp @@ -11,15 +11,15 @@ namespace nostalgia::core { ox::Error initGfx(Context*) { - return 1; + return OxError(1); } ox::Error initConsole(Context*) { - return 1; + return OxError(1); } ox::Error loadTileSheet(Context*, InodeId_t) { - return 1; + return OxError(1); } void puts(Context*, int, const char*) { diff --git a/src/nostalgia/player/CMakeLists.txt b/src/nostalgia/player/CMakeLists.txt index 257d4419..bcc4f370 100644 --- a/src/nostalgia/player/CMakeLists.txt +++ b/src/nostalgia/player/CMakeLists.txt @@ -1,8 +1,17 @@ -add_executable( - nostalgia - main.cpp -) +if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA") + enable_language(C ASM) + add_executable( + nostalgia + main.cpp + startup.s + ) +else() + add_executable( + nostalgia + main.cpp + ) +endif() if(COMMAND OBJCOPY_FILE) set_target_properties(nostalgia diff --git a/src/nostalgia/player/main.cpp b/src/nostalgia/player/main.cpp index aa765892..58bd50f3 100644 --- a/src/nostalgia/player/main.cpp +++ b/src/nostalgia/player/main.cpp @@ -14,25 +14,23 @@ using namespace nostalgia::core; using namespace nostalgia::world; int run() { + while(1); ox::FileSystem32 fs(ox::FileStore32(loadRom(), 32 * ox::units::MB)); Context ctx; init(&ctx); ctx.rom = &fs; - Zone zone(&ctx, Bounds{0, 0, 40, 40}, 102); - zone.draw(&ctx); + //Zone zone(&ctx, Bounds{0, 0, 40, 40}, 102); + //zone.draw(&ctx); while (1); return 0; } #ifndef OX_USE_STDLIB - -extern "C" -void _start() { +extern "C" void _start() { run(); } - #else int main() { diff --git a/src/nostalgia/studio/lib/json_read.cpp b/src/nostalgia/studio/lib/json_read.cpp index 512c16de..2561f035 100644 --- a/src/nostalgia/studio/lib/json_read.cpp +++ b/src/nostalgia/studio/lib/json_read.cpp @@ -18,7 +18,7 @@ ox::Error JsonReader::field(QString fieldName, int *dest) { if (m_src.contains(fieldName)) { return field(m_src[fieldName], dest); } else { - return JSON_ERR_FIELD_MISSING; + return OxError(JSON_ERR_FIELD_MISSING); } } @@ -26,7 +26,7 @@ ox::Error JsonReader::field(QString fieldName, bool *dest) { if (m_src.contains(fieldName)) { return field(m_src[fieldName], dest); } else { - return JSON_ERR_FIELD_MISSING; + return OxError(JSON_ERR_FIELD_MISSING); } } @@ -34,7 +34,7 @@ ox::Error JsonReader::field(QString fieldName, double *dest) { if (m_src.contains(fieldName)) { return field(m_src[fieldName], dest); } else { - return JSON_ERR_FIELD_MISSING; + return OxError(JSON_ERR_FIELD_MISSING); } } @@ -42,7 +42,7 @@ ox::Error JsonReader::field(QString fieldName, QString *dest) { if (m_src.contains(fieldName)) { return field(m_src[fieldName], dest); } else { - return JSON_ERR_FIELD_MISSING; + return OxError(JSON_ERR_FIELD_MISSING); } } @@ -51,36 +51,36 @@ ox::Error JsonReader::field(QString fieldName, QString *dest) { ox::Error JsonReader::field(QJsonValueRef src, int *dest) { if (src.isDouble()) { *dest = src.toInt(); - return 0; + return OxError(0); } else { - return JSON_ERR_UNEXPECTED_TYPE; + return OxError(JSON_ERR_UNEXPECTED_TYPE); } } ox::Error JsonReader::field(QJsonValueRef src, bool *dest) { if (src.isBool()) { *dest = src.toBool(); - return 0; + return OxError(0); } else { - return JSON_ERR_UNEXPECTED_TYPE; + return OxError(JSON_ERR_UNEXPECTED_TYPE); } } ox::Error JsonReader::field(QJsonValueRef src, double *dest) { if (src.isDouble()) { *dest = src.toDouble(); - return 0; + return OxError(0); } else { - return JSON_ERR_UNEXPECTED_TYPE; + return OxError(JSON_ERR_UNEXPECTED_TYPE); } } ox::Error JsonReader::field(QJsonValueRef src, QString *dest) { if (src.isString()) { *dest = src.toString(); - return 0; + return OxError(0); } else { - return JSON_ERR_UNEXPECTED_TYPE; + return OxError(JSON_ERR_UNEXPECTED_TYPE); } } diff --git a/src/nostalgia/studio/lib/json_read.hpp b/src/nostalgia/studio/lib/json_read.hpp index 28075f6a..f8321493 100644 --- a/src/nostalgia/studio/lib/json_read.hpp +++ b/src/nostalgia/studio/lib/json_read.hpp @@ -16,8 +16,7 @@ #include "json_err.hpp" -namespace nostalgia { -namespace studio { +namespace nostalgia::studio { class JsonReader { @@ -64,21 +63,21 @@ ox::Error JsonReader::field(QString fieldName, T *dest) { auto reader = JsonReader(obj); return model(&reader, dest); } else { - return JSON_ERR_FIELD_MISSING; + return OxError(JSON_ERR_FIELD_MISSING); } } template ox::Error JsonReader::field(QString fieldName, QVector *dest) { - ox::Error err = 0; + auto err = OxError(0); if (m_src.contains(fieldName)) { auto a = m_src[fieldName].toArray(); dest->resize(a.size()); for (int i = 0; i < dest->size(); i++) { - err |= field(a[i], &(*dest)[i]); + oxReturnError(field(a[i], &(*dest)[i])); } } else { - err |= JSON_ERR_FIELD_MISSING; + err = OxError(JSON_ERR_FIELD_MISSING); } return err; } @@ -98,4 +97,3 @@ ox::Error readJson(QString json, T *dest) { } } -} diff --git a/src/nostalgia/studio/lib/json_test.cpp b/src/nostalgia/studio/lib/json_test.cpp index 75aaa0c6..d59c6214 100644 --- a/src/nostalgia/studio/lib/json_test.cpp +++ b/src/nostalgia/studio/lib/json_test.cpp @@ -7,6 +7,7 @@ */ #include +#include #include "json.hpp" using namespace std; @@ -22,7 +23,7 @@ struct TestStructNest { template Error model(T *io, TestStructNest *obj) { - Error err = 0; + auto err = OxError(0); err |= io->setTypeInfo("TestStructNest", 4); err |= io->field("Bool", &obj->Bool); err |= io->field("Int", &obj->Int); @@ -41,7 +42,7 @@ struct TestStruct { template Error model(T *io, TestStruct *obj) { - Error err = 0; + auto err = OxError(0); err |= io->setTypeInfo("TestStruct", 5); err |= io->field("Bool", &obj->Bool); err |= io->field("Int", &obj->Int); @@ -52,7 +53,7 @@ Error model(T *io, TestStruct *obj) { } int main() { - int err = 0; + auto err = OxError(0); QString json; TestStruct ts = { true, @@ -75,15 +76,15 @@ int main() { cout << tsOut.Double << endl; cout << tsOut.String.toStdString() << endl; - err |= !(tsOut.Bool) << 0; - err |= !(tsOut.Int == 42) << 1; - err |= !(tsOut.Double == 42.42) << 2; - err |= !(tsOut.String == "Test String") << 3; + oxAssert(tsOut.Bool, "Arg 1 failed"); + oxAssert(tsOut.Int == 42, "Arg 2 failed"); + oxAssert(tsOut.Double == 42.42, "Arg 3 failed"); + oxAssert(tsOut.String == "Test String", "Arg 4 failed"); - err |= !(tsOut.Struct.Bool) << 4; - err |= !(tsOut.Struct.Int == 42) << 5; - err |= !(tsOut.Struct.Double == 42.42) << 6; - err |= !(tsOut.Struct.String == "Test String") << 7; + oxAssert(tsOut.Struct.Bool, "Arg 5 failed"); + oxAssert(tsOut.Struct.Int == 42, "Arg 6 failed"); + oxAssert(tsOut.Struct.Double == 42.42, "Arg 7 failed"); + oxAssert(tsOut.Struct.String == "Test String", "Arg 8 failed"); - return err; + return static_cast(err); } diff --git a/src/nostalgia/studio/lib/json_write.cpp b/src/nostalgia/studio/lib/json_write.cpp index e574d331..57785efd 100644 --- a/src/nostalgia/studio/lib/json_write.cpp +++ b/src/nostalgia/studio/lib/json_write.cpp @@ -8,31 +8,29 @@ #include "json_write.hpp" -namespace nostalgia { -namespace studio { +namespace nostalgia::studio { JsonWriter::JsonWriter(QJsonObject &obj): m_dest(obj) { } ox::Error JsonWriter::field(QString fieldName, int *src) { m_dest[fieldName] = *src; - return 0; + return OxError(0); } ox::Error JsonWriter::field(QString fieldName, bool *src) { m_dest[fieldName] = *src; - return 0; + return OxError(0); } ox::Error JsonWriter::field(QString fieldName, double *src) { m_dest[fieldName] = *src; - return 0; + return OxError(0); } ox::Error JsonWriter::field(QString fieldName, QString *src) { m_dest[fieldName] = *src; - return 0; + return OxError(0); } } -} diff --git a/src/nostalgia/studio/lib/json_write.hpp b/src/nostalgia/studio/lib/json_write.hpp index 6b72e310..92cf7579 100644 --- a/src/nostalgia/studio/lib/json_write.hpp +++ b/src/nostalgia/studio/lib/json_write.hpp @@ -16,8 +16,7 @@ #include "json_err.hpp" -namespace nostalgia { -namespace studio { +namespace nostalgia::studio { class JsonWriter { @@ -56,7 +55,7 @@ ox::Error JsonWriter::field(QString fieldName, T *src) { template ox::Error JsonWriter::field(QString fieldName, QVector *src) { - ox::Error err = 0; + auto err = OxError(0); QJsonArray a; for (int i = 0; i < src->size(); i++) { err |= field(a[i], &src->at(i)); @@ -75,4 +74,3 @@ ox::Error writeJson(QString *json, T *src) { } } -} diff --git a/src/nostalgia/studio/mainwindow.hpp b/src/nostalgia/studio/mainwindow.hpp index 34abce9d..b60e4572 100644 --- a/src/nostalgia/studio/mainwindow.hpp +++ b/src/nostalgia/studio/mainwindow.hpp @@ -36,9 +36,9 @@ struct NostalgiaStudioState { template ox::Error model(T *io, NostalgiaStudioState *obj) { - ox::Error err = 0; - err |= io->setTypeInfo("NostalgiaStudioState", 1); - err |= io->field("project_path", &obj->projectPath); + auto err = OxError(0); + oxReturnError(io->setTypeInfo("NostalgiaStudioState", 1)); + oxReturnError(io->field("project_path", &obj->projectPath)); return err; } @@ -50,10 +50,10 @@ struct NostalgiaStudioPluginDef { template ox::Error model(T *io, NostalgiaStudioPluginDef *obj) { - ox::Error err = 0; - err |= io->setTypeInfo("NostalgiaStudioPluginDef", 2); - err |= io->field("dir", &obj->dir); - err |= io->field("lib_name", &obj->libName); + auto err = OxError(0); + oxReturnError(io->setTypeInfo("NostalgiaStudioPluginDef", 2)); + oxReturnError(io->field("dir", &obj->dir)); + oxReturnError(io->field("lib_name", &obj->libName)); return err; } @@ -66,11 +66,11 @@ struct NostalgiaStudioProfile { template ox::Error model(T *io, NostalgiaStudioProfile *obj) { - ox::Error err = 0; + auto err = OxError(0); io->setTypeInfo("NostalgiaStudioProfile", 3); - err |= io->field("app_name", &obj->appName); - err |= io->field("org_name", &obj->orgName); - err |= io->field("plugins_path", &obj->pluginsPath); + oxReturnError(io->field("app_name", &obj->appName)); + oxReturnError(io->field("org_name", &obj->orgName)); + oxReturnError(io->field("plugins_path", &obj->pluginsPath)); return err; } diff --git a/src/nostalgia/tools/lib/CMakeLists.txt b/src/nostalgia/tools/lib/CMakeLists.txt index 6b2c2145..221afc7a 100644 --- a/src/nostalgia/tools/lib/CMakeLists.txt +++ b/src/nostalgia/tools/lib/CMakeLists.txt @@ -1,10 +1,9 @@ -cmake_minimum_required(VERSION 2.8.11) - set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) add_library( NostalgiaTool SHARED + pack.cpp tilesetimport.cpp ) @@ -19,6 +18,7 @@ target_link_libraries( install( FILES + pack.hpp tilesetimport.hpp DESTINATION include/nostalgia/tools/lib diff --git a/src/nostalgia/tools/lib/pack.cpp b/src/nostalgia/tools/lib/pack.cpp new file mode 100644 index 00000000..8eaf2e34 --- /dev/null +++ b/src/nostalgia/tools/lib/pack.cpp @@ -0,0 +1,27 @@ +/* + * Copyright 2016 - 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include + +#include + +#include "tilesetimport.hpp" + +namespace nostalgia { + +ox::Error pack(QDir src, ox::FileSystem *dest) { + for (auto entry : src.entryList()) { + qDebug() << entry; + oxReturnError(importTileSet(dest, entry, entry)); + } + return OxError(0); +} + +} + diff --git a/src/nostalgia/tools/lib/pack.hpp b/src/nostalgia/tools/lib/pack.hpp new file mode 100644 index 00000000..d2f0003c --- /dev/null +++ b/src/nostalgia/tools/lib/pack.hpp @@ -0,0 +1,20 @@ +/* + * Copyright 2016 - 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include + +#include + +namespace nostalgia { + +ox::Error pack(QDir src, ox::FileSystem *dest); + +} + diff --git a/src/nostalgia/tools/lib/tilesetimport.cpp b/src/nostalgia/tools/lib/tilesetimport.cpp index dc143d35..f6b8ba95 100644 --- a/src/nostalgia/tools/lib/tilesetimport.cpp +++ b/src/nostalgia/tools/lib/tilesetimport.cpp @@ -19,7 +19,6 @@ namespace nostalgia { -using namespace ox; using namespace nostalgia::core; using namespace nostalgia::common; @@ -30,8 +29,8 @@ using namespace nostalgia::common; return (r << 10) | (g << 5) | (b << 0); } -int pointToIdx(int w, int x, int y) { - const auto colLength = 64; +[[nodiscard]] constexpr int pointToIdx(int w, int x, int y) noexcept { + constexpr auto colLength = 64; const auto rowLength = (w / 8) * colLength; const auto colStart = colLength * (x / 8); const auto rowStart = rowLength * (y / 8); @@ -40,58 +39,81 @@ int pointToIdx(int w, int x, int y) { return colStart + colOffset + rowStart + rowOffset; } -Error importTileSet(FileSystem *fs, QString romPath, QString importPath, int bpp) { - Error err = 0; - +[[nodiscard]] ox::ValErr countColors(QString importPath) { QImage src(importPath); if (!src.isNull()) { - QMap colors; - auto tileCount = (src.width() * src.height()) / 64; - const auto imgDataBuffSize = sizeof(GbaImageData) + 1 + tileCount * 64; - QVector imgDataBuff(imgDataBuffSize); - memset(imgDataBuff.data(), 0, imgDataBuffSize); - GbaImageData *id = reinterpret_cast(imgDataBuff.data()); - id->header.bpp = bpp; - id->header.tileCount = tileCount; - int colorId = 0; - - // copy pixels as color ids - for (int x = 0; x < src.width(); x++) { - for (int y = 0; y < src.height(); y++) { - auto destI = pointToIdx(src.width(), x, y); - auto c = src.pixel(x, y); - // assign color a color id for the palette - if (!colors.contains(c)) { - colors[c] = colorId; - colorId++; - } - // set pixel color - if (bpp == 4) { - if (destI % 2) { // is odd number pixel - id->tiles[destI / 2] |= colors[c] << 4; - } else { - id->tiles[destI / 2] |= colors[c]; - } - } else { - id->tiles[destI] = colors[c]; - } - } - } - - // store colors in palette with the corresponding color id - for (auto key : colors.keys()) { - auto colorId = colors[key]; - id->pal[colorId] = toGbaColor(key); - } - - if (!err) { - err |= fs->write(romPath.toUtf8().data(), imgDataBuff.data(), imgDataBuffSize); - } - } else { - err = 4; + return {{}, OxError(1)}; } - return err; + QMap colors; + + // copy pixels as color ids + for (int x = 0; x < src.width(); x++) { + for (int y = 0; y < src.height(); y++) { + auto c = src.pixel(x, y); + // assign color a color id for the palette + if (!colors.contains(c)) { + colors[c] = true; + } + } + } + + return colors.size(); +} + +[[nodiscard]] ox::ValErr> convertImg(QString importPath, int bpp) { + QImage src(importPath); + if (!src.isNull()) { + return {{}, OxError(1)}; + } + + QMap colors; + auto tileCount = (src.width() * src.height()) / 64; + const auto imgDataBuffSize = sizeof(GbaImageData) + 1 + tileCount * 64; + QVector imgDataBuff(imgDataBuffSize); + memset(imgDataBuff.data(), 0, imgDataBuffSize); + GbaImageData *id = reinterpret_cast(imgDataBuff.data()); + id->header.bpp = bpp; + id->header.tileCount = tileCount; + int colorId = 0; + + // copy pixels as color ids + for (int x = 0; x < src.width(); x++) { + for (int y = 0; y < src.height(); y++) { + auto destI = pointToIdx(src.width(), x, y); + auto c = src.pixel(x, y); + // assign color a color id for the palette + if (!colors.contains(c)) { + colors[c] = colorId; + colorId++; + } + // set pixel color + if (bpp == 4) { + if (destI % 2) { // is odd number pixel + id->tiles[destI / 2] |= colors[c] << 4; + } else { + id->tiles[destI / 2] |= colors[c]; + } + } else { + id->tiles[destI] = colors[c]; + } + } + } + + // store colors in palette with the corresponding color id + for (auto key : colors.keys()) { + auto colorId = colors[key]; + id->pal[colorId] = toGbaColor(key); + } + + return imgDataBuff; +} + +ox::Error importTileSet(ox::FileSystem *fs, QString romPath, QString importPath) { + const auto bpp = countColors(importPath) > 16 ? 8 : 4; + auto [imgDataBuff, err] = convertImg(importPath, bpp); + oxReturnError(err); + return fs->write(romPath.toUtf8().data(), imgDataBuff.data(), imgDataBuff.size()); } } diff --git a/src/nostalgia/tools/lib/tilesetimport.hpp b/src/nostalgia/tools/lib/tilesetimport.hpp index ad453680..75cc6033 100644 --- a/src/nostalgia/tools/lib/tilesetimport.hpp +++ b/src/nostalgia/tools/lib/tilesetimport.hpp @@ -8,10 +8,12 @@ #include -#include +#include namespace nostalgia { -ox::Error importTileSet(FileSystem *fs, QString romPath, QString importPath, int bpp); +[[nodiscard]] ox::ValErr countColors(QString importPath); + +ox::Error importTileSet(ox::FileSystem *fs, QString romPath, QString importPath); } diff --git a/src/nostalgia/tools/pack/pack.cpp b/src/nostalgia/tools/pack/pack.cpp index d2da71ff..90e65dde 100644 --- a/src/nostalgia/tools/pack/pack.cpp +++ b/src/nostalgia/tools/pack/pack.cpp @@ -66,7 +66,7 @@ namespace { [[nodiscard]] ox::Error verifyFile(ox::FileSystem32 *fs, const std::string &path, const std::vector &expected) noexcept { std::vector buff(expected.size()); oxReturnError(fs->read(path.c_str(), buff.data(), buff.size())); - return buff == expected ? 0 : OxError(1); + return OxError(buff == expected ? 0 : 1); } [[nodiscard]] ox::Error copy(ox::PassThroughFS *src, ox::FileSystem32 *dest, std::string path) { diff --git a/src/nostalgia/world/world.hpp b/src/nostalgia/world/world.hpp index b9f3aaeb..ea51893b 100644 --- a/src/nostalgia/world/world.hpp +++ b/src/nostalgia/world/world.hpp @@ -26,7 +26,7 @@ struct Tile { template ox::Error modelRead(T *io, Tile *obj) { - ox::Error err = 0; + auto err = OxError(0); io->setTypeInfo("nostalgia::world::Tile", Tile::Fields); err |= io->field("bgTile", &obj->bgTile); err |= io->field("type", &obj->type); @@ -62,7 +62,7 @@ struct Zone { template ox::Error modelRead(T *io, Zone *obj) { - ox::Error err = 0; + auto err = OxError(0); io->setTypeInfo("nostalgia::world::Zone", Zone::Fields); err |= io->field("bounds", &obj->m_bounds); return err; @@ -70,7 +70,7 @@ ox::Error modelRead(T *io, Zone *obj) { template ox::Error modelWrite(T *io, Zone *obj) { - ox::Error err = 0; + auto err = OxError(0); io->setTypeInfo("nostalgia::world::Zone", Zone::Fields); err |= io->field("bounds", &obj->m_bounds); return err; @@ -95,14 +95,14 @@ struct Region { template ox::Error modelRead(T *io, Region*) { - ox::Error err = 0; + auto err = OxError(0); io->setTypeInfo("nostalgia::World::Region", Region::Fields); return err; } template ox::Error modelWrite(T *io, Region*) { - ox::Error err = 0; + auto err = OxError(0); io->setTypeInfo("nostalgia::World::Region", Region::Fields); return err; }