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,15 +1,14 @@
#pragma once
#include <string>
#include <map>
#include "XAssetInfo.h"
#include "Zone/Zone.h"
#include <map>
#include <string>
class Zone;
template<typename T>
class AssetPool
template<typename T> class AssetPool
{
public:
std::map<std::string, XAssetInfo<T>*> m_asset_lookup;
@ -47,13 +46,14 @@ public:
virtual ~AssetPool() = default;
virtual XAssetInfo<T>* AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) = 0;
virtual XAssetInfo<T>*
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) = 0;
XAssetInfo<T>* GetAsset(const std::string& name)
{
auto foundAsset = m_asset_lookup.find(name);
if(foundAsset == m_asset_lookup.end())
if (foundAsset == m_asset_lookup.end())
return nullptr;
return foundAsset->second;
@ -68,4 +68,4 @@ public:
{
return Iterator(m_asset_lookup.end());
}
};
};

View File

@ -6,8 +6,7 @@
#include <cstring>
template <typename T>
class AssetPoolDynamic final : public AssetPool<T>
template<typename T> class AssetPoolDynamic final : public AssetPool<T>
{
using AssetPool<T>::m_asset_lookup;
@ -23,14 +22,14 @@ public:
AssetPoolDynamic(AssetPoolDynamic<T>&) = delete;
AssetPoolDynamic(AssetPoolDynamic<T>&&) = delete;
AssetPoolDynamic<T>& operator =(AssetPoolDynamic<T>&) = delete;
AssetPoolDynamic<T>& operator =(AssetPoolDynamic<T>&&) = default;
AssetPoolDynamic<T>& operator=(AssetPoolDynamic<T>&) = delete;
AssetPoolDynamic<T>& operator=(AssetPoolDynamic<T>&&) = default;
~AssetPoolDynamic() override
{
GlobalAssetPool<T>::UnlinkAssetPool(this);
for(auto* entry : m_assets)
for (auto* entry : m_assets)
{
delete entry->Asset();
delete entry;
@ -40,7 +39,8 @@ public:
m_asset_lookup.clear();
}
XAssetInfo<T>* AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override
XAssetInfo<T>*
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override
{
auto* newInfo = new XAssetInfo<T>();
newInfo->m_type = m_type;
@ -52,10 +52,10 @@ public:
T* newAsset = new T();
memcpy(newAsset, asset, sizeof(T));
newInfo->m_ptr = newAsset;
m_assets.push_back(newInfo);
m_asset_lookup[newInfo->m_name] = newInfo;
GlobalAssetPool<T>::LinkAsset(this, newInfo);
return newInfo;

View File

@ -1,14 +1,13 @@
#pragma once
#include "AssetPool.h"
#include "GlobalAssetPool.h"
#include "XAssetInfo.h"
#include <cstring>
#include <stdexcept>
#include "GlobalAssetPool.h"
#include "AssetPool.h"
#include "XAssetInfo.h"
template <typename T>
class AssetPoolStatic final : public AssetPool<T>
template<typename T> class AssetPoolStatic final : public AssetPool<T>
{
using AssetPool<T>::m_asset_lookup;
@ -40,7 +39,7 @@ public:
m_pool = new AssetPoolEntry[m_capacity];
m_info_pool = new XAssetInfo<T>[m_capacity];
for(size_t i = 0; i < m_capacity - 1; i++)
for (size_t i = 0; i < m_capacity - 1; i++)
{
m_pool[i].m_info = &m_info_pool[i];
m_pool[i].m_next = &m_pool[i + 1];
@ -49,7 +48,7 @@ public:
m_pool[m_capacity - 1].m_next = nullptr;
m_free = m_pool;
GlobalAssetPool<T>::LinkAssetPool(this, priority);
}
else
@ -62,12 +61,12 @@ public:
AssetPoolStatic(AssetPoolStatic<T>&) = delete;
AssetPoolStatic(AssetPoolStatic<T>&&) = delete;
AssetPoolStatic<T>& operator =(AssetPoolStatic<T>&) = delete;
AssetPoolStatic<T>& operator =(AssetPoolStatic<T>&&) = default;
AssetPoolStatic<T>& operator=(AssetPoolStatic<T>&) = delete;
AssetPoolStatic<T>& operator=(AssetPoolStatic<T>&&) = default;
~AssetPoolStatic() override
{
if(m_capacity > 0)
if (m_capacity > 0)
{
GlobalAssetPool<T>::UnlinkAssetPool(this);
}
@ -82,9 +81,10 @@ public:
m_capacity = 0;
}
XAssetInfo<T>* AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override
XAssetInfo<T>*
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override
{
if(m_free == nullptr)
if (m_free == nullptr)
{
throw std::runtime_error("Could not add asset to static asset pool: capacity exhausted.");
}
@ -104,7 +104,7 @@ public:
m_asset_lookup[poolSlot->m_info->m_name] = poolSlot->m_info;
GlobalAssetPool<T>::LinkAsset(this, poolSlot->m_info);
return poolSlot->m_info;
}
};

View File

@ -1,16 +1,15 @@
#pragma once
#include <vector>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cassert>
#include <memory>
#include "AssetPool.h"
template <typename T>
class GlobalAssetPool
#include <algorithm>
#include <cassert>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
template<typename T> class GlobalAssetPool
{
struct LinkedAssetPool
{
@ -30,10 +29,12 @@ class GlobalAssetPool
static void SortLinkedAssetPools()
{
std::sort(m_linked_asset_pools.begin(), m_linked_asset_pools.end(), [](const std::unique_ptr<LinkedAssetPool>& a, const std::unique_ptr<LinkedAssetPool>& b) -> bool
{
return a->m_priority < b->m_priority;
});
std::sort(m_linked_asset_pools.begin(),
m_linked_asset_pools.end(),
[](const std::unique_ptr<LinkedAssetPool>& a, const std::unique_ptr<LinkedAssetPool>& b) -> bool
{
return a->m_priority < b->m_priority;
});
}
static bool ReplaceAssetPoolEntry(GameAssetPoolEntry& assetEntry)
@ -179,8 +180,10 @@ public:
}
};
template <typename T>
std::vector<std::unique_ptr<typename GlobalAssetPool<T>::LinkedAssetPool>> GlobalAssetPool<T>::m_linked_asset_pools = std::vector<std::unique_ptr<LinkedAssetPool>>();
template<typename T>
std::vector<std::unique_ptr<typename GlobalAssetPool<T>::LinkedAssetPool>> GlobalAssetPool<T>::m_linked_asset_pools =
std::vector<std::unique_ptr<LinkedAssetPool>>();
template <typename T>
std::unordered_map<std::string, typename GlobalAssetPool<T>::GameAssetPoolEntry> GlobalAssetPool<T>::m_assets = std::unordered_map<std::string, GameAssetPoolEntry>();
template<typename T>
std::unordered_map<std::string, typename GlobalAssetPool<T>::GameAssetPoolEntry> GlobalAssetPool<T>::m_assets =
std::unordered_map<std::string, GameAssetPoolEntry>();

View File

@ -1,9 +1,9 @@
#pragma once
#include <vector>
#include <string>
#include "Zone/Zone.h"
#include <string>
#include <vector>
class Zone;
class XAssetInfoGeneric
@ -17,8 +17,7 @@ public:
void* m_ptr;
};
template<typename T>
class XAssetInfo : public XAssetInfoGeneric
template<typename T> class XAssetInfo : public XAssetInfoGeneric
{
public:
T* Asset()

View File

@ -5,12 +5,18 @@ ZoneAssetPools::ZoneAssetPools(Zone* zone)
{
}
XAssetInfoGeneric* ZoneAssetPools::AddAsset(const asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings)
XAssetInfoGeneric* ZoneAssetPools::AddAsset(
const asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings)
{
return AddAsset(type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), m_zone);
}
XAssetInfoGeneric* ZoneAssetPools::AddAsset(const asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
XAssetInfoGeneric* ZoneAssetPools::AddAsset(const asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone)
{
auto* assetInfo = AddAssetToPool(type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), zone);
if (assetInfo)

View File

@ -1,12 +1,12 @@
#pragma once
#include <vector>
#include <string>
#include <cstddef>
#include "Utils/ClassUtils.h"
#include "XAssetInfo.h"
#include "Zone/ZoneTypes.h"
#include "Zone/Zone.h"
#include "Zone/ZoneTypes.h"
#include <cstddef>
#include <string>
#include <vector>
class Zone;
class XAssetInfoGeneric;
@ -17,7 +17,11 @@ protected:
Zone* m_zone;
std::vector<XAssetInfoGeneric*> m_assets_in_order;
virtual XAssetInfoGeneric* AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings,
virtual XAssetInfoGeneric* AddAssetToPool(asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) = 0;
public:
@ -30,8 +34,14 @@ public:
ZoneAssetPools& operator=(const ZoneAssetPools& other) = delete;
ZoneAssetPools& operator=(ZoneAssetPools&& other) noexcept = default;
XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings);
XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone);
XAssetInfoGeneric*
AddAsset(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings);
XAssetInfoGeneric* AddAsset(asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone);
_NODISCARD virtual XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const = 0;
_NODISCARD virtual asset_type_t GetAssetTypeCount() const = 0;
_NODISCARD virtual const char* GetAssetTypeName(asset_type_t assetType) const = 0;