From 84feeb8c1f1e7af3fb4ee8afa6fec5fe7b95f9dc Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 22 Jul 2019 23:17:08 -0500 Subject: [PATCH] [nostalgia/tools/pack] Cleanup --- src/nostalgia/tools/pack/imgconv.cpp | 4 ++-- src/nostalgia/tools/pack/pack.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/nostalgia/tools/pack/imgconv.cpp b/src/nostalgia/tools/pack/imgconv.cpp index 01e61856..c71ee3e4 100644 --- a/src/nostalgia/tools/pack/imgconv.cpp +++ b/src/nostalgia/tools/pack/imgconv.cpp @@ -105,8 +105,8 @@ namespace { // store colors in palette with the corresponding color id for (auto key : colors.keys()) { - auto colorId = colors[key]; - id->pal[colorId] = toGbaColor(key); + auto colorId = colors[key]; + id->pal[colorId] = toGbaColor(key); } return imgDataBuff; diff --git a/src/nostalgia/tools/pack/pack.cpp b/src/nostalgia/tools/pack/pack.cpp index 4e7f9a5f..d2da71ff 100644 --- a/src/nostalgia/tools/pack/pack.cpp +++ b/src/nostalgia/tools/pack/pack.cpp @@ -74,7 +74,7 @@ namespace { // copy return src->ls(path.c_str(), [src, dest, path](const char *name, ox::InodeId_t) { std::cout << "reading " << name << '\n'; - const auto currentFile = path + name; + auto currentFile = path + name; auto [stat, err] = src->stat((currentFile).c_str()); oxReturnError(err); if (stat.fileType == ox::FileType_Directory) { @@ -83,10 +83,13 @@ namespace { } else { std::vector buff; // do transforms - if (endsWith(currentFile, ".png")) { + constexpr std::string_view PngExt = ".png"; + constexpr std::string_view GbagExt = ".ng"; + if (endsWith(currentFile, PngExt)) { // load file from full path and transform const auto fullPath = src->basePath() + currentFile; buff = pngToGba(fullPath.c_str(), 0, 0); + currentFile = currentFile.substr(0, currentFile.size() - PngExt.size()) + GbagExt.data(); if (!buff.size()) { return OxError(1); }