mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 01:15:33 +00:00
Merge pull request #2719 from Capostrophic/capofixes
Fixes of my mistakes
This commit is contained in:
commit
7096ecdcf2
3 changed files with 18 additions and 8 deletions
|
@ -266,7 +266,7 @@ namespace
|
|||
MOCK_CONST_METHOD0(numRecords, std::size_t ());
|
||||
MOCK_CONST_METHOD1(getRoot, Nif::Record* (std::size_t));
|
||||
MOCK_CONST_METHOD0(numRoots, std::size_t ());
|
||||
MOCK_CONST_METHOD1(getString, std::string (std::size_t));
|
||||
MOCK_CONST_METHOD1(getString, std::string (uint32_t));
|
||||
MOCK_METHOD1(setUseSkinning, void (bool));
|
||||
MOCK_CONST_METHOD0(getUseSkinning, bool ());
|
||||
MOCK_CONST_METHOD0(getFilename, std::string ());
|
||||
|
|
|
@ -422,7 +422,8 @@ void CompressedBSAFile::convertCompressedSizesToUncompressed()
|
|||
std::uint64_t CompressedBSAFile::generateHash(std::string stem, std::string extension) const
|
||||
{
|
||||
size_t len = stem.length();
|
||||
if (len == 0) return 0;
|
||||
if (len == 0)
|
||||
return 0;
|
||||
std::uint64_t hash = 0;
|
||||
unsigned int hash2 = 0;
|
||||
Misc::StringUtils::lowerCaseInPlace(stem);
|
||||
|
@ -434,12 +435,19 @@ std::uint64_t CompressedBSAFile::generateHash(std::string stem, std::string exte
|
|||
for (const char &c : extension)
|
||||
hash = hash * 0x1003f + c;
|
||||
}
|
||||
for (size_t i = 1; i < len-2 && len > 3; i++)
|
||||
hash2 = hash2 * 0x1003f + stem[i];
|
||||
if (len >= 4)
|
||||
{
|
||||
for (size_t i = 1; i < len-2; i++)
|
||||
hash2 = hash2 * 0x1003f + stem[i];
|
||||
}
|
||||
hash = (hash + hash2) << 32;
|
||||
hash2 = (stem[0] << 24) | (len << 16);
|
||||
if (len >= 3) hash2 |= stem[len-2] << 8;
|
||||
if (len >= 2) hash2 |= stem[len-1];
|
||||
if (len >= 2)
|
||||
{
|
||||
if (len >= 3)
|
||||
hash2 |= stem[len-2] << 8;
|
||||
hash2 |= stem[len-1];
|
||||
}
|
||||
if (!extension.empty())
|
||||
{
|
||||
if (extension == ".kf") hash2 |= 0x80;
|
||||
|
|
|
@ -26,7 +26,7 @@ struct File
|
|||
|
||||
virtual size_t numRoots() const = 0;
|
||||
|
||||
virtual std::string getString(size_t index) const = 0;
|
||||
virtual std::string getString(uint32_t index) const = 0;
|
||||
|
||||
virtual void setUseSkinning(bool skinning) = 0;
|
||||
|
||||
|
@ -129,8 +129,10 @@ public:
|
|||
size_t numRoots() const override { return roots.size(); }
|
||||
|
||||
/// Get a given string from the file's string table
|
||||
std::string getString(size_t index) const override
|
||||
std::string getString(uint32_t index) const override
|
||||
{
|
||||
if (index == std::numeric_limits<uint32_t>::max())
|
||||
return std::string();
|
||||
return strings.at(index);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue