[nostalgia/core] Cleanup, revert CompactTileSheet version to 1
All checks were successful
Build / build (push) Successful in 2m2s

This commit is contained in:
Gary Talent 2023-12-26 18:50:33 -06:00
parent e2d0a784f1
commit d83e392964
2 changed files with 28 additions and 28 deletions

View File

@ -242,7 +242,7 @@ struct TileSheet {
SubSheetIdx validateSubSheetIdx(
SubSheetIdx const&pIdx,
std::size_t pIdxIt,
const SubSheet *pSubsheet) noexcept;
SubSheet const&pSubsheet) noexcept;
/**
* validateSubSheetIdx takes a SubSheetIdx and moves the index to the
@ -252,19 +252,19 @@ struct TileSheet {
* @return a valid version of idx
*/
[[nodiscard]]
SubSheetIdx validateSubSheetIdx(const SubSheetIdx &idx) noexcept;
SubSheetIdx validateSubSheetIdx(SubSheetIdx const&idx) noexcept;
[[nodiscard]]
static SubSheet const&getSubSheet(
SubSheetIdx const&idx,
std::size_t idxIt,
const SubSheet *pSubsheet) noexcept;
SubSheet const&pSubsheet) noexcept;
[[nodiscard]]
static SubSheet &getSubSheet(
SubSheetIdx const&idx,
std::size_t idxIt,
SubSheet *pSubsheet) noexcept;
SubSheet &pSubsheet) noexcept;
[[nodiscard]]
const SubSheet &getSubSheet(SubSheetIdx const&idx) const noexcept;
@ -278,7 +278,7 @@ struct TileSheet {
static ox::Error rmSubSheet(
SubSheetIdx const&idx,
std::size_t idxIt,
SubSheet *pSubsheet) noexcept;
SubSheet &pSubsheet) noexcept;
[[nodiscard]]
ox::Error rmSubSheet(SubSheetIdx const&idx) noexcept;
@ -308,7 +308,7 @@ using TileSheetV4 = TileSheet;
struct CompactTileSheet {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.CompactTileSheet";
static constexpr auto TypeVersion = 2;
static constexpr auto TypeVersion = 1;
int8_t bpp = 0;
ox::FileAddress defaultPalette;
ox::Vector<uint8_t> pixels = {};

View File

@ -254,59 +254,59 @@ TileSheet &TileSheet::operator=(TileSheet &&other) noexcept {
}
TileSheet::SubSheetIdx TileSheet::validateSubSheetIdx(
const SubSheetIdx &pIdx,
SubSheetIdx const&pIdx,
std::size_t pIdxIt,
const SubSheet *pSubsheet) noexcept {
SubSheet const&pSubsheet) noexcept {
if (pIdxIt == pIdx.size()) {
return pIdx;
}
const auto currentIdx = pIdx[pIdxIt];
if (pSubsheet->subsheets.size() <= currentIdx) {
if (pSubsheet.subsheets.size() <= currentIdx) {
auto out = pIdx;
if (!pSubsheet->subsheets.empty()) {
*out.back().value = pSubsheet->subsheets.size() - 1;
if (!pSubsheet.subsheets.empty()) {
*out.back().value = pSubsheet.subsheets.size() - 1;
} else {
out.pop_back();
}
return out;
}
return validateSubSheetIdx(pIdx, pIdxIt + 1, &pSubsheet->subsheets[pIdx[pIdxIt]]);
return validateSubSheetIdx(pIdx, pIdxIt + 1, pSubsheet.subsheets[pIdx[pIdxIt]]);
}
TileSheet::SubSheetIdx TileSheet::validateSubSheetIdx(const SubSheetIdx &idx) noexcept {
return validateSubSheetIdx(idx, 0, &subsheet);
TileSheet::SubSheetIdx TileSheet::validateSubSheetIdx(SubSheetIdx const&idx) noexcept {
return validateSubSheetIdx(idx, 0, subsheet);
}
const TileSheet::SubSheet &TileSheet::getSubSheet(
TileSheet::SubSheetIdx const&idx,
std::size_t idxIt,
SubSheet const*pSubsheet) noexcept {
SubSheet const&pSubsheet) noexcept {
if (idxIt == idx.size()) {
return *pSubsheet;
return pSubsheet;
}
const auto currentIdx = idx[idxIt];
if (pSubsheet->subsheets.size() < currentIdx) {
return *pSubsheet;
if (pSubsheet.subsheets.size() < currentIdx) {
return pSubsheet;
}
return getSubSheet(idx, idxIt + 1, &pSubsheet->subsheets[currentIdx]);
return getSubSheet(idx, idxIt + 1, pSubsheet.subsheets[currentIdx]);
}
TileSheet::SubSheet &TileSheet::getSubSheet(
TileSheet::SubSheetIdx const&idx,
std::size_t idxIt,
TileSheet::SubSheet *pSubsheet) noexcept {
TileSheet::SubSheet &pSubsheet) noexcept {
if (idxIt == idx.size()) {
return *pSubsheet;
return pSubsheet;
}
return getSubSheet(idx, idxIt + 1, &pSubsheet->subsheets[idx[idxIt]]);
return getSubSheet(idx, idxIt + 1, pSubsheet.subsheets[idx[idxIt]]);
}
const TileSheet::SubSheet &TileSheet::getSubSheet(TileSheet::SubSheetIdx const&idx) const noexcept {
return getSubSheet(idx, 0, &subsheet);
return getSubSheet(idx, 0, subsheet);
}
TileSheet::SubSheet &TileSheet::getSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
return getSubSheet(idx, 0, &subsheet);
return getSubSheet(idx, 0, subsheet);
}
ox::Error TileSheet::addSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
@ -323,15 +323,15 @@ ox::Error TileSheet::addSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
ox::Error TileSheet::rmSubSheet(
SubSheetIdx const&idx,
std::size_t idxIt,
SubSheet *pSubsheet) noexcept {
SubSheet &pSubsheet) noexcept {
if (idxIt == idx.size() - 1) {
return pSubsheet->subsheets.erase(idx[idxIt]).error;
return pSubsheet.subsheets.erase(idx[idxIt]).error;
}
return rmSubSheet(idx, idxIt + 1, &pSubsheet->subsheets[idx[idxIt]]);
return rmSubSheet(idx, idxIt + 1, pSubsheet.subsheets[idx[idxIt]]);
}
ox::Error TileSheet::rmSubSheet(TileSheet::SubSheetIdx const&idx) noexcept {
return rmSubSheet(idx, 0, &subsheet);
return rmSubSheet(idx, 0, subsheet);
}
uint8_t TileSheet::getPixel4Bpp(