format: reformat project

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov
2024-08-03 19:53:48 +03:00
committed by Pugemon
parent 736cd175d5
commit bbf33e8e4d
202 changed files with 7389 additions and 5609 deletions
+34 -16
View File
@@ -1,10 +1,10 @@
#include "PacksManager.hpp"
#include "../util/listutil.hpp"
#include <queue>
#include <sstream>
#include "../util/listutil.hpp"
PacksManager::PacksManager() = default;
void PacksManager::setSources(std::vector<fs::path> sources) {
@@ -13,7 +13,7 @@ void PacksManager::setSources(std::vector<fs::path> sources) {
void PacksManager::scan() {
packs.clear();
std::vector<ContentPack> packsList;
for (auto& folder : sources) {
ContentPack::scanFolder(folder, packsList);
@@ -35,7 +35,9 @@ std::vector<std::string> PacksManager::getAllNames() const {
return names;
}
std::vector<ContentPack> PacksManager::getAll(const std::vector<std::string>& names) const {
std::vector<ContentPack> PacksManager::getAll(
const std::vector<std::string>& names
) const {
std::vector<ContentPack> packsList;
for (auto& name : names) {
auto found = packs.find(name);
@@ -47,7 +49,9 @@ std::vector<ContentPack> PacksManager::getAll(const std::vector<std::string>& na
return packsList;
}
static contentpack_error on_circular_dependency(std::queue<const ContentPack*>& queue) {
static contentpack_error on_circular_dependency(
std::queue<const ContentPack*>& queue
) {
const ContentPack* lastPack = queue.back();
// circular dependency
std::stringstream ss;
@@ -66,10 +70,12 @@ static contentpack_error on_circular_dependency(std::queue<const ContentPack*>&
/// @param allNames all already done or enqueued packs
/// @param added packs with all dependencies resolved
/// @param queue current pass queue
/// @param resolveWeaks make weak dependencies resolved if found but not added to queue
/// @return true if all dependencies are already added or not found (optional/weak)
/// @param resolveWeaks make weak dependencies resolved if found but not added
/// to queue
/// @return true if all dependencies are already added or not found
/// (optional/weak)
/// @throws contentpack_error if required dependency is not found
static bool resolve_dependencies (
static bool resolve_dependencies(
const ContentPack* pack,
const std::unordered_map<std::string, ContentPack>& packs,
std::vector<std::string>& allNames,
@@ -85,7 +91,9 @@ static bool resolve_dependencies (
auto found = packs.find(dep.id);
bool exists = found != packs.end();
if (!exists && dep.level == DependencyLevel::required) {
throw contentpack_error(dep.id, fs::path(), "dependency of '"+pack->id+"'");
throw contentpack_error(
dep.id, fs::path(), "dependency of '" + pack->id + "'"
);
}
if (!exists) {
// ignored for optional or weak dependencies
@@ -93,11 +101,13 @@ static bool resolve_dependencies (
}
if (resolveWeaks && dep.level == DependencyLevel::weak) {
// dependency pack is found but not added yet
// resolveWeaks is used on second iteration, so it's will not be added
// resolveWeaks is used on second iteration, so it's will not be
// added
continue;
}
if (!util::contains(allNames, dep.id) && dep.level != DependencyLevel::weak) {
if (!util::contains(allNames, dep.id) &&
dep.level != DependencyLevel::weak) {
allNames.push_back(dep.id);
queue.push(&found->second);
}
@@ -106,7 +116,9 @@ static bool resolve_dependencies (
return satisfied;
}
std::vector<std::string> PacksManager::assembly(const std::vector<std::string>& names) const {
std::vector<std::string> PacksManager::assembly(
const std::vector<std::string>& names
) const {
std::vector<std::string> allNames = names;
std::vector<std::string> added;
std::queue<const ContentPack*> queue;
@@ -126,10 +138,14 @@ std::vector<std::string> PacksManager::assembly(const std::vector<std::string>&
while (!queue.empty()) {
auto* pack = queue.front();
queue.pop();
if (resolve_dependencies(pack, packs, allNames, added, queue, resolveWeaks)) {
if (resolve_dependencies(
pack, packs, allNames, added, queue, resolveWeaks
)) {
if (util::contains(added, pack->id)) {
throw contentpack_error(pack->id, pack->folder, "pack duplication");
throw contentpack_error(
pack->id, pack->folder, "pack duplication"
);
}
added.push_back(pack->id);
addedInIteration++;
@@ -148,7 +164,9 @@ std::vector<std::string> PacksManager::assembly(const std::vector<std::string>&
return added;
}
std::vector<std::string> PacksManager::getNames(const std::vector<ContentPack>& packs) {
std::vector<std::string> PacksManager::getNames(
const std::vector<ContentPack>& packs
) {
std::vector<std::string> result;
for (const auto& pack : packs) {
result.push_back(pack.id);