diff --git a/.gitignore b/.gitignore index c17a18f..a504a1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,14 @@ +# cmake files +CMakeFiles/ +CMakeCache.txt +*.cmake +Makefile +_CPack_Packages +install_manifest.txt +*.tar.bz2 +include/npaversion.hpp +!cmake/Modules/*.cmake + # Compiled Object files *.slo *.lo @@ -35,4 +46,6 @@ nipa nsbparse2 nsbcompile2 npcrypt +npfparse +mpkextract *.exe diff --git a/CMakeLists.txt b/CMakeLists.txt index 6517492..273e036 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ add_executable(nsbcompile2 src/nsbcompile2.cpp) add_executable(nsbparse2 src/nsbparse2.cpp) add_executable(npcrypt src/npcrypt.cpp) add_executable(npfparse src/npfparse.cpp) +add_executable(mpkextract src/mpkextract.cpp) # We don't need npinstall on Windows if (NOT WIN32) @@ -64,6 +65,7 @@ target_link_libraries(nsbcompile2 npa) target_link_libraries(nsbparse2 npa) target_link_libraries(npcrypt npa) target_link_libraries(npfparse npa) +target_link_libraries(mpkextract npa) # We don't need npinstall on Windows if (NOT WIN32) diff --git a/README.md b/README.md index b4b6e54..e22ae59 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,15 @@ nptools nptools is a collection of utilities for manipulating nitroplus game files. To build this, you will need [libnpa][1], [unshield][2], zlib and boost. -**npaextract**: Extracts .npa achieve contents. -**npapack**: Creates .npa achieve from specified directory. +**npaextract**: Extracts .npa archive contents. +**npapack**: Creates .npa archive from specified directory. **nsbparse**: Decompiles .nsb script file into a raw human-readble format. **nsbparse2**: Decompiles .nsb script file into a high level language. **nsbcompile2**: Compiles .nss script file into .nsb format. **npinstall**: Installs a Nitroplus game. -**npcrypt**: Decrypts a Steins;Gate save file +**npcrypt**: Decrypts a Steins;Gate save file **npfparse**: Dumps variables from Steins;Gate save file +**mpkextract**: Extract .mpk archive contents. [1]: https://github.com/FGRE/libnpa [2]: https://github.com/twogood/unshield \ No newline at end of file diff --git a/src/mpkextract.cpp b/src/mpkextract.cpp new file mode 100644 index 0000000..ff81b38 --- /dev/null +++ b/src/mpkextract.cpp @@ -0,0 +1,59 @@ +/* + * mpkextract: .mpk file extraction utility + * Copyright (C) 2013-2016,2018 Mislav Blažević + * Copyright (C) 2021 Ivan Pavluk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * */ +#include "impkfile.hpp" +#include "inpafile.hpp" +#include "isgfile.hpp" +#include "fscommon.hpp" +using namespace std; + +int PrintArguments(char** argv) +{ + cout << "Supported games:\nSteinsGate\n"; + cout << "usage: " << argv[0] << " [charset]" << endl; + return 1; +} + +int main(int argc, char** argv) +{ + if (argc < 3 || argc > 4) + return PrintArguments(argv); + + if (argc == 4) + NpaFile::SetLocale(argv[3]); + else + NpaFile::SetLocale("ja_JP.CP932"); + + INpaFile* pArchive; + if (strcmp(argv[2], "SteinsGate") == 0) + pArchive = new IMpkFile(argv[1]); + else + return PrintArguments(argv); + + for (IMpkFile::NpaIterator iter = pArchive->Begin(); iter != pArchive->End(); ++iter) + { + if (pArchive->IsDirectory(iter)) + continue; + + char* pData = pArchive->ReadFile(iter); + cout << "Writing file: " << iter->first << endl; + fs::WriteFileDirectory(iter->first, pData, pArchive->GetFileSize(iter)); + delete[] pData; + } + delete pArchive; +} diff --git a/src/npapack.cpp b/src/npapack.cpp index 61e171b..2d003c1 100644 --- a/src/npapack.cpp +++ b/src/npapack.cpp @@ -51,7 +51,7 @@ int main(int argc, char** argv) NpaFile::SetLocale("ja_JP.CP932"); string DirName(argv[1]); - if (DirName.back() == '/') + if (DirName.back() == '/' || DirName.back() == '\\') DirName.resize(DirName.size() - 1); ONpaFile Archive(DirName + ".npa");