handle RFF encryption like compression.
This allows simplifiying the code a lot by moving the decrypter to OpenDecompressor and handling it with generic code in the base class.
This commit is contained in:
parent
728bbd6327
commit
c27c8c232a
3 changed files with 28 additions and 33 deletions
|
|
@ -952,6 +952,24 @@ bool FileReader::OpenDecompressor(FileReader &parent, Size length, int method, b
|
|||
break;
|
||||
}
|
||||
|
||||
// While this could be msde a buffering reader it isn't worth the effort because only stock RFFs are encrypted and they do not contain large files.
|
||||
case METHOD_RFFCRYPT:
|
||||
{
|
||||
auto idec = new MemoryArrayReader<FileData>;
|
||||
fr = idec;
|
||||
auto& buffer = idec->GetArray();
|
||||
auto bufr = (uint8_t*)buffer.allocate(length);
|
||||
p->Read(bufr, length);
|
||||
|
||||
Size cryptlen = std::min<Size>(length, 256);
|
||||
|
||||
for (Size i = 0; i < cryptlen; ++i)
|
||||
{
|
||||
bufr[i] ^= i >> 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -974,13 +992,13 @@ bool FileReader::OpenDecompressor(FileReader &parent, Size length, int method, b
|
|||
mReader = new BufferingReader(fr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (fr) delete fr;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FCompressedBuffer::Decompress(char* destbuffer)
|
||||
|
|
@ -1001,3 +1019,4 @@ bool FCompressedBuffer::Decompress(char* destbuffer)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue