2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-06-30 00:01:54 +00:00

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 @@
#include "AssetLoaderLocalizeEntry.h"
#include <sstream>
#include "Localize/LocalizeCommon.h"
#include "Parsing/LocalizeFile/LocalizeFileReader.h"
#include <sstream>
using namespace T5;
XAssetInfoGeneric* AssetLoaderLocalizeEntry::LoadFromGlobalAssetPools(const std::string& assetName) const
@ -22,7 +22,8 @@ bool AssetLoaderLocalizeEntry::CanLoadFromRaw() const
return true;
}
bool AssetLoaderLocalizeEntry::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderLocalizeEntry::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
std::string fileName;
{

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/T5/T5.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "AssetLoading/IAssetLoadingManager.h"
#include "Game/T5/T5.h"
#include "SearchPath/ISearchPath.h"
namespace T5
@ -12,6 +12,7 @@ namespace T5
_NODISCARD XAssetInfoGeneric* LoadFromGlobalAssetPools(const std::string& assetName) const override;
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
_NODISCARD bool CanLoadFromRaw() const override;
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
bool
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
};
}
} // namespace T5

View File

@ -1,13 +1,13 @@
#include "AssetLoaderRawFile.h"
#include "Game/T5/T5.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
#include <filesystem>
#include <iostream>
#include <zlib.h>
#include "Game/T5/T5.h"
#include "Pool/GlobalAssetPool.h"
using namespace T5;
namespace fs = std::filesystem;
@ -25,7 +25,8 @@ bool AssetLoaderRawFile::CanLoadFromRaw() const
return true;
}
bool AssetLoaderRawFile::LoadGsc(const SearchPathOpenFile& file, const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
bool AssetLoaderRawFile::LoadGsc(
const SearchPathOpenFile& file, const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
{
const auto uncompressedBuffer = std::make_unique<char[]>(static_cast<size_t>(file.m_length + 1));
file.m_stream->read(uncompressedBuffer.get(), file.m_length);
@ -65,7 +66,7 @@ bool AssetLoaderRawFile::LoadGsc(const SearchPathOpenFile& file, const std::stri
const auto compressedSize = compressionBufferSize - zs.avail_out;
reinterpret_cast<uint32_t*>(compressedBuffer)[0] = static_cast<uint32_t>(file.m_length + 1); // outLen
reinterpret_cast<uint32_t*>(compressedBuffer)[1] = compressedSize; // inLen
reinterpret_cast<uint32_t*>(compressedBuffer)[1] = compressedSize; // inLen
auto* rawFile = memory->Create<RawFile>();
rawFile->name = memory->Dup(assetName.c_str());
@ -77,7 +78,8 @@ bool AssetLoaderRawFile::LoadGsc(const SearchPathOpenFile& file, const std::stri
return true;
}
bool AssetLoaderRawFile::LoadDefault(const SearchPathOpenFile& file, const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
bool AssetLoaderRawFile::LoadDefault(
const SearchPathOpenFile& file, const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
{
auto* rawFile = memory->Create<RawFile>();
rawFile->name = memory->Dup(assetName.c_str());
@ -95,7 +97,8 @@ bool AssetLoaderRawFile::LoadDefault(const SearchPathOpenFile& file, const std::
return true;
}
bool AssetLoaderRawFile::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderRawFile::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
const auto file = searchPath->Open(assetName);
if (!file.IsOpen())
@ -104,7 +107,7 @@ bool AssetLoaderRawFile::LoadFromRaw(const std::string& assetName, ISearchPath*
const fs::path rawFilePath(assetName);
const auto extension = rawFilePath.extension().string();
if(extension == ".gsc" ||extension == ".csc")
if (extension == ".gsc" || extension == ".csc")
return LoadGsc(file, assetName, searchPath, memory, manager);
return LoadDefault(file, assetName, searchPath, memory, manager);

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/T5/T5.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "AssetLoading/IAssetLoadingManager.h"
#include "Game/T5/T5.h"
#include "SearchPath/ISearchPath.h"
namespace T5
@ -10,12 +10,15 @@ namespace T5
{
static constexpr size_t COMPRESSED_BUFFER_SIZE_PADDING = 64;
static bool LoadGsc(const SearchPathOpenFile& file, const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager);
static bool LoadDefault(const SearchPathOpenFile& file, const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager);
static bool LoadGsc(
const SearchPathOpenFile& file, const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager);
static bool LoadDefault(
const SearchPathOpenFile& file, const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager);
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
_NODISCARD bool CanLoadFromRaw() const override;
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
bool
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
};
}
} // namespace T5

View File

@ -1,12 +1,12 @@
#include "AssetLoaderStringTable.h"
#include <cstring>
#include "Csv/CsvStream.h"
#include "Game/T5/CommonT5.h"
#include "Game/T5/T5.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace T5;
void* AssetLoaderStringTable::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
@ -22,7 +22,8 @@ bool AssetLoaderStringTable::CanLoadFromRaw() const
return true;
}
bool AssetLoaderStringTable::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderStringTable::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
const auto file = searchPath->Open(assetName);
if (!file.IsOpen())
@ -71,14 +72,15 @@ bool AssetLoaderStringTable::LoadFromRaw(const std::string& assetName, ISearchPa
}
}
std::sort(&stringTable->cellIndex[0], &stringTable->cellIndex[cellCount - 1], [stringTable, maxCols](const int16_t a, const int16_t b)
{
auto compareResult = stringTable->values[a].hash - stringTable->values[b].hash;
if (compareResult == 0)
compareResult = a % maxCols - b % maxCols;
return compareResult < 0;
});
std::sort(&stringTable->cellIndex[0],
&stringTable->cellIndex[cellCount - 1],
[stringTable, maxCols](const int16_t a, const int16_t b)
{
auto compareResult = stringTable->values[a].hash - stringTable->values[b].hash;
if (compareResult == 0)
compareResult = a % maxCols - b % maxCols;
return compareResult < 0;
});
}
else

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/T5/T5.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "AssetLoading/IAssetLoadingManager.h"
#include "Game/T5/T5.h"
#include "SearchPath/ISearchPath.h"
namespace T5
@ -11,6 +11,7 @@ namespace T5
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
_NODISCARD bool CanLoadFromRaw() const override;
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
bool
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
};
}
} // namespace T5

