mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fix some compiler warnings
This commit is contained in:
+4
-4
@@ -115,9 +115,9 @@ std::map<uint64_t, std::set<uint64_t>> GetAssetsInBSA(
|
||||
|
||||
namespace ba2 {
|
||||
struct Header {
|
||||
std::array<char, 4> typeId;
|
||||
std::array<char, 4> typeId{};
|
||||
uint32_t version{0};
|
||||
std::array<char, 4> archiveType;
|
||||
std::array<char, 4> archiveType{};
|
||||
uint32_t fileCount{0};
|
||||
uint64_t filePathsOffset{0};
|
||||
};
|
||||
@@ -176,7 +176,7 @@ std::map<uint64_t, std::set<uint64_t>> GetAssetsInBA2FromFilePaths(
|
||||
|
||||
// The file paths are prefixed by a two-byte length, and not null-terminated.
|
||||
for (size_t i = 0; i < header.fileCount; ++i) {
|
||||
uint16_t pathLength;
|
||||
uint16_t pathLength = 0;
|
||||
in.read(reinterpret_cast<char*>(&pathLength), sizeof(pathLength));
|
||||
|
||||
std::string filePath(pathLength, '\0');
|
||||
@@ -282,7 +282,7 @@ std::map<uint64_t, std::set<uint64_t>> GetAssetsInBethesdaArchive(
|
||||
std::ios::eofbit); // Causes ifstream::failure to be thrown if
|
||||
// a problem is encountered.
|
||||
|
||||
std::array<char, 4> typeId;
|
||||
std::array<char, 4> typeId{};
|
||||
in.read(typeId.data(), typeId.size());
|
||||
|
||||
if (typeId == BSA_TYPE_ID) {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
namespace loot::bsa {
|
||||
struct Header {
|
||||
std::array<char, 4> typeId; // Should always be "BSA\0"
|
||||
std::array<char, 4> typeId{}; // Should always be "BSA\0"
|
||||
uint32_t version{0}; // 103 (0x67) for TES4, 104 (0x68) for FO3, FONV, TES5,
|
||||
// 105
|
||||
// (0x69) for TES5SE.
|
||||
|
||||
+1
-66
@@ -50,73 +50,8 @@
|
||||
using std::filesystem::u8path;
|
||||
|
||||
namespace {
|
||||
using std::string_view_literals::operator""sv;
|
||||
using loot::GameType;
|
||||
|
||||
// The Microsoft Store installs Fallout 4 DLCs to directories outside of the
|
||||
// game's install path. These directories have fixed paths relative to the
|
||||
// game install path (renaming them causes the game launch to fail, or not
|
||||
// find the DLC files).
|
||||
constexpr std::string_view MS_FO4_AUTOMATRON_DATA_PATH =
|
||||
"../../Fallout 4- Automatron (PC)/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_CONTRAPTIONS_DATA_PATH =
|
||||
"../../Fallout 4- Contraptions Workshop (PC)/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_FAR_HARBOR_DATA_PATH =
|
||||
"../../Fallout 4- Far Harbor (PC)/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_TEXTURE_PACK_DATA_PATH =
|
||||
"../../Fallout 4- High Resolution Texture Pack/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_NUKA_WORLD_DATA_PATH =
|
||||
"../../Fallout 4- Nuka-World (PC)/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_VAULT_TEC_DATA_PATH =
|
||||
"../../Fallout 4- Vault-Tec Workshop (PC)/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_WASTELAND_DATA_PATH =
|
||||
"../../Fallout 4- Wasteland Workshop (PC)/Content/Data"sv;
|
||||
|
||||
bool IsMicrosoftStoreInstall(const GameType gameType,
|
||||
const std::filesystem::path& gamePath) {
|
||||
switch (gameType) {
|
||||
case GameType::tes3:
|
||||
case GameType::tes4:
|
||||
case GameType::fo3:
|
||||
case GameType::fonv:
|
||||
// tes3, tes4, fo3 and fonv install paths are localised, with the
|
||||
// appxmanifest.xml file sitting in the parent directory.
|
||||
return std::filesystem::exists(gamePath.parent_path() /
|
||||
"appxmanifest.xml");
|
||||
case GameType::tes5se:
|
||||
case GameType::fo4:
|
||||
case GameType::starfield:
|
||||
return std::filesystem::exists(gamePath / "appxmanifest.xml");
|
||||
case GameType::tes5:
|
||||
case GameType::tes5vr:
|
||||
case GameType::fo4vr:
|
||||
case GameType::openmw:
|
||||
return false;
|
||||
default:
|
||||
throw std::logic_error("Unrecognised game type");
|
||||
}
|
||||
}
|
||||
|
||||
std::filesystem::path GetUserDocumentsPath(
|
||||
const std::filesystem::path& gameLocalPath) {
|
||||
#ifdef _WIN32
|
||||
PWSTR path;
|
||||
|
||||
if (SHGetKnownFolderPath(FOLDERID_Documents, 0, NULL, &path) != S_OK)
|
||||
throw std::system_error(GetLastError(),
|
||||
std::system_category(),
|
||||
"Failed to get user Documents path.");
|
||||
|
||||
std::filesystem::path documentsPath(path);
|
||||
CoTaskMemFree(path);
|
||||
|
||||
return documentsPath;
|
||||
#else
|
||||
// Get the documents path relative to the game's local path.
|
||||
return gameLocalPath.parent_path().parent_path().parent_path() / "Documents";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::filesystem::path ResolvePluginPath(
|
||||
GameType gameType,
|
||||
const std::filesystem::path& dataPath,
|
||||
@@ -319,7 +254,7 @@ std::shared_ptr<const PluginInterface> Game::GetPlugin(
|
||||
std::vector<std::shared_ptr<const PluginInterface>> Game::GetLoadedPlugins()
|
||||
const {
|
||||
std::vector<std::shared_ptr<const PluginInterface>> interfacePointers;
|
||||
for (const auto plugin : cache_.GetPlugins()) {
|
||||
for (const auto& plugin : cache_.GetPlugins()) {
|
||||
interfacePointers.push_back(plugin);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
GameType GetType() const override;
|
||||
|
||||
std::vector<std::filesystem::path> GetAdditionalDataPaths() const;
|
||||
std::vector<std::filesystem::path> GetAdditionalDataPaths() const override;
|
||||
|
||||
void SetAdditionalDataPaths(
|
||||
const std::vector<std::filesystem::path>& additionalDataPaths) override;
|
||||
|
||||
+3
-2
@@ -207,14 +207,15 @@ void HandleEspluginError(unsigned int returnCode, std::string_view operation) {
|
||||
throw std::system_error(returnCode, esplugin_category(), err);
|
||||
}
|
||||
|
||||
template<typename ...Args>
|
||||
void HandleEspluginError(unsigned int returnCode,
|
||||
std::string_view message,
|
||||
std::string_view args...) {
|
||||
Args... args) {
|
||||
if (returnCode == ESP_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto operation = fmt::format(message, args);
|
||||
auto operation = fmt::format(message, args...);
|
||||
return HandleEspluginError(returnCode, operation);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -83,8 +83,8 @@ public:
|
||||
// Load ordering functions.
|
||||
size_t GetOverrideRecordCount() const override;
|
||||
|
||||
size_t GetAssetCount() const;
|
||||
bool DoAssetsOverlap(const PluginSortingInterface& plugin) const;
|
||||
size_t GetAssetCount() const override;
|
||||
bool DoAssetsOverlap(const PluginSortingInterface& plugin) const override;
|
||||
|
||||
// Validity checks.
|
||||
static bool IsValid(const GameType gameType,
|
||||
|
||||
@@ -461,8 +461,14 @@ std::string PathToString(const RawPluginGraph& graph,
|
||||
|
||||
class BidirVisitor {
|
||||
public:
|
||||
BidirVisitor() = default;
|
||||
BidirVisitor(const BidirVisitor&) = delete;
|
||||
BidirVisitor(BidirVisitor&&) = delete;
|
||||
virtual ~BidirVisitor() = default;
|
||||
|
||||
BidirVisitor& operator=(const BidirVisitor&) = delete;
|
||||
BidirVisitor& operator=(BidirVisitor&&) = delete;
|
||||
|
||||
virtual void VisitForwardVertex(const vertex_t& sourceVertex,
|
||||
const vertex_t& targetVertex) = 0;
|
||||
|
||||
@@ -479,15 +485,17 @@ public:
|
||||
const vertex_t& toVertex) :
|
||||
pathsCache_(&pathsCache), fromVertex_(fromVertex), toVertex_(toVertex) {}
|
||||
|
||||
void VisitForwardVertex(const vertex_t&, const vertex_t& targetVertex) {
|
||||
void VisitForwardVertex(const vertex_t&,
|
||||
const vertex_t& targetVertex) override {
|
||||
pathsCache_->CachePath(fromVertex_, targetVertex);
|
||||
}
|
||||
|
||||
void VisitReverseVertex(const vertex_t& sourceVertex, const vertex_t&) {
|
||||
void VisitReverseVertex(const vertex_t& sourceVertex,
|
||||
const vertex_t&) override {
|
||||
pathsCache_->CachePath(sourceVertex, toVertex_);
|
||||
}
|
||||
|
||||
void VisitIntersectionVertex(const vertex_t&) {}
|
||||
void VisitIntersectionVertex(const vertex_t&) override {}
|
||||
|
||||
protected:
|
||||
vertex_t GetFromVertex() const { return fromVertex_; }
|
||||
@@ -509,20 +517,20 @@ public:
|
||||
PathCacher(pathsCache, fromVertex, toVertex), graph_(&graph) {}
|
||||
|
||||
void VisitForwardVertex(const vertex_t& sourceVertex,
|
||||
const vertex_t& targetVertex) {
|
||||
const vertex_t& targetVertex) override {
|
||||
PathCacher::VisitForwardVertex(sourceVertex, targetVertex);
|
||||
|
||||
forwardParents.insert_or_assign(targetVertex, sourceVertex);
|
||||
}
|
||||
|
||||
void VisitReverseVertex(const vertex_t& sourceVertex,
|
||||
const vertex_t& targetVertex) {
|
||||
const vertex_t& targetVertex) override {
|
||||
PathCacher::VisitReverseVertex(sourceVertex, targetVertex);
|
||||
|
||||
reverseChildren.insert_or_assign(sourceVertex, targetVertex);
|
||||
}
|
||||
|
||||
void VisitIntersectionVertex(const vertex_t& intersectionVertex) {
|
||||
void VisitIntersectionVertex(const vertex_t& intersectionVertex) override {
|
||||
intersectionVertex_ = intersectionVertex;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user