Convert BsaVersion to enum class

fix-osga-rotate-wildly
elsid 11 months ago
parent df077a2524
commit cc9f9b53ba
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -329,17 +329,19 @@ int main(int argc, char** argv)
switch (bsaVersion)
{
case Bsa::BSAVER_COMPRESSED:
case Bsa::BsaVersion::Unknown:
break;
case Bsa::BsaVersion::Uncompressed:
return call<Bsa::BSAFile>(info);
case Bsa::BsaVersion::Compressed:
return call<Bsa::CompressedBSAFile>(info);
case Bsa::BSAVER_BA2_GNRL:
case Bsa::BsaVersion::BA2GNRL:
return call<Bsa::BA2GNRLFile>(info);
case Bsa::BSAVER_BA2_DX10:
case Bsa::BsaVersion::BA2DX10:
return call<Bsa::BA2DX10File>(info);
case Bsa::BSAVER_UNCOMPRESSED:
return call<Bsa::BSAFile>(info);
default:
throw std::runtime_error("Unrecognised BSA archive");
}
throw std::runtime_error("Unrecognised BSA archive");
}
catch (std::exception& e)
{

@ -819,7 +819,7 @@ void Launcher::DataFilesPage::addArchivesFromDir(const QString& path)
for (const auto& fileinfo : dir.entryInfoList(archiveFilter))
{
const auto absPath = fileinfo.absoluteFilePath();
if (Bsa::BSAFile::detectVersion(Files::pathFromQString(absPath)) == Bsa::BSAVER_UNKNOWN)
if (Bsa::BSAFile::detectVersion(Files::pathFromQString(absPath)) == Bsa::BsaVersion::Unknown)
continue;
const auto fileName = fileinfo.fileName();

@ -335,7 +335,7 @@ BsaVersion Bsa::BSAFile::detectVersion(const std::filesystem::path& filePath)
if (fsize < 12)
{
return BSAVER_UNKNOWN;
return BsaVersion::Unknown;
}
// Get essential header numbers
@ -345,23 +345,23 @@ BsaVersion Bsa::BSAFile::detectVersion(const std::filesystem::path& filePath)
input.read(reinterpret_cast<char*>(head), 12);
if (head[0] == static_cast<uint32_t>(BSAVER_UNCOMPRESSED))
if (head[0] == static_cast<uint32_t>(BsaVersion::Uncompressed))
{
return BSAVER_UNCOMPRESSED;
return BsaVersion::Uncompressed;
}
if (head[0] == static_cast<uint32_t>(BSAVER_COMPRESSED) || head[0] == ESM::fourCC("BTDX"))
if (head[0] == static_cast<uint32_t>(BsaVersion::Compressed) || head[0] == ESM::fourCC("BTDX"))
{
if (head[1] == static_cast<uint32_t>(0x01))
{
if (head[2] == ESM::fourCC("GNRL"))
return BSAVER_BA2_GNRL;
return BsaVersion::BA2GNRL;
if (head[2] == ESM::fourCC("DX10"))
return BSAVER_BA2_DX10;
return BSAVER_UNKNOWN;
return BsaVersion::BA2DX10;
return BsaVersion::Unknown;
}
return BSAVER_COMPRESSED;
return BsaVersion::Compressed;
}
return BSAVER_UNKNOWN;
return BsaVersion::Unknown;
}

@ -35,13 +35,13 @@
namespace Bsa
{
enum BsaVersion
enum class BsaVersion : std::uint32_t
{
BSAVER_UNKNOWN = 0x0,
BSAVER_UNCOMPRESSED = 0x100,
BSAVER_COMPRESSED = 0x415342, // B, S, A,
BSAVER_BA2_GNRL, // used by FO4, BSA which contains files
BSAVER_BA2_DX10 // used by FO4, BSA which contains textures
Unknown = 0x0,
Uncompressed = 0x100,
Compressed = 0x415342, // B, S, A,
BA2GNRL, // used by FO4, BSA which contains files
BA2DX10 // used by FO4, BSA which contains textures
};
/**

@ -70,7 +70,7 @@ namespace Bsa
input.read(reinterpret_cast<char*>(&mHeader), sizeof(mHeader));
if (mHeader.mFormat != BSAVER_COMPRESSED) // BSA
if (mHeader.mFormat != static_cast<std::uint32_t>(BsaVersion::Compressed)) // BSA
fail("Unrecognized compressed BSA format");
if (mHeader.mVersion != Version_TES4 && mHeader.mVersion != Version_FO3 && mHeader.mVersion != Version_SSE)
fail("Unrecognized compressed BSA version");

@ -79,15 +79,15 @@ namespace VFS
{
switch (Bsa::BSAFile::detectVersion(path))
{
case Bsa::BSAVER_UNKNOWN:
case Bsa::BsaVersion::Unknown:
break;
case Bsa::BSAVER_UNCOMPRESSED:
case Bsa::BsaVersion::Uncompressed:
return std::make_unique<BsaArchive<Bsa::BSAFile>>(path);
case Bsa::BSAVER_COMPRESSED:
case Bsa::BsaVersion::Compressed:
return std::make_unique<BsaArchive<Bsa::CompressedBSAFile>>(path);
case Bsa::BSAVER_BA2_GNRL:
case Bsa::BsaVersion::BA2GNRL:
return std::make_unique<BsaArchive<Bsa::BA2GNRLFile>>(path);
case Bsa::BSAVER_BA2_DX10:
case Bsa::BsaVersion::BA2DX10:
return std::make_unique<BsaArchive<Bsa::BA2DX10File>>(path);
}

Loading…
Cancel
Save