View File

@ -1,23 +1,27 @@
#include "ObjLoaderT5.h"
#include "Game/T5/GameT5.h"
#include "Game/T5/GameAssetPoolT5.h"
#include "ObjContainer/IPak/IPak.h"
#include "ObjLoading.h"
#include "AssetLoaders/AssetLoaderLocalizeEntry.h"
#include "AssetLoaders/AssetLoaderRawFile.h"
#include "AssetLoaders/AssetLoaderStringTable.h"
#include "AssetLoading/AssetLoadingManager.h"
#include "Game/T5/GameAssetPoolT5.h"
#include "Game/T5/GameT5.h"
#include "Image/Dx9TextureLoader.h"
#include "Image/Texture.h"
#include "Image/IwiLoader.h"
#include "Image/IwiTypes.h"
#include "Image/Texture.h"
#include "ObjContainer/IPak/IPak.h"
#include "ObjLoading.h"
using namespace T5;
ObjLoader::ObjLoader()
{
#define REGISTER_ASSET_LOADER(t) {auto l = std::make_unique<t>(); m_asset_loaders_by_type[l->GetHandlingAssetType()] = std::move(l);}
#define REGISTER_ASSET_LOADER(t) \
{ \
auto l = std::make_unique<t>(); \
m_asset_loaders_by_type[l->GetHandlingAssetType()] = std::move(l); \
}
#define BASIC_LOADER(assetType, assetClass) BasicAssetLoader<assetType, assetClass>
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_PHYSPRESET, PhysPreset))
@ -65,23 +69,17 @@ bool ObjLoader::SupportsZone(Zone* zone) const
bool ObjLoader::IsMpZone(Zone* zone)
{
return zone->m_name.compare(0, 3, "mp_") == 0
|| zone->m_name.compare(zone->m_name.length() - 3, 3, "_mp") == 0;
return zone->m_name.compare(0, 3, "mp_") == 0 || zone->m_name.compare(zone->m_name.length() - 3, 3, "_mp") == 0;
}
bool ObjLoader::IsZmZone(Zone* zone)
{
return zone->m_name.compare(0, 3, "zm_") == 0
|| zone->m_name.compare(zone->m_name.length() - 3, 3, "_zm") == 0;
return zone->m_name.compare(0, 3, "zm_") == 0 || zone->m_name.compare(zone->m_name.length() - 3, 3, "_zm") == 0;
}
void ObjLoader::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) const
{
}
void ObjLoader::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) const {}
void ObjLoader::UnloadContainersOfZone(Zone* zone) const
{
}
void ObjLoader::UnloadContainersOfZone(Zone* zone) const {}
void ObjLoader::LoadImageFromLoadDef(GfxImage* image, Zone* zone)
{
@ -190,4 +188,4 @@ void ObjLoader::FinalizeAssetsForZone(AssetLoadingContext* context) const
{
for (const auto& [type, loader] : m_asset_loaders_by_type)
loader->FinalizeAssetsForZone(context);
}
}

View File

@ -1,13 +1,13 @@
#pragma once
#include "AssetLoading/IAssetLoader.h"
#include "Game/T5/T5.h"
#include "IObjLoader.h"
#include "SearchPath/ISearchPath.h"
#include <map>
#include <memory>
#include "IObjLoader.h"
#include "AssetLoading/IAssetLoader.h"
#include "SearchPath/ISearchPath.h"
#include "Game/T5/T5.h"
namespace T5
{
class ObjLoader final : public IObjLoader
@ -34,4 +34,4 @@ namespace T5
bool LoadAssetForZone(AssetLoadingContext* context, asset_type_t assetType, const std::string& assetName) const override;
void FinalizeAssetsForZone(AssetLoadingContext* context) const override;
};
}
} // namespace T5