diff --git a/include/resource_append.h b/include/resource_append.h index 593d291..453e9ce 100644 --- a/include/resource_append.h +++ b/include/resource_append.h @@ -34,6 +34,10 @@ public: private: bool Combine(const std::string &folderPath); bool ScanResources(const std::string &resourcePath, const std::string &outputPath); + bool ScanSubResources(const FileEntry entry, const std::string &resourcePath, + const std::string &outputPath); + bool ScanSubLimitkeyResources(const FileEntry entry, const std::string &resourcePath, + const std::string &outputPath); bool ScanIegalResources(const std::string &resourcePath, const std::string &outputPath); bool ScanLimitKey(const std::unique_ptr &entry, const std::string &limitKey, const std::string outputPath); diff --git a/src/increment_list.cpp b/src/increment_list.cpp index 9c4dd4f..839b104 100644 --- a/src/increment_list.cpp +++ b/src/increment_list.cpp @@ -101,9 +101,8 @@ int32_t IncrementList::GetPriority(const string &filePath) const bool IncrementList::ParseSegment(const string &filePath, vector &segments) const { - for (const auto &it : FileEntry::FilePath(filePath).GetSegments()) { - segments.push_back(it); - } + vector segs = FileEntry::FilePath(filePath).GetSegments(); + copy(segs.begin(), segs.end(), back_inserter(segments)); if (segments.size() >= (SEG_RESOURCE + 1) && segments[SEG_RESOURCE] != RESOURCES_DIR) { cerr << "Error: '" << filePath << "' don't contain '" << RESOURCES_DIR << "'" << endl; diff --git a/src/reference_parser.cpp b/src/reference_parser.cpp index 68ffb2a..d3f17db 100644 --- a/src/reference_parser.cpp +++ b/src/reference_parser.cpp @@ -298,8 +298,6 @@ bool ReferenceParser::ParseRefImpl(string &key, const map &refs int32_t id = idWorker_.GetId(ref.second, name); if (isSystem) { id = idWorker_.GetSystemId(ref.second, name); - } else { - id = idWorker_.GetId(ref.second, name); } if (id < 0) { cerr << "Error: ref '" << key << "' don't be defined." << endl; diff --git a/src/resource_append.cpp b/src/resource_append.cpp index 88f3771..8a066a4 100644 --- a/src/resource_append.cpp +++ b/src/resource_append.cpp @@ -135,6 +135,11 @@ bool ResourceAppend::ScanResources(const string &resourcePath, const string &out return ScanSingleFile(resourcePath, outputPath); } + return ScanSubResources(entry, resourcePath, outputPath); +} + +bool ResourceAppend::ScanSubResources(const FileEntry entry, const string &resourcePath, const string &outputPath) +{ vector keyParams; if (KeyParser::Parse(entry.GetFilePath().GetFilename(), keyParams)) { for (const auto &child : entry.GetChilds()) { @@ -152,6 +157,12 @@ bool ResourceAppend::ScanResources(const string &resourcePath, const string &out return ScanIegalResources(resourcePath, outputPath); } + return ScanSubLimitkeyResources(entry, resourcePath, outputPath); +} + +bool ResourceAppend::ScanSubLimitkeyResources(const FileEntry entry, const string &resourcePath, + const string &outputPath) +{ for (const auto &child : entry.GetChilds()) { string limitKey = child->GetFilePath().GetFilename(); if (ResourceUtil::IsIgnoreFile(limitKey, child->IsFile())) { @@ -526,6 +537,10 @@ bool ResourceAppend::LoadResourceItemFromMem(const char buffer[], int32_t length return false; } + if (!ResourceUtil::FileExist(filePathStr)) { + continue; + } + if (!ResourceUtil::CopyFleInner(filePathStr, outPath.Append(data).GetPath())) { return false; } diff --git a/src/resource_pack.cpp b/src/resource_pack.cpp index 6fa33e9..54d4e08 100644 --- a/src/resource_pack.cpp +++ b/src/resource_pack.cpp @@ -92,14 +92,14 @@ uint32_t ResourcePack::InitModule() }); if (it == moduleNames.end()) { string buffer(" "); - for_each(moduleNames.begin(), moduleNames.end(), [&buffer](auto &iter) { + for_each(moduleNames.begin(), moduleNames.end(), [&buffer](const auto &iter) { buffer.append(" " + iter + " "); }); cerr << "Error: module name '" << moduleName_ << "' not in [" << buffer << "]" << endl; return RESTOOL_ERROR; } - int32_t startId = ((it - moduleNames.begin()) + 1) * 0x01000000; + startId = ((it - moduleNames.begin()) + 1) * 0x01000000; if (startId >= 0x07000000) { startId = startId + 0x01000000; }