Skip to content

Commit

Permalink
change otr version check to still track game versions if available (#346
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Archez authored Sep 26, 2023
1 parent e2545c0 commit 6b32658
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/resource/Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,24 +393,22 @@ void Archive::GenerateCrcMap() {
}

bool Archive::ProcessOtrVersion(HANDLE mpqHandle) {
// Skip when there are no valid hashes to check against
if (mValidHashes.empty()) {
return true;
}

auto t = LoadFileFromHandle("version", false, mpqHandle);
if (t != nullptr && t->IsLoaded) {
auto stream = std::make_shared<MemoryStream>(t->Buffer.data(), t->Buffer.size());
auto reader = std::make_shared<BinaryReader>(stream);
LUS::Endianness endianness = (LUS::Endianness)reader->ReadUByte();
reader->SetEndianness(endianness);
uint32_t version = reader->ReadUInt32();
if (mValidHashes.contains(version)) {
// Game version found so track it if it matches or there is nothing to match against
if (mValidHashes.empty() || mValidHashes.contains(version)) {
PushGameVersion(version);
return true;
}
}
return false;

// Allow the otr through if there are no valid hashes anyways
return mValidHashes.empty();
}

bool Archive::LoadMainMPQ(bool enableWriting, bool generateCrcMap) {
Expand Down

0 comments on commit 6b32658

Please sign in to comment.