|
|
@ -43,7 +43,7 @@ void BSAFile::fail(const std::string &msg)
|
|
|
|
BSAFile::Hash getHash(const std::string& name)
|
|
|
|
BSAFile::Hash getHash(const std::string& name)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BSAFile::Hash hash;
|
|
|
|
BSAFile::Hash hash;
|
|
|
|
unsigned l = (name.size() >> 1);
|
|
|
|
unsigned l = (static_cast<unsigned>(name.size()) >> 1);
|
|
|
|
unsigned sum, off, temp, i, n;
|
|
|
|
unsigned sum, off, temp, i, n;
|
|
|
|
|
|
|
|
|
|
|
|
for (sum = off = i = 0; i < l; i++) {
|
|
|
|
for (sum = off = i = 0; i < l; i++) {
|
|
|
@ -163,7 +163,7 @@ void BSAFile::readHeader()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FileStruct &fs = mFiles[i];
|
|
|
|
FileStruct &fs = mFiles[i];
|
|
|
|
fs.fileSize = offsets[i*2];
|
|
|
|
fs.fileSize = offsets[i*2];
|
|
|
|
fs.offset = offsets[i*2+1] + fileDataOffset;
|
|
|
|
fs.offset = static_cast<uint32_t>(offsets[i*2+1] + fileDataOffset);
|
|
|
|
auto namesOffset = offsets[2*filenum+i];
|
|
|
|
auto namesOffset = offsets[2*filenum+i];
|
|
|
|
fs.setNameInfos(namesOffset, &mStringBuf);
|
|
|
|
fs.setNameInfos(namesOffset, &mStringBuf);
|
|
|
|
fs.hash = hashes[i];
|
|
|
|
fs.hash = hashes[i];
|
|
|
@ -203,11 +203,11 @@ void Bsa::BSAFile::writeHeader()
|
|
|
|
uint32_t head[3];
|
|
|
|
uint32_t head[3];
|
|
|
|
head[0] = 0x100;
|
|
|
|
head[0] = 0x100;
|
|
|
|
auto fileDataOffset = mFiles.empty() ? 12 : mFiles.front().offset;
|
|
|
|
auto fileDataOffset = mFiles.empty() ? 12 : mFiles.front().offset;
|
|
|
|
head[1] = fileDataOffset - 12 - 8*mFiles.size();
|
|
|
|
head[1] = static_cast<uint32_t>(fileDataOffset - 12 - 8*mFiles.size());
|
|
|
|
|
|
|
|
|
|
|
|
output.seekp(0, std::ios_base::end);
|
|
|
|
output.seekp(0, std::ios_base::end);
|
|
|
|
|
|
|
|
|
|
|
|
head[2] = mFiles.size();
|
|
|
|
head[2] = static_cast<uint32_t>(mFiles.size());
|
|
|
|
output.seekp(0);
|
|
|
|
output.seekp(0);
|
|
|
|
output.write(reinterpret_cast<char*>(head), 12);
|
|
|
|
output.write(reinterpret_cast<char*>(head), 12);
|
|
|
|
|
|
|
|
|
|
|
@ -239,9 +239,9 @@ int BSAFile::getIndex(const char *str) const
|
|
|
|
if(it == mLookup.end())
|
|
|
|
if(it == mLookup.end())
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
int res = it->second;
|
|
|
|
size_t res = it->second;
|
|
|
|
assert(res >= 0 && (size_t)res < mFiles.size());
|
|
|
|
assert(res >= 0 && res < mFiles.size());
|
|
|
|
return res;
|
|
|
|
return static_cast<int>(res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Open an archive file.
|
|
|
|
/// Open an archive file.
|
|
|
@ -300,7 +300,7 @@ void Bsa::BSAFile::addFile(const std::string& filename, std::istream& file)
|
|
|
|
newFile.hash = getHash(filename);
|
|
|
|
newFile.hash = getHash(filename);
|
|
|
|
|
|
|
|
|
|
|
|
if(mFiles.empty())
|
|
|
|
if(mFiles.empty())
|
|
|
|
newFile.offset = newStartOfDataBuffer;
|
|
|
|
newFile.offset = static_cast<uint32_t>(newStartOfDataBuffer);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::vector<char> buffer;
|
|
|
|
std::vector<char> buffer;
|
|
|
|