Decompile fn_04021 (myGPack::CGPakUpdate::CopyEntry)
Batch #15370 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_04021 myGPack::CGPakUpdate::CopyEntry: logic confirmed by peer review Peer-reviewed-by: alisonrag, gordaoprogramas, Toshiro Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
parent
933ca4f5ac
commit
6ebff7479b
1 changed files with 19 additions and 21 deletions
|
|
@ -733,32 +733,30 @@ namespace myGPack {
|
|||
bool CGPakUpdate::CopyEntry(const PakName& name) {
|
||||
PakEntry entry;
|
||||
|
||||
for (CGPakRead* source : this->m_sources) {
|
||||
if (!source->Find(name, &entry)) {
|
||||
continue;
|
||||
for (auto& source : this->m_sources) {
|
||||
if (source->Find(name, &entry) == true) {
|
||||
std::vector<std::uint8_t> buffer(entry.compressedSize);
|
||||
if (!source->ReadEntry(&entry, buffer.data())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::uint64_t offset = this->Allocate(entry.alignedSize);
|
||||
if (!this->m_output.Write(offset, buffer.data(), entry.alignedSize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
entry.dataOffset = offset - kPakHeaderSize;
|
||||
|
||||
auto found = std::lower_bound(this->m_entries.begin(), this->m_entries.end(), entry.name,
|
||||
[](const PakEntry& candidate, const PakName& key) { return candidate.name < key; });
|
||||
if (found != this->m_entries.end() && found->name == entry.name) {
|
||||
*found = entry;
|
||||
} else {
|
||||
this->m_added.push_back(entry);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::uint8_t> buffer(entry.compressedSize);
|
||||
if (!source->ReadEntry(&entry, buffer.data())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::uint64_t offset = this->Allocate(entry.alignedSize);
|
||||
if (!this->m_output.Write(offset, buffer.data(), entry.alignedSize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
entry.dataOffset = offset - kPakHeaderSize;
|
||||
|
||||
auto found = std::lower_bound(this->m_entries.begin(), this->m_entries.end(), entry.name,
|
||||
[](const PakEntry& candidate, const PakName& key) { return candidate.name < key; });
|
||||
if (found != this->m_entries.end() && found->name == entry.name) {
|
||||
*found = entry;
|
||||
} else {
|
||||
this->m_added.push_back(entry);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue