From ec0c7de511ab8930fd4d8fab3e94a837f8a009af Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 22 Jul 2015 09:05:18 -1000 Subject: [PATCH 1/3] MSVC fixes --- CMakeLists.txt | 1 - DataSpec/CMakeLists.txt | 3 ++- DataSpec/DNACommon/DNACommon.hpp | 11 ++++++++++- DataSpec/DNACommon/STRG.hpp | 23 ----------------------- DataSpec/DNACommon/TXTR.cpp | 4 +++- DataSpec/DNAMP1/DNAMP1.cpp | 2 +- DataSpec/DNAMP1/PAK.cpp | 2 +- DataSpec/DNAMP1/STRG.hpp | 23 ++++++++++++++++++++++- DataSpec/DNAMP2/DNAMP2.cpp | 2 +- DataSpec/DNAMP2/STRG.cpp | 1 + DataSpec/DNAMP2/STRG.hpp | 23 ++++++++++++++++++++++- DataSpec/DNAMP3/PAK.cpp | 11 ++++++----- DataSpec/DNAMP3/STRG.cpp | 1 + DataSpec/DNAMP3/STRG.hpp | 14 +++++++++++++- DataSpec/SpecBase.cpp | 2 ++ DataSpec/SpecMP1.cpp | 13 +++++++++++-- DataSpec/SpecMP2.cpp | 12 ++++++++++-- DataSpec/SpecMP3.cpp | 14 +++++++++++--- NODLib | 2 +- 19 files changed, 118 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 804dd214c..e8a62f958 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,6 @@ set(NOD_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/NODLib/include) add_subdirectory(DataSpec) add_subdirectory(Runtime) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") include_directories(include) add_library(RetroCommon src/RetroCommon.cpp include/RetroCommon.hpp diff --git a/DataSpec/CMakeLists.txt b/DataSpec/CMakeLists.txt index 7dea5a421..7a94635de 100644 --- a/DataSpec/CMakeLists.txt +++ b/DataSpec/CMakeLists.txt @@ -1,6 +1,5 @@ include_directories(${HECL_INCLUDE_DIR} ${NOD_LIB_INCLUDE_DIR} ${LIBPNG_INCLUDE_DIR} ${SQUISH_INCLUDE_DIR}) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-multichar") # Magic ingredient find_package(atdna REQUIRED) @@ -13,6 +12,8 @@ macro(make_dnalist outlist) endforeach() endmacro() +include_directories(${ZLIB_INCLUDE_DIR} ${LZO_INCLUDE_DIR}) + # Each game's DNA library add_subdirectory(DNACommon) add_subdirectory(DNAMP1) diff --git a/DataSpec/DNACommon/DNACommon.hpp b/DataSpec/DNACommon/DNACommon.hpp index b1f694741..841bdc3b6 100644 --- a/DataSpec/DNACommon/DNACommon.hpp +++ b/DataSpec/DNACommon/DNACommon.hpp @@ -133,13 +133,22 @@ struct CaseInsensitiveCompare inline bool operator()(const std::string& lhs, const std::string& rhs) const { #if _WIN32 - if (stricmp(lhs.c_str(), rhs.c_str()) < 0) + if (_stricmp(lhs.c_str(), rhs.c_str()) < 0) #else if (strcasecmp(lhs.c_str(), rhs.c_str()) < 0) #endif return true; return false; } + +#if _WIN32 + inline bool operator()(const std::wstring& lhs, const std::wstring& rhs) const + { + if (_wcsicmp(lhs.c_str(), rhs.c_str()) < 0) + return true; + return false; + } +#endif }; /* PAK entry stream reader */ diff --git a/DataSpec/DNACommon/STRG.hpp b/DataSpec/DNACommon/STRG.hpp index e6bbe38e1..abf87ea09 100644 --- a/DataSpec/DNACommon/STRG.hpp +++ b/DataSpec/DNACommon/STRG.hpp @@ -23,29 +23,6 @@ struct ISTRG virtual bool readAngelScript(const AngelScript::asIScriptModule& in)=0; virtual void writeAngelScript(std::ofstream& out) const=0; - - template - static bool Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath) - { - SUBCLS strg; - strg.read(rs); - std::ofstream strgOut(outPath.getAbsolutePath()); - strg.writeAngelScript(strgOut); - return true; - } - - template - static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath) - { - SUBCLS strg; - HECL::Database::ASUniqueModule mod = HECL::Database::ASUniqueModule::CreateFromPath(inPath); - if (!mod) - return false; - strg.readAngelScript(mod); - Athena::io::FileWriter ws(outPath.getAbsolutePath()); - strg.write(ws); - return true; - } }; std::unique_ptr LoadSTRG(Athena::io::IStreamReader& reader); diff --git a/DataSpec/DNACommon/TXTR.cpp b/DataSpec/DNACommon/TXTR.cpp index 13eda0981..427d08fcc 100644 --- a/DataSpec/DNACommon/TXTR.cpp +++ b/DataSpec/DNACommon/TXTR.cpp @@ -439,11 +439,13 @@ bool TXTR::Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath) png_write_flush(png); png_destroy_write_struct(&png, &info); fclose(fp); + + return true; } bool TXTR::Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath) { - + return false; } } diff --git a/DataSpec/DNAMP1/DNAMP1.cpp b/DataSpec/DNAMP1/DNAMP1.cpp index 0424a830b..23c7c63d7 100644 --- a/DataSpec/DNAMP1/DNAMP1.cpp +++ b/DataSpec/DNAMP1/DNAMP1.cpp @@ -49,7 +49,7 @@ ResExtractor PAKBridge::LookupExtractor(const PAK::Entry& entry) switch (entry.type.toUint32()) { case SBIG('STRG'): - return {STRG::Extract, ".as"}; + return {STRG::Extract, ".as"}; case SBIG('TXTR'): return {TXTR::Extract, ".png"}; } diff --git a/DataSpec/DNAMP1/PAK.cpp b/DataSpec/DNAMP1/PAK.cpp index 8881a9220..00f2009bd 100644 --- a/DataSpec/DNAMP1/PAK.cpp +++ b/DataSpec/DNAMP1/PAK.cpp @@ -57,7 +57,7 @@ void PAK::write(Athena::io::IStreamWriter& writer) const writer.writeUint32(0x00030005); writer.writeUint32(0); - writer.writeUint32(m_nameEntries.size()); + writer.writeUint32((atUint32)m_nameEntries.size()); for (const NameEntry& entry : m_nameEntries) { ((NameEntry&)entry).nameLen = entry.name.size(); diff --git a/DataSpec/DNAMP1/STRG.hpp b/DataSpec/DNAMP1/STRG.hpp index 07251352c..9d6ee0c96 100644 --- a/DataSpec/DNAMP1/STRG.hpp +++ b/DataSpec/DNAMP1/STRG.hpp @@ -53,12 +53,33 @@ struct STRG : ISTRG, BigDNA #else return HECL::WideToUTF8(search->second->at(idx)); #endif - return std::string(); + return HECL::SystemString(); } bool readAngelScript(const AngelScript::asIScriptModule& in); void writeAngelScript(std::ofstream& out) const; + static bool Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath) + { + STRG strg; + strg.read(rs); + std::ofstream strgOut(outPath.getAbsolutePath()); + strg.writeAngelScript(strgOut); + return true; + } + + static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath) + { + STRG strg; + HECL::Database::ASUniqueModule mod = HECL::Database::ASUniqueModule::CreateFromPath(inPath); + if (!mod) + return false; + strg.readAngelScript(mod); + Athena::io::FileWriter ws(outPath.getAbsolutePath()); + strg.write(ws); + return true; + } + }; } diff --git a/DataSpec/DNAMP2/DNAMP2.cpp b/DataSpec/DNAMP2/DNAMP2.cpp index 5f0404812..3c9299080 100644 --- a/DataSpec/DNAMP2/DNAMP2.cpp +++ b/DataSpec/DNAMP2/DNAMP2.cpp @@ -48,7 +48,7 @@ ResExtractor PAKBridge::LookupExtractor(const DNAMP1::PAK::Entry& entry) switch (entry.type.toUint32()) { case SBIG('STRG'): - return {STRG::Extract, ".as"}; + return {STRG::Extract, ".as"}; case SBIG('TXTR'): return {TXTR::Extract, ".png"}; } diff --git a/DataSpec/DNAMP2/STRG.cpp b/DataSpec/DNAMP2/STRG.cpp index 24611ebe4..4014c497e 100644 --- a/DataSpec/DNAMP2/STRG.cpp +++ b/DataSpec/DNAMP2/STRG.cpp @@ -141,6 +141,7 @@ void STRG::write(Athena::io::IStreamWriter& writer) const bool STRG::readAngelScript(const AngelScript::asIScriptModule& in) { + return false; } void STRG::writeAngelScript(std::ofstream& out) const diff --git a/DataSpec/DNAMP2/STRG.hpp b/DataSpec/DNAMP2/STRG.hpp index 5cb687e8d..bfc976073 100644 --- a/DataSpec/DNAMP2/STRG.hpp +++ b/DataSpec/DNAMP2/STRG.hpp @@ -60,11 +60,32 @@ struct STRG : ISTRG, BigDNA #else return HECL::WideToUTF8(search->second->at(idx)); #endif - return std::string(); + return HECL::SystemString(); } bool readAngelScript(const AngelScript::asIScriptModule& in); void writeAngelScript(std::ofstream& out) const; + + static bool Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath) + { + STRG strg; + strg.read(rs); + std::ofstream strgOut(outPath.getAbsolutePath()); + strg.writeAngelScript(strgOut); + return true; + } + + static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath) + { + STRG strg; + HECL::Database::ASUniqueModule mod = HECL::Database::ASUniqueModule::CreateFromPath(inPath); + if (!mod) + return false; + strg.readAngelScript(mod); + Athena::io::FileWriter ws(outPath.getAbsolutePath()); + strg.write(ws); + return true; + } }; } diff --git a/DataSpec/DNAMP3/PAK.cpp b/DataSpec/DNAMP3/PAK.cpp index 3a5be6742..74293d320 100644 --- a/DataSpec/DNAMP3/PAK.cpp +++ b/DataSpec/DNAMP3/PAK.cpp @@ -67,7 +67,7 @@ void PAK::write(Athena::io::IStreamWriter& writer) const FourCC("STRG").write(writer); atUint32 strgSz = 4; for (const NameEntry& entry : m_nameEntries) - strgSz += entry.name.size() + 13; + strgSz += (atUint32)entry.name.size() + 13; atUint32 strgPad = ((strgSz + 63) & ~63) - strgSz; strgSz += strgPad; writer.writeUint32(strgSz); @@ -88,12 +88,12 @@ void PAK::write(Athena::io::IStreamWriter& writer) const writer.writeUint32(dataSz); writer.seek(36, Athena::Current); - writer.writeUint32(m_nameEntries.size()); + writer.writeUint32((atUint32)m_nameEntries.size()); for (const NameEntry& entry : m_nameEntries) entry.write(writer); writer.seek(strgPad, Athena::Current); - writer.writeUint32(m_entries.size()); + writer.writeUint32((atUint32)m_entries.size()); for (const Entry& entry : m_entries) { Entry copy = entry; @@ -125,8 +125,9 @@ std::unique_ptr PAK::Entry::getBuffer(const NOD::DiscBase::IPartition { atUint32 compSz; atUint32 decompSz; - } blocks[head.blockCount]; - strm->read(blocks, 8 * head.blockCount); + }; + std::unique_ptr blocks(new Block[head.blockCount]); + strm->read(blocks.get(), 8 * head.blockCount); atUint64 maxBlockSz = 0; atUint64 totalDecompSz = 0; diff --git a/DataSpec/DNAMP3/STRG.cpp b/DataSpec/DNAMP3/STRG.cpp index f1ab8d5d1..d721e2ab6 100644 --- a/DataSpec/DNAMP3/STRG.cpp +++ b/DataSpec/DNAMP3/STRG.cpp @@ -149,6 +149,7 @@ void STRG::write(Athena::io::IStreamWriter& writer) const bool STRG::readAngelScript(const AngelScript::asIScriptModule& in) { + return false; } void STRG::writeAngelScript(std::ofstream& out) const diff --git a/DataSpec/DNAMP3/STRG.hpp b/DataSpec/DNAMP3/STRG.hpp index bf74ad9fd..cc313b886 100644 --- a/DataSpec/DNAMP3/STRG.hpp +++ b/DataSpec/DNAMP3/STRG.hpp @@ -60,7 +60,7 @@ struct STRG : ISTRG, BigDNA #else return search->second->at(idx); #endif - return std::string(); + return HECL::SystemString(); } bool readAngelScript(const AngelScript::asIScriptModule& in); @@ -73,6 +73,18 @@ struct STRG : ISTRG, BigDNA strg->writeAngelScript(strgOut); return true; } + + static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath) + { + STRG strg; + HECL::Database::ASUniqueModule mod = HECL::Database::ASUniqueModule::CreateFromPath(inPath); + if (!mod) + return false; + strg.readAngelScript(mod); + Athena::io::FileWriter ws(outPath.getAbsolutePath()); + strg.write(ws); + return true; + } }; } diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index 17df43108..f21ac9fb5 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -74,6 +74,7 @@ void SpecBase::doExtract(HECL::Database::Project& project, const ExtractPassInfo bool SpecBase::canCook(const HECL::Database::Project& project, const CookTaskInfo& info) { + return false; } void SpecBase::doCook(const HECL::Database::Project& project, const CookTaskInfo& info) @@ -82,6 +83,7 @@ void SpecBase::doCook(const HECL::Database::Project& project, const CookTaskInfo bool SpecBase::canPackage(const HECL::Database::Project& project, const PackagePassInfo& info) { + return false; } void SpecBase::gatherDependencies(const HECL::Database::Project& project, const PackagePassInfo& info, diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index a52872b69..04b04e1a9 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "SpecBase.hpp" #include "DNAMP1/DNAMP1.hpp" @@ -100,7 +101,8 @@ struct SpecMP1 : SpecBase { rep.childOpts.emplace_back(); ExtractReport& childRep = rep.childOpts.back(); - childRep.name = item.first; + HECL::SystemStringView nameView(item.first); + childRep.name = nameView; childRep.desc = item.second->getLevelString(); } } @@ -149,7 +151,7 @@ struct SpecMP1 : SpecBase { HECL::SystemString lowerArg = arg; HECL::ToLower(lowerArg); - if (!lowerArg.compare(0, 3, "mp1")) + if (!lowerArg.compare(0, 3, _S("mp1"))) { doMP1 = true; size_t slashPos = arg.find(_S('/')); @@ -247,31 +249,38 @@ struct SpecMP1 : SpecBase bool checkFromProject(HECL::Database::Project& proj) { + return false; } bool readFromProject(HECL::Database::Project& proj) { + return false; } bool visitGameObjects(std::function) { + return false; } struct LevelSpec : public ILevelSpec { bool visitLevelObjects(std::function) { + return false; } struct AreaSpec : public IAreaSpec { bool visitAreaObjects(std::function) { + return false; } }; bool visitAreas(std::function) { + return false; } }; bool visitLevels(std::function) { + return false; } }; diff --git a/DataSpec/SpecMP2.cpp b/DataSpec/SpecMP2.cpp index f45e612e5..ce6c3967f 100644 --- a/DataSpec/SpecMP2.cpp +++ b/DataSpec/SpecMP2.cpp @@ -98,7 +98,8 @@ struct SpecMP2 : SpecBase { rep.childOpts.emplace_back(); ExtractReport& childRep = rep.childOpts.back(); - childRep.name = item.first; + HECL::SystemStringView nameView(item.first); + childRep.name = nameView; childRep.desc = item.second->getLevelString(); } } @@ -147,7 +148,7 @@ struct SpecMP2 : SpecBase { HECL::SystemString lowerArg = arg; HECL::ToLower(lowerArg); - if (!lowerArg.compare(0, 3, "mp2")) + if (!lowerArg.compare(0, 3, _S("mp2"))) { doMP2 = true; size_t slashPos = arg.find(_S('/')); @@ -245,31 +246,38 @@ struct SpecMP2 : SpecBase bool checkFromProject(HECL::Database::Project& proj) { + return false; } bool readFromProject(HECL::Database::Project& proj) { + return false; } bool visitGameObjects(std::function) { + return false; } struct LevelSpec : public ILevelSpec { bool visitLevelObjects(std::function) { + return false; } struct AreaSpec : public IAreaSpec { bool visitAreaObjects(std::function) { + return false; } }; bool visitAreas(std::function) { + return false; } }; bool visitLevels(std::function) { + return false; } }; diff --git a/DataSpec/SpecMP3.cpp b/DataSpec/SpecMP3.cpp index 0c13ac4d7..dc304a557 100644 --- a/DataSpec/SpecMP3.cpp +++ b/DataSpec/SpecMP3.cpp @@ -133,7 +133,8 @@ struct SpecMP3 : SpecBase { rep.childOpts.emplace_back(); ExtractReport& childRep = rep.childOpts.back(); - childRep.name = item.first; + HECL::SystemStringView nameView(item.first); + childRep.name = nameView; if (!item.first.compare("Worlds.pak")) continue; else if (!item.first.compare("Metroid6.pak")) @@ -191,7 +192,7 @@ struct SpecMP3 : SpecBase { HECL::SystemString lowerArg = arg; HECL::ToLower(lowerArg); - if (!lowerArg.compare(0, 3, "mp3")) + if (!lowerArg.compare(0, 3, _S("mp3"))) { doMP3 = true; size_t slashPos = arg.find(_S('/')); @@ -206,7 +207,7 @@ struct SpecMP3 : SpecBase { HECL::SystemString lowerArg = arg; HECL::ToLower(lowerArg); - if (!lowerArg.compare(0, 2, "fe")) + if (!lowerArg.compare(0, 2, _S("fe"))) { doMPTFE = true; size_t slashPos = arg.find(_S('/')); @@ -381,31 +382,38 @@ struct SpecMP3 : SpecBase bool checkFromProject(HECL::Database::Project& proj) { + return false; } bool readFromProject(HECL::Database::Project& proj) { + return false; } bool visitGameObjects(std::function) { + return false; } struct LevelSpec : public ILevelSpec { bool visitLevelObjects(std::function) { + return false; } struct AreaSpec : public IAreaSpec { bool visitAreaObjects(std::function) { + return false; } }; bool visitAreas(std::function) { + return false; } }; bool visitLevels(std::function) { + return false; } }; diff --git a/NODLib b/NODLib index edb846857..48e329879 160000 --- a/NODLib +++ b/NODLib @@ -1 +1 @@ -Subproject commit edb84685750cdf6d5d6ed5bd3801b2c31202468f +Subproject commit 48e329879776115803dda9423ab7001716db49e2 From 5deacef567cd295e78cbbabfde944a8e0b3a2272 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 22 Jul 2015 09:07:28 -1000 Subject: [PATCH 2/3] Updated NODLib --- NODLib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NODLib b/NODLib index 48e329879..9e7e0979b 160000 --- a/NODLib +++ b/NODLib @@ -1 +1 @@ -Subproject commit 48e329879776115803dda9423ab7001716db49e2 +Subproject commit 9e7e0979bd3fcdcd1930a477c96838f9d8418f70 From 1afc14159b1e37d6963bae248a120344596b9db1 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 22 Jul 2015 13:42:44 -0700 Subject: [PATCH 3/3] Remove exceptions --- src/RetroCommon.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/RetroCommon.cpp b/src/RetroCommon.cpp index a783d5c21..3edec5577 100644 --- a/src/RetroCommon.cpp +++ b/src/RetroCommon.cpp @@ -1,6 +1,5 @@ #include "RetroCommon.hpp" #include -#include #include struct CMPDBlock