Reformat code with clang format

This commit is contained in:
Clang Format
2023-11-19 15:28:38 +01:00
committed by Jan
parent 22e17272fd
commit 6b4f5d94a8
1099 changed files with 16763 additions and 18076 deletions

View File

@ -1,10 +1,10 @@
#pragma once
#include <exception>
#include "Math/Vector.h"
#include "Utils/ClassUtils.h"
#include "Obj/Gdt/GdtEntry.h"
#include "Utils/ClassUtils.h"
#include <exception>
class GdtReadingException : public std::exception
{

View File

@ -1,15 +1,15 @@
#pragma once
#include <unordered_map>
#include <typeindex>
#include <type_traits>
#include "IGdtQueryable.h"
#include "IZoneAssetLoaderState.h"
#include "Obj/Gdt/Gdt.h"
#include "SearchPath/ISearchPath.h"
#include "Zone/Zone.h"
#include <type_traits>
#include <typeindex>
#include <unordered_map>
class AssetLoadingContext final : public IGdtQueryable
{
std::unordered_map<std::string, std::unordered_map<std::string, GdtEntry*>> m_entries_by_gdf_and_by_name;
@ -26,14 +26,13 @@ public:
AssetLoadingContext(Zone* zone, ISearchPath* rawSearchPath, std::vector<Gdt*> gdtFiles);
GdtEntry* GetGdtEntryByGdfAndName(const std::string& gdfName, const std::string& entryName) override;
template<typename T>
T* GetZoneAssetLoaderState()
template<typename T> T* GetZoneAssetLoaderState()
{
static_assert(std::is_base_of_v<IZoneAssetLoaderState, T>, "T must inherit IZoneAssetLoaderState");
// T must also have a public default constructor
const auto foundEntry = m_zone_asset_loader_states.find(typeid(T));
if(foundEntry != m_zone_asset_loader_states.end())
if (foundEntry != m_zone_asset_loader_states.end())
return dynamic_cast<T*>(foundEntry->second.get());
auto newState = std::make_unique<T>();

View File

@ -1,10 +1,11 @@
#include "AssetLoadingManager.h"
#include <iostream>
AssetLoadingManager::AssetLoadingManager(const std::map<asset_type_t, std::unique_ptr<IAssetLoader>>& assetLoadersByType, AssetLoadingContext& context):
m_asset_loaders_by_type(assetLoadersByType),
m_context(context),
m_last_dependency_loaded(nullptr)
AssetLoadingManager::AssetLoadingManager(const std::map<asset_type_t, std::unique_ptr<IAssetLoader>>& assetLoadersByType, AssetLoadingContext& context)
: m_asset_loaders_by_type(assetLoadersByType),
m_context(context),
m_last_dependency_loaded(nullptr)
{
}
@ -18,20 +19,30 @@ AssetLoadingContext* AssetLoadingManager::GetAssetLoadingContext() const
return &m_context;
}
XAssetInfoGeneric* AssetLoadingManager::AddAsset(const asset_type_t assetType, const std::string& assetName, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings,
Zone* zone)
XAssetInfoGeneric* AssetLoadingManager::AddAsset(const asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone)
{
m_last_dependency_loaded = m_context.m_zone->m_pools->AddAsset(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), zone);
if (m_last_dependency_loaded == nullptr)
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << assetName << "\"" << std::endl;
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << assetName << "\""
<< std::endl;
return m_last_dependency_loaded;
}
XAssetInfoGeneric* AssetLoadingManager::AddAsset(const asset_type_t assetType, const std::string& assetName, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings)
XAssetInfoGeneric* AssetLoadingManager::AddAsset(const asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings)
{
m_last_dependency_loaded = m_context.m_zone->m_pools->AddAsset(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings));
if (m_last_dependency_loaded == nullptr)
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << assetName << "\"" << std::endl;
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << assetName << "\""
<< std::endl;
return m_last_dependency_loaded;
}
@ -54,19 +65,26 @@ XAssetInfoGeneric* AssetLoadingManager::LoadIgnoredDependency(const asset_type_t
if (existingAsset)
{
std::vector<XAssetInfoGeneric*> dependencies;
AddAsset(existingAsset->m_type, existingAsset->m_name, existingAsset->m_ptr, std::vector<XAssetInfoGeneric*>(), std::vector<scr_string_t>(), existingAsset->m_zone);
AddAsset(existingAsset->m_type,
existingAsset->m_name,
existingAsset->m_ptr,
std::vector<XAssetInfoGeneric*>(),
std::vector<scr_string_t>(),
existingAsset->m_zone);
auto* lastDependency = m_last_dependency_loaded;
m_last_dependency_loaded = nullptr;
return lastDependency;
}
std::cout << "Failed to create empty asset \"" << assetName << "\" for type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"" << std::endl;
std::cout << "Failed to create empty asset \"" << assetName << "\" for type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\""
<< std::endl;
return nullptr;
}
XAssetInfoGeneric* AssetLoadingManager::LoadAssetDependency(const asset_type_t assetType, const std::string& assetName, IAssetLoader* loader)
{
if (loader->CanLoadFromGdt() && !m_context.m_gdt_files.empty() && loader->LoadFromGdt(assetName, &m_context, m_context.m_zone->GetMemory(), this, m_context.m_zone))
if (loader->CanLoadFromGdt() && !m_context.m_gdt_files.empty()
&& loader->LoadFromGdt(assetName, &m_context, m_context.m_zone->GetMemory(), this, m_context.m_zone))
{
auto* lastDependency = m_last_dependency_loaded;
m_last_dependency_loaded = nullptr;
@ -98,10 +116,15 @@ XAssetInfoGeneric* AssetLoadingManager::LoadAssetDependency(const asset_type_t a
// Make sure any used script string is available in the created zone
// The replacement of the scr_string_t values will be done upon writing
for(const auto scrString : existingAsset->m_used_script_strings)
for (const auto scrString : existingAsset->m_used_script_strings)
m_context.m_zone->m_script_strings.AddOrGetScriptString(existingAsset->m_zone->m_script_strings.CValue(scrString));
AddAsset(existingAsset->m_type, existingAsset->m_name, existingAsset->m_ptr, std::move(dependencies), existingAsset->m_used_script_strings, existingAsset->m_zone);
AddAsset(existingAsset->m_type,
existingAsset->m_name,
existingAsset->m_ptr,
std::move(dependencies),
existingAsset->m_used_script_strings,
existingAsset->m_zone);
auto* lastDependency = m_last_dependency_loaded;
m_last_dependency_loaded = nullptr;
return lastDependency;

View File

@ -1,10 +1,10 @@
#pragma once
#include <map>
#include "AssetLoadingContext.h"
#include "IAssetLoader.h"
#include "IAssetLoadingManager.h"
#include <map>
class AssetLoadingManager final : public IAssetLoadingManager
{
const std::map<asset_type_t, std::unique_ptr<IAssetLoader>>& m_asset_loaders_by_type;
@ -14,7 +14,12 @@ class AssetLoadingManager final : public IAssetLoadingManager
XAssetInfoGeneric* LoadIgnoredDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader);
XAssetInfoGeneric* LoadAssetDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader);
XAssetInfoGeneric* AddAsset(asset_type_t assetType, const std::string& assetName, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone);
XAssetInfoGeneric* AddAsset(asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone);
public:
AssetLoadingManager(const std::map<asset_type_t, std::unique_ptr<IAssetLoader>>& assetLoadersByType, AssetLoadingContext& context);
@ -23,6 +28,10 @@ public:
_NODISCARD AssetLoadingContext* GetAssetLoadingContext() const override;
XAssetInfoGeneric* AddAsset(asset_type_t assetType, const std::string& assetName, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override;
XAssetInfoGeneric* AddAsset(asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings) override;
XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) override;
};

View File

@ -2,8 +2,7 @@
#include "IAssetLoader.h"
#include "Pool/GlobalAssetPool.h"
template<typename T>
class BasicAssetLoaderWithoutType : public IAssetLoader
template<typename T> class BasicAssetLoaderWithoutType : public IAssetLoader
{
public:
_NODISCARD XAssetInfoGeneric* LoadFromGlobalAssetPools(const std::string& assetName) const override
@ -12,8 +11,7 @@ public:
}
};
template<asset_type_t AssetType, typename T>
class BasicAssetLoader : public BasicAssetLoaderWithoutType<T>
template<asset_type_t AssetType, typename T> class BasicAssetLoader : public BasicAssetLoaderWithoutType<T>
{
public:
_NODISCARD asset_type_t GetHandlingAssetType() const override

View File

@ -1,12 +1,12 @@
#pragma once
#include <string>
#include "Utils/ClassUtils.h"
#include "SearchPath/ISearchPath.h"
#include "IAssetLoadingManager.h"
#include "IGdtQueryable.h"
#include "SearchPath/ISearchPath.h"
#include "Utils/ClassUtils.h"
#include "Zone/ZoneTypes.h"
#include <string>
class IAssetLoader
{
public:

View File

@ -1,10 +1,10 @@
#pragma once
#include <string>
#include "AssetLoadingContext.h"
#include "Pool/XAssetInfo.h"
#include "Zone/ZoneTypes.h"
#include "Utils/ClassUtils.h"
#include "Zone/ZoneTypes.h"
#include <string>
class IAssetLoadingManager
{
@ -18,10 +18,16 @@ public:
_NODISCARD virtual AssetLoadingContext* GetAssetLoadingContext() const = 0;
virtual XAssetInfoGeneric* AddAsset(asset_type_t assetType, const std::string& assetName, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) = 0;
virtual XAssetInfoGeneric* AddAsset(asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings) = 0;
XAssetInfoGeneric* AddAsset(const asset_type_t assetType, const std::string& assetName, void* asset)
{
return AddAsset(assetType, assetName, asset, std::vector<XAssetInfoGeneric*>(), std::vector<scr_string_t>());
}
virtual XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) = 0;
};

View File

@ -1,8 +1,8 @@
#pragma once
#include <string>
#include "Obj/Gdt/GdtEntry.h"
#include <string>
class IGdtQueryable
{
public:

View File

@ -2,9 +2,9 @@
#include "Parsing/Impl/AbstractParser.h"
#include "Parsing/Impl/ParserSingleInputStream.h"
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
#include "Parsing/Simple/SimpleLexer.h"
#include "Parsing/Simple/SimpleParserValue.h"
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
enum class SndCurveParserStatus
{
@ -36,7 +36,7 @@ public:
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Keyword("SNDCURVE")
create.Keyword("SNDCURVE"),
});
}
@ -56,7 +56,7 @@ public:
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Integer().Capture(CAPTURE_KNOT_COUNT)
create.Integer().Capture(CAPTURE_KNOT_COUNT),
});
}
@ -84,15 +84,19 @@ public:
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Or({
create.FloatingPoint(),
create.Integer()
}).Capture(CAPTURE_X),
create
.Or({
create.FloatingPoint(),
create.Integer(),
})
.Capture(CAPTURE_X),
create.Or({
create.FloatingPoint(),
create.Integer()
}).Capture(CAPTURE_Y),
create
.Or({
create.FloatingPoint(),
create.Integer(),
})
.Capture(CAPTURE_Y),
});
}
@ -135,31 +139,28 @@ protected:
switch (m_state->m_status)
{
case SndCurveParserStatus::EXPECT_MAGIC:
{
static std::vector<sequence_t*> expectMagicSequences
{
new SndCurveMagicSequence()
};
return expectMagicSequences;
}
{
static std::vector<sequence_t*> expectMagicSequences{
new SndCurveMagicSequence(),
};
return expectMagicSequences;
}
case SndCurveParserStatus::EXPECT_KNOT_COUNT:
{
static std::vector<sequence_t*> expectKnotCountSequences
{
new SndCurveKnotCountSequence()
};
return expectKnotCountSequences;
}
{
static std::vector<sequence_t*> expectKnotCountSequences{
new SndCurveKnotCountSequence(),
};
return expectKnotCountSequences;
}
case SndCurveParserStatus::KNOTS:
{
static std::vector<sequence_t*> knotsSequences
{
new SndCurveKnotSequence()
};
return knotsSequences;
}
{
static std::vector<sequence_t*> knotsSequences{
new SndCurveKnotSequence(),
};
return knotsSequences;
}
}
assert(false);
@ -203,7 +204,7 @@ std::unique_ptr<SndCurveReader::Result> SndCurveReader::Read() const
return nullptr;
}
if(!parser.HasExpectedKnotCount())
if (!parser.HasExpectedKnotCount())
{
std::cerr << "Failed to load SndCurve: Actual knot count differs from expected: \"" << m_filename << "\"\n";
return nullptr;

View File

@ -1,11 +1,11 @@
#pragma once
#include <istream>
#include <vector>
#include <memory>
#include "Utils/ClassUtils.h"
#include <istream>
#include <memory>
#include <vector>
class SndCurveReader
{
public:
@ -17,7 +17,7 @@ public:
double m_x;
double m_y;
};
std::vector<Knot> m_knots;
};