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,11 +1,11 @@
#include "AssetLoaderAddonMapEnts.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderAddonMapEnts::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderClipMap.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderClipMap::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -22,4 +22,4 @@ namespace IW4
public:
_NODISCARD asset_type_t GetHandlingAssetType() const override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderComWorld.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderComWorld::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderFont.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderFont::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderFx.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderFx::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderFxImpactTable.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderFxImpactTable::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderFxWorld.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderFxWorld::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderGameWorldMp.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderGameWorldMp::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderGameWorldSp.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderGameWorldSp::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderGfxImage.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderGfxImage::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,13 +1,13 @@
#include "AssetLoaderGfxLightDef.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
#include <iostream>
#include <sstream>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "Pool/GlobalAssetPool.h"
using namespace IW4;
std::string AssetLoaderGfxLightDef::GetAssetFilename(const std::string& assetName)
@ -32,7 +32,8 @@ bool AssetLoaderGfxLightDef::CanLoadFromRaw() const
return true;
}
bool AssetLoaderGfxLightDef::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderGfxLightDef::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
const auto filename = GetAssetFilename(assetName);
const auto file = searchPath->Open(filename);
@ -53,7 +54,7 @@ bool AssetLoaderGfxLightDef::LoadFromRaw(const std::string& assetName, ISearchPa
auto* imageDependency = reinterpret_cast<XAssetInfo<GfxImage>*>(manager->LoadDependency(ASSET_TYPE_IMAGE, imageName));
if(!imageDependency)
if (!imageDependency)
{
std::cerr << "Could not load GfxLightDef \"" << assetName << "\" due to missing image \"" << imageName << "\"\n";
return false;

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -15,6 +15,7 @@ namespace IW4
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 IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderGfxWorld.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderGfxWorld::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderLeaderboard.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderLeaderboard::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderLoadedSound.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderLoadedSound::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,10 +1,10 @@
#include "AssetLoaderLocalizeEntry.h"
#include <sstream>
#include "Localize/LocalizeCommon.h"
#include "Parsing/LocalizeFile/LocalizeFileReader.h"
#include <sstream>
using namespace IW4;
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/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "AssetLoading/IAssetLoadingManager.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -12,6 +12,7 @@ namespace IW4
_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 IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderMapEnts.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderMapEnts::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,12 +1,6 @@
#include "AssetLoaderMaterial.h"
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include "AssetLoaderTechniqueSet.h"
#include "ObjLoading.h"
#include "AssetLoading/AbstractGdtEntryReader.h"
#include "Game/IW4/CommonIW4.h"
#include "Game/IW4/IW4.h"
@ -14,11 +8,17 @@
#include "Game/IW4/ObjConstantsIW4.h"
#include "Game/IW4/TechsetConstantsIW4.h"
#include "Math/Vector.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include "StateMap/StateMapFromTechniqueExtractor.h"
#include "StateMap/StateMapHandler.h"
#include "Techset/TechniqueFileReader.h"
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
using namespace IW4;
namespace IW4
@ -68,9 +68,7 @@ namespace IW4
{
const auto materialType = ReadStringProperty("materialType");
if (materialType == GDT_MATERIAL_TYPE_MODEL_PHONG
|| materialType == GDT_MATERIAL_TYPE_WORLD_PHONG
|| materialType == GDT_MATERIAL_TYPE_IMPACT_MARK)
if (materialType == GDT_MATERIAL_TYPE_MODEL_PHONG || materialType == GDT_MATERIAL_TYPE_WORLD_PHONG || materialType == GDT_MATERIAL_TYPE_IMPACT_MARK)
{
mtl_phong_template();
}
@ -82,8 +80,7 @@ namespace IW4
{
mtl_2d_template();
}
else if (materialType == GDT_MATERIAL_TYPE_MODEL_UNLIT
|| materialType == GDT_MATERIAL_TYPE_WORLD_UNLIT)
else if (materialType == GDT_MATERIAL_TYPE_MODEL_UNLIT || materialType == GDT_MATERIAL_TYPE_WORLD_UNLIT)
{
mtl_unlit_template();
}
@ -557,11 +554,10 @@ namespace IW4
sortKey = GDT_SORTKEY_DECAL_WEAPON_IMPACT;
else if (materialType == GDT_MATERIAL_TYPE_EFFECT)
sortKey = GDT_SORTKEY_EFFECT_AUTO_SORT;
else if (materialType == GDT_MATERIAL_TYPE_OBJECTIVE
|| blendFunc == "Blend" || blendFunc == "Add" || blendFunc == "Screen Add")
else if (materialType == GDT_MATERIAL_TYPE_OBJECTIVE || blendFunc == "Blend" || blendFunc == "Add" || blendFunc == "Screen Add")
sortKey = GDT_SORTKEY_BLEND_ADDITIVE;
// else if (blendFunc == "Multiply") // TODO
// sortKey = GDT_SORTKEY_MULTIPLICATIVE;
// else if (blendFunc == "Multiply") // TODO
// sortKey = GDT_SORTKEY_MULTIPLICATIVE;
else if (materialType == GDT_MATERIAL_TYPE_SKY)
sortKey = GDT_SORTKEY_SKY;
else if (materialType == GDT_MATERIAL_TYPE_MODEL_AMBIENT)
@ -599,9 +595,7 @@ namespace IW4
}
}
void clamp_template()
{
}
void clamp_template() {}
void textureAtlas_template()
{
@ -674,11 +668,15 @@ namespace IW4
else if (blendFunc == GDT_BLEND_FUNC_CUSTOM)
{
const auto customBlendOpRgb = ReadEnumProperty<BlendOp_e>("customBlendOpRgb", GdtBlendOpNames, std::extent_v<decltype(GdtBlendOpNames)>);
const auto srcCustomBlendFunc = ReadEnumProperty<CustomBlendFunc_e>("srcCustomBlendFunc", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
const auto destCustomBlendFunc = ReadEnumProperty<CustomBlendFunc_e>("destCustomBlendFunc", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
const auto srcCustomBlendFunc =
ReadEnumProperty<CustomBlendFunc_e>("srcCustomBlendFunc", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
const auto destCustomBlendFunc =
ReadEnumProperty<CustomBlendFunc_e>("destCustomBlendFunc", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
const auto customBlendOpAlpha = ReadEnumProperty<BlendOp_e>("customBlendOpAlpha", GdtBlendOpNames, std::extent_v<decltype(GdtBlendOpNames)>);
const auto srcCustomBlendFuncAlpha = ReadEnumProperty<CustomBlendFunc_e>("srcCustomBlendFuncAlpha", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
const auto destCustomBlendFuncAlpha = ReadEnumProperty<CustomBlendFunc_e>("destCustomBlendFuncAlpha", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
const auto srcCustomBlendFuncAlpha =
ReadEnumProperty<CustomBlendFunc_e>("srcCustomBlendFuncAlpha", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
const auto destCustomBlendFuncAlpha =
ReadEnumProperty<CustomBlendFunc_e>("destCustomBlendFuncAlpha", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
SetBlendFunc(customBlendOpRgb, srcCustomBlendFunc, destCustomBlendFunc);
SetSeparateAlphaBlendFunc(customBlendOpAlpha, srcCustomBlendFuncAlpha, destCustomBlendFuncAlpha);
@ -693,10 +691,14 @@ namespace IW4
void colorwrite_template()
{
const auto colorWriteRed = ReadEnumProperty<StateBitsEnabledStatus_e>("colorWriteRed", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
const auto colorWriteGreen = ReadEnumProperty<StateBitsEnabledStatus_e>("colorWriteGreen", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
const auto colorWriteBlue = ReadEnumProperty<StateBitsEnabledStatus_e>("colorWriteBlue", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
const auto colorWriteAlpha = ReadEnumProperty<StateBitsEnabledStatus_e>("colorWriteAlpha", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
const auto colorWriteRed = ReadEnumProperty<StateBitsEnabledStatus_e>(
"colorWriteRed", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
const auto colorWriteGreen = ReadEnumProperty<StateBitsEnabledStatus_e>(
"colorWriteGreen", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
const auto colorWriteBlue = ReadEnumProperty<StateBitsEnabledStatus_e>(
"colorWriteBlue", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
const auto colorWriteAlpha = ReadEnumProperty<StateBitsEnabledStatus_e>(
"colorWriteAlpha", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
SetColorWrite(colorWriteRed, colorWriteGreen, colorWriteBlue, colorWriteAlpha);
}
@ -717,7 +719,8 @@ namespace IW4
void depthwrite_template()
{
const auto depthWrite = ReadEnumProperty<StateBitsEnabledStatus_e>("depthWrite", GdtStateBitsOnOffStatusNames, std::extent_v<decltype(GdtStateBitsOnOffStatusNames)>);
const auto depthWrite =
ReadEnumProperty<StateBitsEnabledStatus_e>("depthWrite", GdtStateBitsOnOffStatusNames, std::extent_v<decltype(GdtStateBitsOnOffStatusNames)>);
const auto blendFunc = ReadStringProperty("blendFunc");
if (depthWrite == StateBitsEnabledStatus_e::ENABLED)
@ -746,7 +749,8 @@ namespace IW4
void gammawrite_template()
{
const auto gammaWrite = ReadEnumProperty<StateBitsEnabledStatus_e>("gammaWrite", GdtStateBitsOnOffStatusNames, std::extent_v<decltype(GdtStateBitsOnOffStatusNames)>);
const auto gammaWrite =
ReadEnumProperty<StateBitsEnabledStatus_e>("gammaWrite", GdtStateBitsOnOffStatusNames, std::extent_v<decltype(GdtStateBitsOnOffStatusNames)>);
if (gammaWrite == StateBitsEnabledStatus_e::UNKNOWN)
{
@ -760,7 +764,8 @@ namespace IW4
void polygonoffset_template()
{
const auto polygonOffset = ReadEnumProperty<PolygonOffset_e>("polygonOffset", GdtPolygonOffsetNames, std::extent_v<decltype(GdtPolygonOffsetNames)>);
const auto polygonOffset =
ReadEnumProperty<PolygonOffset_e>("polygonOffset", GdtPolygonOffsetNames, std::extent_v<decltype(GdtPolygonOffsetNames)>);
SetPolygonOffset(polygonOffset);
}
@ -778,17 +783,23 @@ namespace IW4
{
if (stencilMode == StencilMode_e::TWO_SIDED)
{
const auto stencilBackFunc = ReadEnumProperty<StencilFunc_e>("stencilFunc2", GdtStencilFuncNames, std::extent_v<decltype(GdtStencilFuncNames)>);
const auto stencilBackOpFail = ReadEnumProperty<StencilOp_e>("stencilOpFail2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
const auto stencilBackOpZFail = ReadEnumProperty<StencilOp_e>("stencilOpZFail2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
const auto stencilBackOpPass = ReadEnumProperty<StencilOp_e>("stencilOpPass2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
const auto stencilBackFunc =
ReadEnumProperty<StencilFunc_e>("stencilFunc2", GdtStencilFuncNames, std::extent_v<decltype(GdtStencilFuncNames)>);
const auto stencilBackOpFail =
ReadEnumProperty<StencilOp_e>("stencilOpFail2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
const auto stencilBackOpZFail =
ReadEnumProperty<StencilOp_e>("stencilOpZFail2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
const auto stencilBackOpPass =
ReadEnumProperty<StencilOp_e>("stencilOpPass2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
EnableStencil(StencilIndex::BACK, stencilBackFunc, stencilBackOpFail, stencilBackOpZFail, stencilBackOpPass);
}
const auto stencilFrontFunc = ReadEnumProperty<StencilFunc_e>("stencilFunc1", GdtStencilFuncNames, std::extent_v<decltype(GdtStencilFuncNames)>);
const auto stencilFrontFunc =
ReadEnumProperty<StencilFunc_e>("stencilFunc1", GdtStencilFuncNames, std::extent_v<decltype(GdtStencilFuncNames)>);
const auto stencilFrontOpFail = ReadEnumProperty<StencilOp_e>("stencilOpFail1", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
const auto stencilFrontOpZFail = ReadEnumProperty<StencilOp_e>("stencilOpZFail1", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
const auto stencilFrontOpZFail =
ReadEnumProperty<StencilOp_e>("stencilOpZFail1", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
const auto stencilFrontOpPass = ReadEnumProperty<StencilOp_e>("stencilOpPass1", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
EnableStencil(StencilIndex::FRONT, stencilFrontFunc, stencilFrontOpFail, stencilFrontOpZFail, stencilFrontOpPass);
@ -833,11 +844,13 @@ namespace IW4
if (techsetDefinition->GetTechniqueByIndex(i, techniqueName))
{
const auto stateBitsForTechnique = GetStateBitsForTechnique(techniqueName);
const auto foundStateBits = std::find_if(m_state_bits.begin(), m_state_bits.end(),
[stateBitsForTechnique](const GfxStateBits& s1)
{
return s1.loadBits[0] == stateBitsForTechnique.loadBits[0] && s1.loadBits[1] == stateBitsForTechnique.loadBits[1];
});
const auto foundStateBits =
std::find_if(m_state_bits.begin(),
m_state_bits.end(),
[stateBitsForTechnique](const GfxStateBits& s1)
{
return s1.loadBits[0] == stateBitsForTechnique.loadBits[0] && s1.loadBits[1] == stateBitsForTechnique.loadBits[1];
});
if (foundStateBits != m_state_bits.end())
{
@ -928,7 +941,8 @@ namespace IW4
}
}
void AddMapTexture(const std::string& typeName, const TileMode_e tileMode, GdtFilter_e filterMode, const TextureSemantic semantic, const std::string& textureName)
void AddMapTexture(
const std::string& typeName, const TileMode_e tileMode, GdtFilter_e filterMode, const TextureSemantic semantic, const std::string& textureName)
{
MaterialTextureDef textureDef{};
textureDef.nameHash = Common::R_HashString(typeName.c_str());
@ -1086,7 +1100,9 @@ namespace IW4
m_base_state_bits.loadBits[0] |= ((static_cast<unsigned>(destFunc) - 1) << GFXS0_DSTBLEND_ALPHA_SHIFT) & GFXS0_DSTBLEND_ALPHA_MASK;
}
void SetColorWrite(const StateBitsEnabledStatus_e colorWriteRed, const StateBitsEnabledStatus_e colorWriteGreen, const StateBitsEnabledStatus_e colorWriteBlue,
void SetColorWrite(const StateBitsEnabledStatus_e colorWriteRed,
const StateBitsEnabledStatus_e colorWriteGreen,
const StateBitsEnabledStatus_e colorWriteBlue,
const StateBitsEnabledStatus_e colorWriteAlpha)
{
if (colorWriteRed == StateBitsEnabledStatus_e::UNKNOWN || colorWriteGreen == StateBitsEnabledStatus_e::UNKNOWN
@ -1200,8 +1216,16 @@ namespace IW4
m_base_state_bits.loadBits[1] |= ((static_cast<unsigned>(polygonOffset) - 1) << GFXS1_POLYGON_OFFSET_SHIFT) & GFXS1_POLYGON_OFFSET_MASK;
}
static void GetStencilMasksForIndex(const StencilIndex stencil, unsigned& enabledMask, unsigned& funcShift, unsigned& funcMask, unsigned& opFailShift, unsigned& opFailMask,
unsigned& opZFailShift, unsigned& opZFailMask, unsigned& opPassShift, unsigned& opPassMask)
static void GetStencilMasksForIndex(const StencilIndex stencil,
unsigned& enabledMask,
unsigned& funcShift,
unsigned& funcMask,
unsigned& opFailShift,
unsigned& opFailMask,
unsigned& opZFailShift,
unsigned& opZFailMask,
unsigned& opPassShift,
unsigned& opPassMask)
{
if (stencil == StencilIndex::FRONT)
{
@ -1239,7 +1263,8 @@ namespace IW4
m_base_state_bits.loadBits[1] &= ~(enabledMask | funcMask | opFailMask | opZFailMask | opPassMask);
}
void EnableStencil(const StencilIndex stencil, StencilFunc_e stencilFunc, StencilOp_e stencilOpFail, StencilOp_e stencilOpZFail, StencilOp_e stencilOpPass)
void EnableStencil(
const StencilIndex stencil, StencilFunc_e stencilFunc, StencilOp_e stencilOpFail, StencilOp_e stencilOpZFail, StencilOp_e stencilOpPass)
{
unsigned enabledMask, funcShift, funcMask, opFailShift, opFailMask, opZFailShift, opZFailMask, opPassShift, opPassMask;
GetStencilMasksForIndex(stencil, enabledMask, funcShift, funcMask, opFailShift, opFailMask, opZFailShift, opZFailMask, opPassShift, opPassMask);
@ -1298,7 +1323,8 @@ namespace IW4
}
}
static size_t GetIndexForString(const std::string& propertyName, const std::string& value, const char** validValuesArray, const size_t validValuesArraySize)
static size_t
GetIndexForString(const std::string& propertyName, const std::string& value, const char** validValuesArray, const size_t validValuesArraySize)
{
for (auto i = 0u; i < validValuesArraySize; i++)
{
@ -1311,8 +1337,7 @@ namespace IW4
throw GdtReadingException(ss.str());
}
template <typename T>
T ReadEnumProperty(const std::string& propertyName, const char** validValuesArray, const size_t validValuesArraySize) const
template<typename T> T ReadEnumProperty(const std::string& propertyName, const char** validValuesArray, const size_t validValuesArraySize) const
{
return static_cast<T>(GetIndexForString(propertyName, ReadStringProperty(propertyName), validValuesArray, validValuesArraySize));
}
@ -1330,7 +1355,7 @@ namespace IW4
std::vector<MaterialTextureDef> m_textures;
std::vector<MaterialConstantDef> m_constants;
};
}
} // namespace IW4
void* AssetLoaderMaterial::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
{
@ -1345,7 +1370,8 @@ bool AssetLoaderMaterial::CanLoadFromGdt() const
return true;
}
bool AssetLoaderMaterial::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderMaterial::LoadFromGdt(
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
const auto* entry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_MATERIAL, assetName);
if (!entry)

View File

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

View File

@ -1,11 +1,11 @@
#include "AssetLoaderMenuDef.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderMenuDef::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,15 +1,15 @@
#include "AssetLoaderMenuList.h"
#include <cstring>
#include <iostream>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "Game/IW4/Menu/MenuConversionZoneStateIW4.h"
#include "Game/IW4/Menu/MenuConverterIW4.h"
#include "ObjLoading.h"
#include "Parsing/Menu/MenuFileReader.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
#include <iostream>
using namespace IW4;
namespace IW4
@ -17,8 +17,14 @@ namespace IW4
class MenuLoader
{
public:
static bool ProcessParsedResults(const std::string& fileName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, menu::ParsingResult* parsingResult,
menu::MenuAssetZoneState* zoneState, MenuConversionZoneState* conversionState, std::vector<menuDef_t*>& menus,
static bool ProcessParsedResults(const std::string& fileName,
ISearchPath* searchPath,
MemoryManager* memory,
IAssetLoadingManager* manager,
menu::ParsingResult* parsingResult,
menu::MenuAssetZoneState* zoneState,
MenuConversionZoneState* conversionState,
std::vector<menuDef_t*>& menus,
std::vector<XAssetInfoGeneric*>& menuListDependencies)
{
const auto menuCount = parsingResult->m_menus.size();
@ -28,8 +34,8 @@ namespace IW4
for (const auto& menu : parsingResult->m_menus)
totalItemCount += menu->m_items.size();
std::cout << "Successfully read menu file \"" << fileName << "\" (" << menuLoadCount << " loads, " << menuCount << " menus, " << functionCount << " functions, " << totalItemCount <<
" items)\n";
std::cout << "Successfully read menu file \"" << fileName << "\" (" << menuLoadCount << " loads, " << menuCount << " menus, " << functionCount
<< " functions, " << totalItemCount << " items)\n";
// Add all functions to the zone state to make them available for all menus to be converted
for (auto& function : parsingResult->m_functions)
@ -51,7 +57,8 @@ namespace IW4
}
menus.push_back(menuAsset);
auto* menuAssetInfo = manager->AddAsset(ASSET_TYPE_MENU, menu->m_name, menuAsset, std::move(converter.GetDependencies()), std::vector<scr_string_t>());
auto* menuAssetInfo =
manager->AddAsset(ASSET_TYPE_MENU, menu->m_name, menuAsset, std::move(converter.GetDependencies()), std::vector<scr_string_t>());
if (menuAssetInfo)
{
@ -86,20 +93,24 @@ namespace IW4
return menuListAsset;
}
static std::unique_ptr<menu::ParsingResult> ParseMenuFile(const std::string& menuFileName, ISearchPath* searchPath, const menu::MenuAssetZoneState* zoneState)
static std::unique_ptr<menu::ParsingResult>
ParseMenuFile(const std::string& menuFileName, ISearchPath* searchPath, const menu::MenuAssetZoneState* zoneState)
{
const auto file = searchPath->Open(menuFileName);
if (!file.IsOpen())
return nullptr;
menu::MenuFileReader reader(*file.m_stream, menuFileName, menu::FeatureLevel::IW4, [searchPath](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
{
auto foundFileToInclude = searchPath->Open(filename);
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
return nullptr;
menu::MenuFileReader reader(*file.m_stream,
menuFileName,
menu::FeatureLevel::IW4,
[searchPath](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
{
auto foundFileToInclude = searchPath->Open(filename);
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
return nullptr;
return std::move(foundFileToInclude.m_stream);
});
return std::move(foundFileToInclude.m_stream);
});
reader.IncludeZoneState(zoneState);
reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing);
@ -107,7 +118,7 @@ namespace IW4
return reader.ReadMenuFile();
}
};
}
} // namespace IW4
void* AssetLoaderMenuList::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
{
@ -122,8 +133,15 @@ bool AssetLoaderMenuList::CanLoadFromRaw() const
return true;
}
bool BuildMenuFileQueue(std::deque<std::string>& menuLoadQueue, const std::string& menuListAssetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, menu::MenuAssetZoneState* zoneState,
MenuConversionZoneState* conversionState, std::vector<menuDef_t*>& menus, std::vector<XAssetInfoGeneric*>& menuListDependencies)
bool BuildMenuFileQueue(std::deque<std::string>& menuLoadQueue,
const std::string& menuListAssetName,
ISearchPath* searchPath,
MemoryManager* memory,
IAssetLoadingManager* manager,
menu::MenuAssetZoneState* zoneState,
MenuConversionZoneState* conversionState,
std::vector<menuDef_t*>& menus,
std::vector<XAssetInfoGeneric*>& menuListDependencies)
{
const auto alreadyLoadedMenuListFileMenus = conversionState->m_menus_by_filename.find(menuListAssetName);
@ -132,7 +150,8 @@ bool BuildMenuFileQueue(std::deque<std::string>& menuLoadQueue, const std::strin
const auto menuListResult = MenuLoader::ParseMenuFile(menuListAssetName, searchPath, zoneState);
if (menuListResult)
{
MenuLoader::ProcessParsedResults(menuListAssetName, searchPath, memory, manager, menuListResult.get(), zoneState, conversionState, menus, menuListDependencies);
MenuLoader::ProcessParsedResults(
menuListAssetName, searchPath, memory, manager, menuListResult.get(), zoneState, conversionState, menus, menuListDependencies);
for (const auto& menuToLoad : menuListResult->m_menus_to_load)
menuLoadQueue.push_back(menuToLoad);
@ -146,8 +165,14 @@ bool BuildMenuFileQueue(std::deque<std::string>& menuLoadQueue, const std::strin
return true;
}
void LoadMenuFileFromQueue(const std::string& menuFilePath, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, menu::MenuAssetZoneState* zoneState,
MenuConversionZoneState* conversionState, std::vector<menuDef_t*>& menus, std::vector<XAssetInfoGeneric*>& menuListDependencies)
void LoadMenuFileFromQueue(const std::string& menuFilePath,
ISearchPath* searchPath,
MemoryManager* memory,
IAssetLoadingManager* manager,
menu::MenuAssetZoneState* zoneState,
MenuConversionZoneState* conversionState,
std::vector<menuDef_t*>& menus,
std::vector<XAssetInfoGeneric*>& menuListDependencies)
{
const auto alreadyLoadedMenuFile = conversionState->m_menus_by_filename.find(menuFilePath);
if (alreadyLoadedMenuFile != conversionState->m_menus_by_filename.end())
@ -164,7 +189,8 @@ void LoadMenuFileFromQueue(const std::string& menuFilePath, ISearchPath* searchP
const auto menuFileResult = MenuLoader::ParseMenuFile(menuFilePath, searchPath, zoneState);
if (menuFileResult)
{
MenuLoader::ProcessParsedResults(menuFilePath, searchPath, memory, manager, menuFileResult.get(), zoneState, conversionState, menus, menuListDependencies);
MenuLoader::ProcessParsedResults(
menuFilePath, searchPath, memory, manager, menuFileResult.get(), zoneState, conversionState, menus, menuListDependencies);
if (!menuFileResult->m_menus_to_load.empty())
std::cout << "WARNING: Menu file has menus to load even though it is not a menu list, ignoring: \"" << menuFilePath << "\"\n";
}
@ -172,7 +198,8 @@ void LoadMenuFileFromQueue(const std::string& menuFilePath, ISearchPath* searchP
std::cerr << "Could not read menu file \"" << menuFilePath << "\"\n";
}
bool AssetLoaderMenuList::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderMenuList::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
std::vector<menuDef_t*> menus;
std::vector<XAssetInfoGeneric*> menuListDependencies;
@ -184,7 +211,7 @@ bool AssetLoaderMenuList::LoadFromRaw(const std::string& assetName, ISearchPath*
if (!BuildMenuFileQueue(menuLoadQueue, assetName, searchPath, memory, manager, zoneState, conversionState, menus, menuListDependencies))
return false;
while(!menuLoadQueue.empty())
while (!menuLoadQueue.empty())
{
const auto& menuFileToLoad = menuLoadQueue.front();

View File

@ -1,8 +1,8 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "AssetLoading/IAssetLoadingManager.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -12,7 +12,8 @@ namespace IW4
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;
void FinalizeAssetsForZone(AssetLoadingContext* context) const override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderPhysCollmap.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderPhysCollmap::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,16 +1,16 @@
#include "AssetLoaderPhysPreset.h"
#include "Game/IW4/IW4.h"
#include "Game/IW4/InfoString/InfoStringToStructConverter.h"
#include "Game/IW4/InfoString/PhysPresetFields.h"
#include "Game/IW4/ObjConstantsIW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
#include <iostream>
#include <limits>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "Game/IW4/ObjConstantsIW4.h"
#include "Game/IW4/InfoString/InfoStringToStructConverter.h"
#include "Game/IW4/InfoString/PhysPresetFields.h"
#include "Pool/GlobalAssetPool.h"
using namespace IW4;
namespace IW4
@ -25,13 +25,18 @@ namespace IW4
}
public:
InfoStringToPhysPresetConverter(const InfoString& infoString, PhysPresetInfo* physPreset, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager,
const cspField_t* fields, const size_t fieldCount)
InfoStringToPhysPresetConverter(const InfoString& infoString,
PhysPresetInfo* physPreset,
ZoneScriptStrings& zoneScriptStrings,
MemoryManager* memory,
IAssetLoadingManager* manager,
const cspField_t* fields,
const size_t fieldCount)
: InfoStringToStructConverter(infoString, physPreset, zoneScriptStrings, memory, manager, fields, fieldCount)
{
}
};
}
} // namespace IW4
void AssetLoaderPhysPreset::CopyFromPhysPresetInfo(const PhysPresetInfo* physPresetInfo, PhysPreset* physPreset)
{
@ -52,11 +57,13 @@ void AssetLoaderPhysPreset::CopyFromPhysPresetInfo(const PhysPresetInfo* physPre
physPreset->perSurfaceSndAlias = physPresetInfo->perSurfaceSndAlias != 0;
}
bool AssetLoaderPhysPreset::LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
bool AssetLoaderPhysPreset::LoadFromInfoString(
const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
{
const auto presetInfo = std::make_unique<PhysPresetInfo>();
memset(presetInfo.get(), 0, sizeof(PhysPresetInfo));
InfoStringToPhysPresetConverter converter(infoString, presetInfo.get(), zone->m_script_strings, memory, manager, phys_preset_fields, std::extent<decltype(phys_preset_fields)>::value);
InfoStringToPhysPresetConverter converter(
infoString, presetInfo.get(), zone->m_script_strings, memory, manager, phys_preset_fields, std::extent<decltype(phys_preset_fields)>::value);
if (!converter.Convert())
{
std::cout << "Failed to parse phys preset: \"" << assetName << "\"" << std::endl;
@ -86,7 +93,8 @@ bool AssetLoaderPhysPreset::CanLoadFromGdt() const
return true;
}
bool AssetLoaderPhysPreset::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderPhysPreset::LoadFromGdt(
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_PHYS_PRESET, assetName);
if (gdtEntry == nullptr)
@ -107,7 +115,8 @@ bool AssetLoaderPhysPreset::CanLoadFromRaw() const
return true;
}
bool AssetLoaderPhysPreset::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderPhysPreset::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
const auto fileName = "physic/" + assetName;
const auto file = searchPath->Open(fileName);
@ -123,4 +132,3 @@ bool AssetLoaderPhysPreset::LoadFromRaw(const std::string& assetName, ISearchPat
return LoadFromInfoString(infoString, assetName, memory, manager, zone);
}

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "InfoString/InfoString.h"
#include "SearchPath/ISearchPath.h"
@ -11,13 +11,16 @@ namespace IW4
{
static void CopyFromPhysPresetInfo(const PhysPresetInfo* physPresetInfo, PhysPreset* physPreset);
static bool LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone);
static bool
LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone);
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
_NODISCARD bool CanLoadFromGdt() const override;
bool LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
bool LoadFromGdt(
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const 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 IW4

View File

@ -1,14 +1,14 @@
#include "AssetLoaderPixelShader.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstdint>
#include <cstring>
#include <iostream>
#include <sstream>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "Pool/GlobalAssetPool.h"
using namespace IW4;
void* AssetLoaderPixelShader::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
@ -31,14 +31,15 @@ std::string AssetLoaderPixelShader::GetFileNameForAsset(const std::string& asset
return ss.str();
}
bool AssetLoaderPixelShader::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderPixelShader::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
const auto fileName = GetFileNameForAsset(assetName);
const auto file = searchPath->Open(fileName);
if (!file.IsOpen())
return false;
if(file.m_length % sizeof(uint32_t) != 0)
if (file.m_length % sizeof(uint32_t) != 0)
{
std::cerr << "Invalid pixel shader \"" << assetName << "\": Size must be dividable by " << sizeof(uint32_t) << "\n";
return false;

View File

@ -1,11 +1,11 @@
#pragma once
#include <string>
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
#include <string>
namespace IW4
{
class AssetLoaderPixelShader final : public BasicAssetLoader<ASSET_TYPE_PIXELSHADER, MaterialPixelShader>
@ -15,6 +15,7 @@ namespace IW4
_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 IW4

View File

@ -1,10 +1,10 @@
#include "AssetLoaderRawFile.h"
#include <cstring>
#include "Game/IW4/IW4.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderRawFile::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
@ -20,7 +20,8 @@ bool AssetLoaderRawFile::CanLoadFromRaw() const
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())

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "AssetLoading/IAssetLoadingManager.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,6 +11,7 @@ namespace IW4
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 IW4

View File

@ -1,14 +1,14 @@
#include "AssetLoaderSndCurve.h"
#include "AssetLoading/SndCurve/SndCurveReader.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
#include <iostream>
#include <sstream>
#include "ObjLoading.h"
#include "AssetLoading/SndCurve/SndCurveReader.h"
#include "Game/IW4/IW4.h"
#include "Pool/GlobalAssetPool.h"
using namespace IW4;
std::string AssetLoaderSndCurve::GetAssetFilename(const std::string& assetName)
@ -33,7 +33,8 @@ bool AssetLoaderSndCurve::CanLoadFromRaw() const
return true;
}
bool AssetLoaderSndCurve::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderSndCurve::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
const auto filename = GetAssetFilename(assetName);
const auto file = searchPath->Open(filename);
@ -47,7 +48,7 @@ bool AssetLoaderSndCurve::LoadFromRaw(const std::string& assetName, ISearchPath*
if (!sndCurveData)
return false;
if(sndCurveData->m_knots.size() > std::extent_v<decltype(SndCurve::knots)>)
if (sndCurveData->m_knots.size() > std::extent_v<decltype(SndCurve::knots)>)
{
std::cerr << "Failed to load SndCurve \"" << assetName << "\": Too many knots (" << sndCurveData->m_knots.size() << ")\n";
return false;
@ -57,9 +58,9 @@ bool AssetLoaderSndCurve::LoadFromRaw(const std::string& assetName, ISearchPath*
sndCurve->filename = memory->Dup(assetName.c_str());
sndCurve->knotCount = static_cast<uint16_t>(sndCurveData->m_knots.size());
for(auto i = 0u; i < std::extent_v<decltype(SndCurve::knots)>; i++)
for (auto i = 0u; i < std::extent_v<decltype(SndCurve::knots)>; i++)
{
if(i < sndCurveData->m_knots.size())
if (i < sndCurveData->m_knots.size())
{
const auto& [x, y] = sndCurveData->m_knots[i];
sndCurve->knots[i][0] = static_cast<float>(x);

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -13,6 +13,7 @@ namespace IW4
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 IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderSoundAliasList.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderSoundAliasList::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,13 +1,13 @@
#include "AssetLoaderStringTable.h"
#include <cstring>
#include "ObjLoading.h"
#include "Csv/CsvStream.h"
#include "Game/IW4/CommonIW4.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderStringTable::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
@ -23,7 +23,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())

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,6 +11,7 @@ namespace IW4
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 IW4

View File

@ -1,13 +1,13 @@
#include "AssetLoaderStructuredDataDefSet.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "StructuredDataDef/StructuredDataDefReader.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include "StructuredDataDef/StructuredDataDefReader.h"
#include "Utils/Alignment.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderStructuredDataDefSet::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
@ -88,7 +88,8 @@ void AssetLoaderStructuredDataDefSet::ConvertStruct(StructuredDataStruct* output
inputStruct->SortPropertiesByName();
if (!inputStruct->m_properties.empty())
{
outputStruct->properties = static_cast<StructuredDataStructProperty*>(memory->Alloc(sizeof(StructuredDataStructProperty) * inputStruct->m_properties.size()));
outputStruct->properties =
static_cast<StructuredDataStructProperty*>(memory->Alloc(sizeof(StructuredDataStructProperty) * inputStruct->m_properties.size()));
for (auto propertyIndex = 0u; propertyIndex < inputStruct->m_properties.size(); propertyIndex++)
{
auto& outputProperty = outputStruct->properties[propertyIndex];
@ -110,14 +111,18 @@ void AssetLoaderStructuredDataDefSet::ConvertStruct(StructuredDataStruct* output
outputStruct->properties = nullptr;
}
void AssetLoaderStructuredDataDefSet::ConvertIndexedArray(StructuredDataIndexedArray* outputIndexedArray, const CommonStructuredDataIndexedArray* inputIndexedArray, MemoryManager* memory)
void AssetLoaderStructuredDataDefSet::ConvertIndexedArray(StructuredDataIndexedArray* outputIndexedArray,
const CommonStructuredDataIndexedArray* inputIndexedArray,
MemoryManager* memory)
{
outputIndexedArray->arraySize = static_cast<int>(inputIndexedArray->m_element_count);
outputIndexedArray->elementType = ConvertType(inputIndexedArray->m_array_type);
outputIndexedArray->elementSize = utils::Align(inputIndexedArray->m_element_size_in_bits, 8u) / 8u;
}
void AssetLoaderStructuredDataDefSet::ConvertEnumedArray(StructuredDataEnumedArray* outputEnumedArray, const CommonStructuredDataEnumedArray* inputEnumedArray, MemoryManager* memory)
void AssetLoaderStructuredDataDefSet::ConvertEnumedArray(StructuredDataEnumedArray* outputEnumedArray,
const CommonStructuredDataEnumedArray* inputEnumedArray,
MemoryManager* memory)
{
outputEnumedArray->enumIndex = static_cast<int>(inputEnumedArray->m_enum_index);
outputEnumedArray->elementType = ConvertType(inputEnumedArray->m_array_type);
@ -152,7 +157,8 @@ void AssetLoaderStructuredDataDefSet::ConvertDef(StructuredDataDef* outputDef, c
outputDef->indexedArrayCount = static_cast<int>(inputDef->m_indexed_arrays.size());
if (!inputDef->m_indexed_arrays.empty())
{
outputDef->indexedArrays = static_cast<StructuredDataIndexedArray*>(memory->Alloc(sizeof(StructuredDataIndexedArray) * inputDef->m_indexed_arrays.size()));
outputDef->indexedArrays =
static_cast<StructuredDataIndexedArray*>(memory->Alloc(sizeof(StructuredDataIndexedArray) * inputDef->m_indexed_arrays.size()));
for (auto indexedArrayIndex = 0u; indexedArrayIndex < inputDef->m_indexed_arrays.size(); indexedArrayIndex++)
ConvertIndexedArray(&outputDef->indexedArrays[indexedArrayIndex], &inputDef->m_indexed_arrays[indexedArrayIndex], memory);
}
@ -173,7 +179,9 @@ void AssetLoaderStructuredDataDefSet::ConvertDef(StructuredDataDef* outputDef, c
outputDef->size = inputDef->m_size_in_byte;
}
StructuredDataDefSet* AssetLoaderStructuredDataDefSet::ConvertSet(const std::string& assetName, const std::vector<std::unique_ptr<CommonStructuredDataDef>>& defs, MemoryManager* memory)
StructuredDataDefSet* AssetLoaderStructuredDataDefSet::ConvertSet(const std::string& assetName,
const std::vector<std::unique_ptr<CommonStructuredDataDef>>& defs,
MemoryManager* memory)
{
auto* set = memory->Create<StructuredDataDefSet>();
set->name = memory->Dup(assetName.c_str());
@ -186,20 +194,23 @@ StructuredDataDefSet* AssetLoaderStructuredDataDefSet::ConvertSet(const std::str
return set;
}
bool AssetLoaderStructuredDataDefSet::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderStructuredDataDefSet::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
const auto file = searchPath->Open(assetName);
if (!file.IsOpen())
return false;
StructuredDataDefReader reader(*file.m_stream, assetName, [searchPath](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
{
auto foundFileToInclude = searchPath->Open(filename);
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
return nullptr;
StructuredDataDefReader reader(*file.m_stream,
assetName,
[searchPath](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
{
auto foundFileToInclude = searchPath->Open(filename);
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
return nullptr;
return std::move(foundFileToInclude.m_stream);
});
return std::move(foundFileToInclude.m_stream);
});
bool readingDefsSuccessful;
const auto defs = reader.ReadStructureDataDefs(readingDefsSuccessful);

View File

@ -1,9 +1,9 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "StructuredDataDef/CommonStructuredDataDef.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
#include "StructuredDataDef/CommonStructuredDataDef.h"
namespace IW4
{
@ -15,10 +15,15 @@ namespace IW4
static StructuredDataType ConvertType(CommonStructuredDataType inputType);
static void ConvertEnum(StructuredDataEnum* outputEnum, CommonStructuredDataEnum* inputEnum, MemoryManager* memory);
static void ConvertStruct(StructuredDataStruct* outputStruct, CommonStructuredDataStruct* inputStruct, MemoryManager* memory);
static void ConvertIndexedArray(StructuredDataIndexedArray* outputIndexedArray, const CommonStructuredDataIndexedArray* inputIndexedArray, MemoryManager* memory);
static void ConvertEnumedArray(StructuredDataEnumedArray* outputEnumedArray, const CommonStructuredDataEnumedArray* inputEnumedArray, MemoryManager* memory);
static void ConvertIndexedArray(StructuredDataIndexedArray* outputIndexedArray,
const CommonStructuredDataIndexedArray* inputIndexedArray,
MemoryManager* memory);
static void
ConvertEnumedArray(StructuredDataEnumedArray* outputEnumedArray, const CommonStructuredDataEnumedArray* inputEnumedArray, MemoryManager* memory);
static void ConvertDef(StructuredDataDef* outputDef, const CommonStructuredDataDef* inputDef, MemoryManager* memory);
static StructuredDataDefSet* ConvertSet(const std::string& assetName, const std::vector<std::unique_ptr<CommonStructuredDataDef>>& defs, MemoryManager* memory);
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
static StructuredDataDefSet*
ConvertSet(const std::string& assetName, const std::vector<std::unique_ptr<CommonStructuredDataDef>>& defs, MemoryManager* memory);
bool
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
};
}
} // namespace IW4

View File

@ -1,26 +1,26 @@
#include "AssetLoaderTechniqueSet.h"
#include "AssetLoaderPixelShader.h"
#include "AssetLoaderVertexShader.h"
#include "Game/IW4/IW4.h"
#include "Game/IW4/TechsetConstantsIW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include "Shader/D3D9ShaderAnalyser.h"
#include "StateMap/StateMapReader.h"
#include "Techset/TechniqueFileReader.h"
#include "Techset/TechniqueStateMapCache.h"
#include "Techset/TechsetDefinitionCache.h"
#include "Techset/TechsetFileReader.h"
#include "Utils/Alignment.h"
#include "Utils/ClassUtils.h"
#include <cstring>
#include <iostream>
#include <memory>
#include <unordered_map>
#include <sstream>
#include <type_traits>
#include "AssetLoaderPixelShader.h"
#include "AssetLoaderVertexShader.h"
#include "Utils/ClassUtils.h"
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "Game/IW4/TechsetConstantsIW4.h"
#include "Pool/GlobalAssetPool.h"
#include "Techset/TechniqueFileReader.h"
#include "Techset/TechsetFileReader.h"
#include "Shader/D3D9ShaderAnalyser.h"
#include "StateMap/StateMapReader.h"
#include "Techset/TechniqueStateMapCache.h"
#include "Techset/TechsetDefinitionCache.h"
#include "Utils/Alignment.h"
#include <unordered_map>
using namespace IW4;
using namespace std::string_literals;
@ -61,7 +61,8 @@ namespace IW4
const LoadedTechnique* AddLoadedTechnique(std::string techniqueName, MaterialTechnique* technique, std::vector<XAssetInfoGeneric*> dependencies)
{
return m_loaded_techniques.emplace(std::make_pair(std::move(techniqueName), std::make_unique<LoadedTechnique>(technique, std::move(dependencies)))).first->second.get();
return m_loaded_techniques.emplace(std::make_pair(std::move(techniqueName), std::make_unique<LoadedTechnique>(technique, std::move(dependencies))))
.first->second.get();
}
literal_t GetAllocatedLiteral(MemoryManager* memory, techset::ShaderArgumentLiteralSource source)
@ -205,7 +206,11 @@ namespace IW4
std::vector<Pass> m_passes;
std::vector<XAssetInfoGeneric*> m_dependencies;
TechniqueCreator(const std::string& techniqueName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, TechniqueZoneLoadingState* zoneState,
TechniqueCreator(const std::string& techniqueName,
ISearchPath* searchPath,
MemoryManager* memory,
IAssetLoadingManager* manager,
TechniqueZoneLoadingState* zoneState,
ShaderInfoFromFileSystemCacheState* shaderInfoCache,
techset::TechniqueStateMapCache* stateMapCache)
: m_technique_name(techniqueName),
@ -225,20 +230,22 @@ namespace IW4
static size_t RegisterCountPerElement(const d3d9::ShaderConstant& constant)
{
const auto valuesPerRegister = constant.m_register_set == d3d9::RegisterSet::BOOL || constant.m_register_set == d3d9::RegisterSet::SAMPLER ? 1u : 4u;
const auto valuesPerRegister =
constant.m_register_set == d3d9::RegisterSet::BOOL || constant.m_register_set == d3d9::RegisterSet::SAMPLER ? 1u : 4u;
return utils::Align(constant.m_type_columns * constant.m_type_rows, valuesPerRegister) / valuesPerRegister;
}
static bool IsSamplerArgument(const d3d9::ShaderConstant& constant)
{
return constant.m_type == d3d9::ParameterType::SAMPLER
|| constant.m_type == d3d9::ParameterType::SAMPLER_1D
|| constant.m_type == d3d9::ParameterType::SAMPLER_2D
|| constant.m_type == d3d9::ParameterType::SAMPLER_3D
|| constant.m_type == d3d9::ParameterType::SAMPLER_CUBE;
return constant.m_type == d3d9::ParameterType::SAMPLER || constant.m_type == d3d9::ParameterType::SAMPLER_1D
|| constant.m_type == d3d9::ParameterType::SAMPLER_2D || constant.m_type == d3d9::ParameterType::SAMPLER_3D
|| constant.m_type == d3d9::ParameterType::SAMPLER_CUBE;
}
bool AutoCreateShaderArgument(const techset::ShaderSelector shaderType, const d3d9::ShaderConstant& shaderArgument, const size_t elementOffset, const size_t registerOffset)
bool AutoCreateShaderArgument(const techset::ShaderSelector shaderType,
const d3d9::ShaderConstant& shaderArgument,
const size_t elementOffset,
const size_t registerOffset)
{
assert(!m_passes.empty());
auto& pass = m_passes.at(m_passes.size() - 1);
@ -367,7 +374,8 @@ namespace IW4
assert(!m_passes.empty());
auto& pass = m_passes.at(m_passes.size() - 1);
std::sort(std::begin(pass.m_vertex_decl.routing.data), std::begin(pass.m_vertex_decl.routing.data) + pass.m_vertex_decl.streamCount,
std::sort(std::begin(pass.m_vertex_decl.routing.data),
std::begin(pass.m_vertex_decl.routing.data) + pass.m_vertex_decl.streamCount,
[](const MaterialStreamRouting& r1, const MaterialStreamRouting& r2)
{
return r1.source < r2.source;
@ -395,19 +403,22 @@ namespace IW4
return false;
// Sort args by their update frequency
std::sort(pass.m_arguments.begin(), pass.m_arguments.end(), [](const PassShaderArgument& arg1, const PassShaderArgument& arg2)
{
if (arg1.m_update_frequency != arg2.m_update_frequency)
return arg1.m_update_frequency < arg2.m_update_frequency;
std::sort(pass.m_arguments.begin(),
pass.m_arguments.end(),
[](const PassShaderArgument& arg1, const PassShaderArgument& arg2)
{
if (arg1.m_update_frequency != arg2.m_update_frequency)
return arg1.m_update_frequency < arg2.m_update_frequency;
if (arg1.m_arg.type != arg2.m_arg.type)
return arg1.m_arg.type < arg2.m_arg.type;
if (arg1.m_arg.type != arg2.m_arg.type)
return arg1.m_arg.type < arg2.m_arg.type;
if (arg1.m_arg.type == MTL_ARG_MATERIAL_VERTEX_CONST || arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_CONST || arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_SAMPLER)
return arg1.m_arg.u.codeSampler < arg2.m_arg.u.codeSampler;
if (arg1.m_arg.type == MTL_ARG_MATERIAL_VERTEX_CONST || arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_CONST
|| arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_SAMPLER)
return arg1.m_arg.u.codeSampler < arg2.m_arg.u.codeSampler;
return arg1.m_arg.dest < arg2.m_arg.dest;
});
return arg1.m_arg.dest < arg2.m_arg.dest;
});
AllocateVertexDecl();
@ -430,7 +441,9 @@ namespace IW4
return true;
}
static void InitializeArgumentState(const d3d9::ShaderInfo& shaderInfo, std::vector<size_t>& argumentHandledOffsetVector, std::vector<bool>& argumentHandledVector)
static void InitializeArgumentState(const d3d9::ShaderInfo& shaderInfo,
std::vector<size_t>& argumentHandledOffsetVector,
std::vector<bool>& argumentHandledVector)
{
auto vertexShaderArgumentSlotCount = 0u;
auto argIndex = 0u;
@ -464,7 +477,8 @@ namespace IW4
if (pass.m_vertex_shader->Asset()->name && pass.m_vertex_shader->Asset()->name[0] == ',')
{
pass.m_vertex_shader_info = m_shader_info_cache->LoadShaderInfoFromDisk(m_search_path, AssetLoaderVertexShader::GetFileNameForAsset(vertexShaderName));
pass.m_vertex_shader_info =
m_shader_info_cache->LoadShaderInfoFromDisk(m_search_path, AssetLoaderVertexShader::GetFileNameForAsset(vertexShaderName));
}
else
{
@ -503,7 +517,8 @@ namespace IW4
if (pass.m_pixel_shader->Asset()->name && pass.m_pixel_shader->Asset()->name[0] == ',')
{
pass.m_pixel_shader_info = m_shader_info_cache->LoadShaderInfoFromDisk(m_search_path, AssetLoaderPixelShader::GetFileNameForAsset(pixelShaderName));
pass.m_pixel_shader_info =
m_shader_info_cache->LoadShaderInfoFromDisk(m_search_path, AssetLoaderPixelShader::GetFileNameForAsset(pixelShaderName));
}
else
{
@ -579,12 +594,18 @@ namespace IW4
return foundSource;
}
bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo, const techset::ShaderArgument& argument, size_t& constantIndex, size_t& registerOffset, std::string& errorMessage) const
bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo,
const techset::ShaderArgument& argument,
size_t& constantIndex,
size_t& registerOffset,
std::string& errorMessage) const
{
const auto matchingShaderConstant = std::find_if(shaderInfo.m_constants.begin(), shaderInfo.m_constants.end(), [argument](const d3d9::ShaderConstant& constant)
{
return constant.m_name == argument.m_argument_name;
});
const auto matchingShaderConstant = std::find_if(shaderInfo.m_constants.begin(),
shaderInfo.m_constants.end(),
[argument](const d3d9::ShaderConstant& constant)
{
return constant.m_name == argument.m_argument_name;
});
if (matchingShaderConstant == shaderInfo.m_constants.end())
{
@ -623,8 +644,12 @@ namespace IW4
return true;
}
static bool SetArgumentCodeConst(MaterialShaderArgument& argument, const techset::ShaderArgumentCodeSource& source, const d3d9::ShaderConstant& shaderConstant, const unsigned sourceIndex,
const unsigned arrayCount, std::string& errorMessage)
static bool SetArgumentCodeConst(MaterialShaderArgument& argument,
const techset::ShaderArgumentCodeSource& source,
const d3d9::ShaderConstant& shaderConstant,
const unsigned sourceIndex,
const unsigned arrayCount,
std::string& errorMessage)
{
if (arrayCount > 0u)
{
@ -657,8 +682,12 @@ namespace IW4
return true;
}
static bool SetArgumentCodeSampler(MaterialShaderArgument& argument, const techset::ShaderArgumentCodeSource& source, const d3d9::ShaderConstant& shaderConstant, const unsigned sourceIndex,
const unsigned arrayCount, std::string& errorMessage)
static bool SetArgumentCodeSampler(MaterialShaderArgument& argument,
const techset::ShaderArgumentCodeSource& source,
const d3d9::ShaderConstant& shaderConstant,
const unsigned sourceIndex,
const unsigned arrayCount,
std::string& errorMessage)
{
if (arrayCount > 0u)
{
@ -689,7 +718,9 @@ namespace IW4
return true;
}
bool AcceptVertexShaderConstantArgument(const techset::ShaderArgument& shaderArgument, const techset::ShaderArgumentCodeSource& source, std::string& errorMessage)
bool AcceptVertexShaderConstantArgument(const techset::ShaderArgument& shaderArgument,
const techset::ShaderArgumentCodeSource& source,
std::string& errorMessage)
{
assert(!m_passes.empty());
auto& pass = m_passes.at(m_passes.size() - 1);
@ -737,7 +768,10 @@ namespace IW4
return true;
}
bool AcceptPixelShaderCodeArgument(const techset::ShaderArgument& shaderArgument, const techset::ShaderArgumentCodeSource& source, std::string& errorMessage, const bool isSampler)
bool AcceptPixelShaderCodeArgument(const techset::ShaderArgument& shaderArgument,
const techset::ShaderArgumentCodeSource& source,
std::string& errorMessage,
const bool isSampler)
{
assert(!m_passes.empty());
auto& pass = m_passes.at(m_passes.size() - 1);
@ -809,14 +843,15 @@ namespace IW4
return false;
}
pass.m_arguments.emplace_back(argument);
pass.m_handled_pixel_shader_arguments[pass.m_pixel_shader_argument_handled_offset[shaderConstantIndex] + elementOffset] = true;
return true;
}
bool AcceptShaderConstantArgument(const techset::ShaderSelector shader, const techset::ShaderArgument shaderArgument, const techset::ShaderArgumentCodeSource source,
bool AcceptShaderConstantArgument(const techset::ShaderSelector shader,
const techset::ShaderArgument shaderArgument,
const techset::ShaderArgumentCodeSource source,
std::string& errorMessage) override
{
if (shader == techset::ShaderSelector::VERTEX_SHADER)
@ -826,7 +861,9 @@ namespace IW4
return AcceptPixelShaderCodeArgument(shaderArgument, source, errorMessage, false);
}
bool AcceptShaderSamplerArgument(const techset::ShaderSelector shader, const techset::ShaderArgument shaderArgument, const techset::ShaderArgumentCodeSource source,
bool AcceptShaderSamplerArgument(const techset::ShaderSelector shader,
const techset::ShaderArgument shaderArgument,
const techset::ShaderArgumentCodeSource source,
std::string& errorMessage) override
{
if (shader == techset::ShaderSelector::VERTEX_SHADER)
@ -839,7 +876,10 @@ namespace IW4
return AcceptPixelShaderCodeArgument(shaderArgument, source, errorMessage, true);
}
bool AcceptShaderLiteralArgument(const techset::ShaderSelector shader, techset::ShaderArgument shaderArgument, techset::ShaderArgumentLiteralSource source, std::string& errorMessage) override
bool AcceptShaderLiteralArgument(const techset::ShaderSelector shader,
techset::ShaderArgument shaderArgument,
techset::ShaderArgumentLiteralSource source,
std::string& errorMessage) override
{
assert(!m_passes.empty());
auto& pass = m_passes.at(m_passes.size() - 1);
@ -895,7 +935,9 @@ namespace IW4
return true;
}
bool AcceptShaderMaterialArgument(const techset::ShaderSelector shader, techset::ShaderArgument shaderArgument, const techset::ShaderArgumentMaterialSource source,
bool AcceptShaderMaterialArgument(const techset::ShaderSelector shader,
techset::ShaderArgument shaderArgument,
const techset::ShaderArgumentMaterialSource source,
std::string& errorMessage) override
{
assert(!m_passes.empty());
@ -1010,52 +1052,53 @@ namespace IW4
static void UpdateTechniqueFlags(MaterialTechnique& technique)
{
// This is stupid but that's what the game does for zprepass for sure
// The other ones might be handled by the game in the same fashion because there is not recognizable pattern that connects the shaders with the same flags
// The other ones might be handled by the game in the same fashion because there is not recognizable pattern that connects the shaders with the same
// flags
static std::unordered_map<std::string, size_t> flagsByTechniqueName({
{"zprepass", TECHNIQUE_FLAG_4 | TECHNIQUE_FLAG_200},
{"build_floatz", TECHNIQUE_FLAG_8},
{"build_shadowmap_depth", TECHNIQUE_FLAG_10 | TECHNIQUE_FLAG_200},
{"build_shadowmap_model", TECHNIQUE_FLAG_10 | TECHNIQUE_FLAG_200},
{"distortion_scale_ua_zfeather", TECHNIQUE_FLAG_100},
{"distortion_scale_zfeather", TECHNIQUE_FLAG_100},
{"distortion_scale_zfeather_dtex", TECHNIQUE_FLAG_100},
{"alternate_scene_overlay", TECHNIQUE_FLAG_200},
{"blur_apply", TECHNIQUE_FLAG_200},
{"build_floatz", TECHNIQUE_FLAG_200},
{"build_floatz_clear", TECHNIQUE_FLAG_200},
{"build_floatz_dtex", TECHNIQUE_FLAG_200},
{"build_floatz_ua", TECHNIQUE_FLAG_200},
{"build_floatz_ua_dtex", TECHNIQUE_FLAG_200},
{"build_shadowmap_depth_nc", TECHNIQUE_FLAG_200},
{"build_shadowmap_depth_ua", TECHNIQUE_FLAG_200},
{"build_shadowmap_model_dtex", TECHNIQUE_FLAG_200},
{"build_shadowmap_model_nc_dtex", TECHNIQUE_FLAG_200},
{"build_shadowmap_model_ua", TECHNIQUE_FLAG_200},
{"cinematic", TECHNIQUE_FLAG_200},
{"cinematic_3d", TECHNIQUE_FLAG_200},
{"cinematic_dtex_3d", TECHNIQUE_FLAG_200},
{"dof_near_coc", TECHNIQUE_FLAG_200},
{"floatz", TECHNIQUE_FLAG_200},
{"floatzdisplay", TECHNIQUE_FLAG_200},
{"particle_blend", TECHNIQUE_FLAG_200},
{"particle_zdownsample", TECHNIQUE_FLAG_200},
{"passthru_alpha", TECHNIQUE_FLAG_200},
{"postfx", TECHNIQUE_FLAG_200},
{"postfx_mblur", TECHNIQUE_FLAG_200},
{"processed_floatz", TECHNIQUE_FLAG_200},
{"ps3_aadownsample", TECHNIQUE_FLAG_200},
{"shell_shock", TECHNIQUE_FLAG_200},
{"shell_shock_flashed", TECHNIQUE_FLAG_200},
{"small_blur", TECHNIQUE_FLAG_200},
{"stencildisplay", TECHNIQUE_FLAG_200},
{"stencilshadow", TECHNIQUE_FLAG_200},
{"wireframe_solid", TECHNIQUE_FLAG_200},
{"wireframe_solid_atest_dtex", TECHNIQUE_FLAG_200},
{"wireframe_solid_dtex", TECHNIQUE_FLAG_200},
{"wireframe_solid_nc", TECHNIQUE_FLAG_200},
{"wireframe_solid_nc_dtex", TECHNIQUE_FLAG_200},
{"wireframe_solid_ua", TECHNIQUE_FLAG_200},
{"wireframe_solid_ua_dtex", TECHNIQUE_FLAG_200}
{"zprepass", TECHNIQUE_FLAG_4 | TECHNIQUE_FLAG_200 },
{"build_floatz", TECHNIQUE_FLAG_8 },
{"build_shadowmap_depth", TECHNIQUE_FLAG_10 | TECHNIQUE_FLAG_200},
{"build_shadowmap_model", TECHNIQUE_FLAG_10 | TECHNIQUE_FLAG_200},
{"distortion_scale_ua_zfeather", TECHNIQUE_FLAG_100 },
{"distortion_scale_zfeather", TECHNIQUE_FLAG_100 },
{"distortion_scale_zfeather_dtex", TECHNIQUE_FLAG_100 },
{"alternate_scene_overlay", TECHNIQUE_FLAG_200 },
{"blur_apply", TECHNIQUE_FLAG_200 },
{"build_floatz", TECHNIQUE_FLAG_200 },
{"build_floatz_clear", TECHNIQUE_FLAG_200 },
{"build_floatz_dtex", TECHNIQUE_FLAG_200 },
{"build_floatz_ua", TECHNIQUE_FLAG_200 },
{"build_floatz_ua_dtex", TECHNIQUE_FLAG_200 },
{"build_shadowmap_depth_nc", TECHNIQUE_FLAG_200 },
{"build_shadowmap_depth_ua", TECHNIQUE_FLAG_200 },
{"build_shadowmap_model_dtex", TECHNIQUE_FLAG_200 },
{"build_shadowmap_model_nc_dtex", TECHNIQUE_FLAG_200 },
{"build_shadowmap_model_ua", TECHNIQUE_FLAG_200 },
{"cinematic", TECHNIQUE_FLAG_200 },
{"cinematic_3d", TECHNIQUE_FLAG_200 },
{"cinematic_dtex_3d", TECHNIQUE_FLAG_200 },
{"dof_near_coc", TECHNIQUE_FLAG_200 },
{"floatz", TECHNIQUE_FLAG_200 },
{"floatzdisplay", TECHNIQUE_FLAG_200 },
{"particle_blend", TECHNIQUE_FLAG_200 },
{"particle_zdownsample", TECHNIQUE_FLAG_200 },
{"passthru_alpha", TECHNIQUE_FLAG_200 },
{"postfx", TECHNIQUE_FLAG_200 },
{"postfx_mblur", TECHNIQUE_FLAG_200 },
{"processed_floatz", TECHNIQUE_FLAG_200 },
{"ps3_aadownsample", TECHNIQUE_FLAG_200 },
{"shell_shock", TECHNIQUE_FLAG_200 },
{"shell_shock_flashed", TECHNIQUE_FLAG_200 },
{"small_blur", TECHNIQUE_FLAG_200 },
{"stencildisplay", TECHNIQUE_FLAG_200 },
{"stencilshadow", TECHNIQUE_FLAG_200 },
{"wireframe_solid", TECHNIQUE_FLAG_200 },
{"wireframe_solid_atest_dtex", TECHNIQUE_FLAG_200 },
{"wireframe_solid_dtex", TECHNIQUE_FLAG_200 },
{"wireframe_solid_nc", TECHNIQUE_FLAG_200 },
{"wireframe_solid_nc_dtex", TECHNIQUE_FLAG_200 },
{"wireframe_solid_ua", TECHNIQUE_FLAG_200 },
{"wireframe_solid_ua_dtex", TECHNIQUE_FLAG_200 },
});
const auto flagsForName = flagsByTechniqueName.find(technique.name);
@ -1140,19 +1183,19 @@ namespace IW4
stableArgCount++;
break;
case MTL_UPDATE_CUSTOM:
{
assert(arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER);
if (arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER)
{
assert(arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER);
if (arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER)
const auto customSampler = std::find(std::begin(g_customSamplerSrc), std::end(g_customSamplerSrc), arg.m_arg.u.codeSampler);
assert(customSampler != std::end(g_customSamplerSrc));
if (customSampler != std::end(g_customSamplerSrc))
{
const auto customSampler = std::find(std::begin(g_customSamplerSrc), std::end(g_customSamplerSrc), arg.m_arg.u.codeSampler);
assert(customSampler != std::end(g_customSamplerSrc));
if (customSampler != std::end(g_customSamplerSrc))
{
const auto customSamplerIndex = customSampler - std::begin(g_customSamplerSrc);
out.customSamplerFlags |= 1 << customSamplerIndex;
}
const auto customSamplerIndex = customSampler - std::begin(g_customSamplerSrc);
out.customSamplerFlags |= 1 << customSamplerIndex;
}
}
}
continue;
default:
assert(false);
@ -1174,7 +1217,9 @@ namespace IW4
dependencies.push_back(in.m_vertex_decl_asset);
}
MaterialTechnique* ConvertTechnique(const std::string& techniqueName, const std::vector<TechniqueCreator::Pass>& passes, std::vector<XAssetInfoGeneric*>& dependencies) const
MaterialTechnique* ConvertTechnique(const std::string& techniqueName,
const std::vector<TechniqueCreator::Pass>& passes,
std::vector<XAssetInfoGeneric*>& dependencies) const
{
assert(!passes.empty());
const auto techniqueSize = sizeof(MaterialTechnique) + (passes.size() - 1u) * sizeof(MaterialPass);
@ -1231,7 +1276,7 @@ namespace IW4
return m_zone_state->AddLoadedTechnique(techniqueName, techniqueFromRaw, dependencies);
}
};
}
} // namespace IW4
void* AssetLoaderTechniqueSet::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
{
@ -1262,8 +1307,8 @@ std::string AssetLoaderTechniqueSet::GetStateMapFileName(const std::string& stat
return ss.str();
}
bool AssetLoaderTechniqueSet::CreateTechsetFromDefinition(const std::string& assetName, const techset::TechsetDefinition& definition, ISearchPath* searchPath, MemoryManager* memory,
IAssetLoadingManager* manager)
bool AssetLoaderTechniqueSet::CreateTechsetFromDefinition(
const std::string& assetName, const techset::TechsetDefinition& definition, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
{
auto* techset = memory->Create<MaterialTechniqueSet>();
memset(techset, 0, sizeof(MaterialTechniqueSet));
@ -1293,7 +1338,8 @@ bool AssetLoaderTechniqueSet::CreateTechsetFromDefinition(const std::string& ass
return true;
}
techset::TechsetDefinition* AssetLoaderTechniqueSet::LoadTechsetDefinition(const std::string& assetName, ISearchPath* searchPath, techset::TechsetDefinitionCache* definitionCache)
techset::TechsetDefinition*
AssetLoaderTechniqueSet::LoadTechsetDefinition(const std::string& assetName, ISearchPath* searchPath, techset::TechsetDefinitionCache* definitionCache)
{
auto* cachedTechsetDefinition = definitionCache->GetCachedTechsetDefinition(assetName);
if (cachedTechsetDefinition)
@ -1313,7 +1359,8 @@ techset::TechsetDefinition* AssetLoaderTechniqueSet::LoadTechsetDefinition(const
return techsetDefinitionPtr;
}
const state_map::StateMapDefinition* AssetLoaderTechniqueSet::LoadStateMapDefinition(const std::string& stateMapName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache)
const state_map::StateMapDefinition*
AssetLoaderTechniqueSet::LoadStateMapDefinition(const std::string& stateMapName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache)
{
auto* cachedStateMap = stateMapCache->GetCachedStateMap(stateMapName);
if (cachedStateMap)
@ -1341,7 +1388,8 @@ bool AssetLoaderTechniqueSet::CanLoadFromRaw() const
return true;
}
bool AssetLoaderTechniqueSet::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderTechniqueSet::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
auto* definitionCache = manager->GetAssetLoadingContext()->GetZoneAssetLoaderState<techset::TechsetDefinitionCache>();
const auto* techsetDefinition = LoadTechsetDefinition(assetName, searchPath, definitionCache);

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
#include "StateMap/StateMapDefinition.h"
#include "Techset/TechniqueStateMapCache.h"
@ -12,7 +12,10 @@ namespace IW4
{
class AssetLoaderTechniqueSet final : public BasicAssetLoader<ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet>
{
static bool CreateTechsetFromDefinition(const std::string& assetName, const techset::TechsetDefinition& definition, ISearchPath* searchPath, MemoryManager* memory,
static bool CreateTechsetFromDefinition(const std::string& assetName,
const techset::TechsetDefinition& definition,
ISearchPath* searchPath,
MemoryManager* memory,
IAssetLoadingManager* manager);
public:
@ -20,11 +23,14 @@ namespace IW4
static std::string GetTechniqueFileName(const std::string& techniqueName);
static std::string GetStateMapFileName(const std::string& stateMapName);
static techset::TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, ISearchPath* searchPath, techset::TechsetDefinitionCache* definitionCache);
static const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache);
static techset::TechsetDefinition*
LoadTechsetDefinition(const std::string& assetName, ISearchPath* searchPath, techset::TechsetDefinitionCache* definitionCache);
static const state_map::StateMapDefinition*
LoadStateMapDefinition(const std::string& stateMapName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache);
_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 IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderTracer.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderTracer::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderVehicle.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderVehicle::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,13 +1,13 @@
#include "AssetLoaderVertexDecl.h"
#include "Game/IW4/IW4.h"
#include "Game/IW4/TechsetConstantsIW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
#include <iostream>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "Game/IW4/TechsetConstantsIW4.h"
#include "Pool/GlobalAssetPool.h"
using namespace IW4;
void* AssetLoaderVertexDecl::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
@ -42,7 +42,8 @@ bool AssetLoaderVertexDecl::NextAbbreviation(const std::string& assetName, std::
return true;
}
bool AssetLoaderVertexDecl::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderVertexDecl::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
MaterialVertexDeclaration decl{};
@ -50,7 +51,7 @@ bool AssetLoaderVertexDecl::LoadFromRaw(const std::string& assetName, ISearchPat
std::string sourceAbbreviation;
while (NextAbbreviation(assetName, sourceAbbreviation, currentOffset))
{
if(decl.streamCount >= std::extent_v<decltype(MaterialVertexStreamRouting::data)>)
if (decl.streamCount >= std::extent_v<decltype(MaterialVertexStreamRouting::data)>)
{
std::cout << "Failed to add vertex decl stream. Too many abbreviations: " << assetName << "\n";
return false;
@ -63,14 +64,16 @@ bool AssetLoaderVertexDecl::LoadFromRaw(const std::string& assetName, ISearchPat
return false;
}
const auto foundSourceAbbreviation = std::find(std::begin(materialStreamSourceAbbreviation), std::end(materialStreamSourceAbbreviation), sourceAbbreviation);
const auto foundSourceAbbreviation =
std::find(std::begin(materialStreamSourceAbbreviation), std::end(materialStreamSourceAbbreviation), sourceAbbreviation);
if (foundSourceAbbreviation == std::end(materialStreamSourceAbbreviation))
{
std::cout << "Unknown vertex decl source abbreviation: " << sourceAbbreviation << "\n";
return false;
}
const auto foundDestinationAbbreviation = std::find(std::begin(materialStreamDestinationAbbreviation), std::end(materialStreamDestinationAbbreviation), destinationAbbreviation);
const auto foundDestinationAbbreviation =
std::find(std::begin(materialStreamDestinationAbbreviation), std::end(materialStreamDestinationAbbreviation), destinationAbbreviation);
if (foundDestinationAbbreviation == std::end(materialStreamDestinationAbbreviation))
{
std::cout << "Unknown vertex decl destination abbreviation: " << destinationAbbreviation << "\n";
@ -78,7 +81,8 @@ bool AssetLoaderVertexDecl::LoadFromRaw(const std::string& assetName, ISearchPat
}
const auto sourceIndex = static_cast<MaterialStreamStreamSource_e>(foundSourceAbbreviation - std::begin(materialStreamSourceAbbreviation));
const auto destinationIndex = static_cast<MaterialStreamDestination_e>(foundDestinationAbbreviation - std::begin(materialStreamDestinationAbbreviation));
const auto destinationIndex =
static_cast<MaterialStreamDestination_e>(foundDestinationAbbreviation - std::begin(materialStreamDestinationAbbreviation));
decl.routing.data[decl.streamCount].source = sourceIndex;
decl.routing.data[decl.streamCount].dest = destinationIndex;

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -14,6 +14,7 @@ namespace IW4
_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 IW4

View File

@ -1,14 +1,14 @@
#include "AssetLoaderVertexShader.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstdint>
#include <cstring>
#include <iostream>
#include <sstream>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "Pool/GlobalAssetPool.h"
using namespace IW4;
void* AssetLoaderVertexShader::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
@ -31,7 +31,8 @@ std::string AssetLoaderVertexShader::GetFileNameForAsset(const std::string& asse
return ss.str();
}
bool AssetLoaderVertexShader::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
bool AssetLoaderVertexShader::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
const auto fileName = GetFileNameForAsset(assetName);
const auto file = searchPath->Open(fileName);

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -13,6 +13,7 @@ namespace IW4
_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 IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderWeapon.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderWeapon::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderXAnim.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderXAnim::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderXModel.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderXModel::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -1,11 +1,11 @@
#include "AssetLoaderXModelSurfs.h"
#include <cstring>
#include "ObjLoading.h"
#include "Game/IW4/IW4.h"
#include "ObjLoading.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>
using namespace IW4;
void* AssetLoaderXModelSurfs::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)

View File

@ -1,7 +1,7 @@
#pragma once
#include "Game/IW4/IW4.h"
#include "AssetLoading/BasicAssetLoader.h"
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
namespace IW4
@ -11,4 +11,4 @@ namespace IW4
public:
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
};
}
} // namespace IW4

View File

@ -5,8 +5,13 @@
using namespace IW4;
InfoStringToStructConverter::InfoStringToStructConverter(const InfoString& infoString, void* structure, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager,
const cspField_t* fields, const size_t fieldCount)
InfoStringToStructConverter::InfoStringToStructConverter(const InfoString& infoString,
void* structure,
ZoneScriptStrings& zoneScriptStrings,
MemoryManager* memory,
IAssetLoadingManager* manager,
const cspField_t* fields,
const size_t fieldCount)
: InfoStringToStructConverterBase(infoString, structure, zoneScriptStrings, memory),
m_loading_manager(manager),
m_fields(fields),
@ -46,151 +51,151 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons
return ConvertMilliseconds(value, field.iOffset);
case CSPFT_FX:
{
if (value.empty())
{
if (value.empty())
{
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* fx = m_loading_manager->LoadDependency(ASSET_TYPE_FX, value);
if (fx == nullptr)
{
std::cout << "Failed to load fx asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(fx);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = fx->m_ptr;
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* fx = m_loading_manager->LoadDependency(ASSET_TYPE_FX, value);
if (fx == nullptr)
{
std::cout << "Failed to load fx asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(fx);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = fx->m_ptr;
return true;
}
case CSPFT_XMODEL:
{
if (value.empty())
{
if (value.empty())
{
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* xmodel = m_loading_manager->LoadDependency(ASSET_TYPE_XMODEL, value);
if (xmodel == nullptr)
{
std::cout << "Failed to load xmodel asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(xmodel);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = xmodel->m_ptr;
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* xmodel = m_loading_manager->LoadDependency(ASSET_TYPE_XMODEL, value);
if (xmodel == nullptr)
{
std::cout << "Failed to load xmodel asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(xmodel);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = xmodel->m_ptr;
return true;
}
case CSPFT_MATERIAL:
{
if (value.empty())
{
if (value.empty())
{
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* material = m_loading_manager->LoadDependency(ASSET_TYPE_MATERIAL, value);
if (material == nullptr)
{
std::cout << "Failed to load material asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(material);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = material->m_ptr;
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* material = m_loading_manager->LoadDependency(ASSET_TYPE_MATERIAL, value);
if (material == nullptr)
{
std::cout << "Failed to load material asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(material);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = material->m_ptr;
return true;
}
case CSPFT_TRACER:
{
if (value.empty())
{
if (value.empty())
{
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* tracer = m_loading_manager->LoadDependency(ASSET_TYPE_TRACER, value);
if (tracer == nullptr)
{
std::cout << "Failed to load tracer asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(tracer);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = tracer->m_ptr;
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* tracer = m_loading_manager->LoadDependency(ASSET_TYPE_TRACER, value);
if (tracer == nullptr)
{
std::cout << "Failed to load tracer asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(tracer);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = tracer->m_ptr;
return true;
}
case CSPFT_MPH_TO_INCHES_PER_SEC:
{
char* endPtr;
*reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = strtof(value.c_str(), &endPtr) * 17.6f;
if (endPtr != &value[value.size()])
{
char* endPtr;
*reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = strtof(value.c_str(), &endPtr) * 17.6f;
if (endPtr != &value[value.size()])
{
std::cout << "Failed to parse value \"" << value << "\" as mph" << std::endl;
return false;
}
return true;
std::cout << "Failed to parse value \"" << value << "\" as mph" << std::endl;
return false;
}
return true;
}
case CSPFT_PHYS_COLLMAP:
{
if (value.empty())
{
if (value.empty())
{
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* collmap = m_loading_manager->LoadDependency(ASSET_TYPE_PHYSCOLLMAP, value);
if (collmap == nullptr)
{
std::cout << "Failed to load collmap asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(collmap);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = collmap->m_ptr;
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* collmap = m_loading_manager->LoadDependency(ASSET_TYPE_PHYSCOLLMAP, value);
if (collmap == nullptr)
{
std::cout << "Failed to load collmap asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(collmap);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = collmap->m_ptr;
return true;
}
case CSPFT_SOUND:
{
if (value.empty())
{
if (value.empty())
{
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* sound = m_loading_manager->LoadDependency(ASSET_TYPE_SOUND, value);
if (sound == nullptr)
{
std::cout << "Failed to load sound asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(sound);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = sound->m_ptr;
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
return true;
}
auto* sound = m_loading_manager->LoadDependency(ASSET_TYPE_SOUND, value);
if (sound == nullptr)
{
std::cout << "Failed to load sound asset \"" << value << "\"" << std::endl;
return false;
}
m_dependencies.emplace(sound);
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = sound->m_ptr;
return true;
}
case CSPFT_NUM_BASE_FIELD_TYPES:
default:
assert(false);

View File

@ -1,7 +1,7 @@
#pragma once
#include "AssetLoading/IAssetLoadingManager.h"
#include "InfoString/InfoStringToStructConverterBase.h"
#include "Game/IW4/IW4.h"
#include "InfoString/InfoStringToStructConverterBase.h"
namespace IW4
{
@ -16,8 +16,13 @@ namespace IW4
bool ConvertBaseField(const cspField_t& field, const std::string& value);
public:
InfoStringToStructConverter(const InfoString& infoString, void* structure, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager, const cspField_t* fields,
size_t fieldCount);
InfoStringToStructConverter(const InfoString& infoString,
void* structure,
ZoneScriptStrings& zoneScriptStrings,
MemoryManager* memory,
IAssetLoadingManager* manager,
const cspField_t* fields,
size_t fieldCount);
bool Convert() override;
};
}
} // namespace IW4

View File

@ -1,10 +1,10 @@
#pragma once
#include <map>
#include "AssetLoading/IZoneAssetLoaderState.h"
#include "Game/IW4/IW4.h"
#include <map>
namespace IW4
{
class MenuConversionZoneState final : public IZoneAssetLoaderState
@ -36,4 +36,4 @@ namespace IW4
void FinalizeSupportingData() const;
};
}
} // namespace IW4

View File

@ -1,21 +1,21 @@
#include "MenuConverterIW4.h"
#include <cassert>
#include <cstring>
#include <sstream>
#include "MenuConversionZoneStateIW4.h"
#include "Utils/ClassUtils.h"
#include "Menu/AbstractMenuConverter.h"
#include "Parsing/Menu/MenuAssetZoneState.h"
#include "MenuConversionZoneStateIW4.h"
#include "Parsing/Menu/Domain/EventHandler/CommonEventHandlerCondition.h"
#include "Parsing/Menu/Domain/EventHandler/CommonEventHandlerScript.h"
#include "Parsing/Menu/Domain/EventHandler/CommonEventHandlerSetLocalVar.h"
#include "Parsing/Menu/Domain/Expression/CommonExpressionBaseFunctionCall.h"
#include "Parsing/Menu/Domain/Expression/CommonExpressionCustomFunctionCall.h"
#include "Parsing/Menu/MenuAssetZoneState.h"
#include "Parsing/Simple/Expression/SimpleExpressionBinaryOperation.h"
#include "Parsing/Simple/Expression/SimpleExpressionConditionalOperator.h"
#include "Parsing/Simple/Expression/SimpleExpressionUnaryOperation.h"
#include "Utils/ClassUtils.h"
#include <cassert>
#include <cstring>
#include <sstream>
using namespace IW4;
using namespace menu;
@ -35,7 +35,7 @@ namespace IW4
static_cast<float>(rect.w),
static_cast<float>(rect.h),
static_cast<unsigned char>(rect.horizontalAlign),
static_cast<unsigned char>(rect.verticalAlign)
static_cast<unsigned char>(rect.verticalAlign),
};
}
@ -47,7 +47,7 @@ namespace IW4
static_cast<float>(rect.w),
static_cast<float>(rect.h),
static_cast<unsigned char>(rect.horizontalAlign),
static_cast<unsigned char>(rect.verticalAlign)
static_cast<unsigned char>(rect.verticalAlign),
};
}
@ -101,7 +101,10 @@ namespace IW4
return static_cast<snd_alias_list_t*>(soundDependency->m_ptr);
}
bool HandleStaticDvarFunctionCall(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const CommonExpressionBaseFunctionCall* functionCall, const int targetFunctionIndex) const
bool HandleStaticDvarFunctionCall(Statement_s* gameStatement,
std::vector<expressionEntry>& entries,
const CommonExpressionBaseFunctionCall* functionCall,
const int targetFunctionIndex) const
{
if (functionCall->m_args.size() != 1)
return false;
@ -122,7 +125,8 @@ namespace IW4
expressionEntry staticDvarIndexEntry{};
staticDvarIndexEntry.type = EET_OPERAND;
staticDvarIndexEntry.data.operand.dataType = VAL_INT;
staticDvarIndexEntry.data.operand.internals.intVal = static_cast<int>(m_conversion_zone_state->AddStaticDvar(*staticDvarNameExpressionValue.m_string_value));
staticDvarIndexEntry.data.operand.internals.intVal =
static_cast<int>(m_conversion_zone_state->AddStaticDvar(*staticDvarNameExpressionValue.m_string_value));
entries.emplace_back(staticDvarIndexEntry);
expressionEntry parenRight{};
@ -135,7 +139,10 @@ namespace IW4
return true;
}
bool HandleSpecialBaseFunctionCall(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const CommonExpressionBaseFunctionCall* functionCall, const CommonMenuDef* menu,
bool HandleSpecialBaseFunctionCall(Statement_s* gameStatement,
std::vector<expressionEntry>& entries,
const CommonExpressionBaseFunctionCall* functionCall,
const CommonMenuDef* menu,
const CommonItemDef* item) const
{
switch (functionCall->m_function_index)
@ -155,7 +162,10 @@ namespace IW4
return false;
}
void ConvertExpressionEntryBaseFunctionCall(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const CommonExpressionBaseFunctionCall* functionCall, const CommonMenuDef* menu,
void ConvertExpressionEntryBaseFunctionCall(Statement_s* gameStatement,
std::vector<expressionEntry>& entries,
const CommonExpressionBaseFunctionCall* functionCall,
const CommonMenuDef* menu,
const CommonItemDef* item) const
{
if (!HandleSpecialBaseFunctionCall(gameStatement, entries, functionCall, menu, item))
@ -188,7 +198,9 @@ namespace IW4
}
}
void ConvertExpressionEntryCustomFunctionCall(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const CommonExpressionCustomFunctionCall* functionCall,
void ConvertExpressionEntryCustomFunctionCall(Statement_s* gameStatement,
std::vector<expressionEntry>& entries,
const CommonExpressionCustomFunctionCall* functionCall,
const CommonMenuDef* menu,
const CommonItemDef* item) const
{
@ -216,11 +228,10 @@ namespace IW4
gameStatement->supportingData = m_conversion_zone_state->m_supporting_data;
}
constexpr static expressionOperatorType_e UNARY_OPERATION_MAPPING[static_cast<unsigned>(SimpleUnaryOperationId::COUNT)]
{
constexpr static expressionOperatorType_e UNARY_OPERATION_MAPPING[static_cast<unsigned>(SimpleUnaryOperationId::COUNT)]{
OP_NOT,
OP_BITWISENOT,
OP_SUBTRACT
OP_SUBTRACT,
};
bool IsOperation(const ISimpleExpression* expression) const
@ -231,7 +242,10 @@ namespace IW4
return dynamic_cast<const SimpleExpressionBinaryOperation*>(expression) || dynamic_cast<const SimpleExpressionUnaryOperation*>(expression);
}
void ConvertExpressionEntryUnaryOperation(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const SimpleExpressionUnaryOperation* unaryOperation, const CommonMenuDef* menu,
void ConvertExpressionEntryUnaryOperation(Statement_s* gameStatement,
std::vector<expressionEntry>& entries,
const SimpleExpressionUnaryOperation* unaryOperation,
const CommonMenuDef* menu,
const CommonItemDef* item) const
{
assert(static_cast<unsigned>(unaryOperation->m_operation_type->m_id) < static_cast<unsigned>(SimpleUnaryOperationId::COUNT));
@ -258,8 +272,7 @@ namespace IW4
ConvertExpressionEntry(gameStatement, entries, unaryOperation->m_operand.get(), menu, item);
}
constexpr static expressionOperatorType_e BINARY_OPERATION_MAPPING[static_cast<unsigned>(SimpleBinaryOperationId::COUNT)]
{
constexpr static expressionOperatorType_e BINARY_OPERATION_MAPPING[static_cast<unsigned>(SimpleBinaryOperationId::COUNT)]{
OP_ADD,
OP_SUBTRACT,
OP_MULTIPLY,
@ -276,10 +289,13 @@ namespace IW4
OP_EQUALS,
OP_NOTEQUAL,
OP_AND,
OP_OR
OP_OR,
};
void ConvertExpressionEntryBinaryOperation(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const SimpleExpressionBinaryOperation* binaryOperation, const CommonMenuDef* menu,
void ConvertExpressionEntryBinaryOperation(Statement_s* gameStatement,
std::vector<expressionEntry>& entries,
const SimpleExpressionBinaryOperation* binaryOperation,
const CommonMenuDef* menu,
const CommonItemDef* item) const
{
// Game needs all nested operations to have parenthesis
@ -349,7 +365,11 @@ namespace IW4
entries.emplace_back(entry);
}
void ConvertExpressionEntry(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item) const
void ConvertExpressionEntry(Statement_s* gameStatement,
std::vector<expressionEntry>& entries,
const ISimpleExpression* expression,
const CommonMenuDef* menu,
const CommonItemDef* item) const
{
if (!m_disable_optimizations && expression->IsStatic())
{
@ -409,7 +429,10 @@ namespace IW4
return statement;
}
_NODISCARD Statement_s* ConvertOrApplyStatement(float& staticValue, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
_NODISCARD Statement_s* ConvertOrApplyStatement(float& staticValue,
const ISimpleExpression* expression,
const CommonMenuDef* menu,
const CommonItemDef* item = nullptr) const
{
if (m_disable_optimizations)
return ConvertExpression(expression, menu, item);
@ -437,7 +460,10 @@ namespace IW4
return ConvertExpression(expression, menu, item);
}
_NODISCARD Statement_s* ConvertOrApplyStatement(const char*& staticValue, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
_NODISCARD Statement_s* ConvertOrApplyStatement(const char*& staticValue,
const ISimpleExpression* expression,
const CommonMenuDef* menu,
const CommonItemDef* item = nullptr) const
{
if (m_disable_optimizations)
return ConvertExpression(expression, menu, item);
@ -464,7 +490,10 @@ namespace IW4
return ConvertExpression(expression, menu, item);
}
_NODISCARD Statement_s* ConvertOrApplyStatement(Material*& staticValue, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
_NODISCARD Statement_s* ConvertOrApplyStatement(Material*& staticValue,
const ISimpleExpression* expression,
const CommonMenuDef* menu,
const CommonItemDef* item = nullptr) const
{
if (m_disable_optimizations)
return ConvertExpression(expression, menu, item);
@ -491,7 +520,10 @@ namespace IW4
return ConvertExpression(expression, menu, item);
}
_NODISCARD Statement_s* ConvertVisibleExpression(windowDef_t* window, const ISimpleExpression* expression, const CommonMenuDef* commonMenu, const CommonItemDef* commonItem = nullptr) const
_NODISCARD Statement_s* ConvertVisibleExpression(windowDef_t* window,
const ISimpleExpression* expression,
const CommonMenuDef* commonMenu,
const CommonItemDef* commonItem = nullptr) const
{
if (expression == nullptr)
return nullptr;
@ -502,7 +534,8 @@ namespace IW4
{
const auto* staticValue = dynamic_cast<const SimpleExpressionValue*>(expression);
isStatic = staticValue != nullptr;
isTruthy = isStatic && (staticValue->m_type == SimpleExpressionValue::Type::INT || staticValue->m_type == SimpleExpressionValue::Type::DOUBLE) && staticValue->IsTruthy();
isTruthy = isStatic && (staticValue->m_type == SimpleExpressionValue::Type::INT || staticValue->m_type == SimpleExpressionValue::Type::DOUBLE)
&& staticValue->IsTruthy();
}
else
{
@ -540,7 +573,10 @@ namespace IW4
}
}
void ConvertEventHandlerSetLocalVar(std::vector<MenuEventHandler*>& elements, const CommonEventHandlerSetLocalVar* setLocalVar, const CommonMenuDef* menu, const CommonItemDef* item) const
void ConvertEventHandlerSetLocalVar(std::vector<MenuEventHandler*>& elements,
const CommonEventHandlerSetLocalVar* setLocalVar,
const CommonMenuDef* menu,
const CommonItemDef* item) const
{
assert(setLocalVar);
if (!setLocalVar)
@ -571,20 +607,22 @@ namespace IW4
elements.push_back(outputHandler);
}
void ConvertEventHandlerCondition(std::vector<MenuEventHandler*>& elements, const CommonEventHandlerCondition* condition, const CommonMenuDef* menu,
void ConvertEventHandlerCondition(std::vector<MenuEventHandler*>& elements,
const CommonEventHandlerCondition* condition,
const CommonMenuDef* menu,
const CommonItemDef* item) const
{
assert(condition);
if (!condition || !condition->m_condition)
return;
if(!m_disable_optimizations && condition->m_condition->IsStatic())
if (!m_disable_optimizations && condition->m_condition->IsStatic())
{
const auto staticValueIsTruthy = condition->m_condition->EvaluateStatic().IsTruthy();
if(staticValueIsTruthy)
if (staticValueIsTruthy)
ConvertEventHandlerElements(elements, condition->m_condition_elements.get(), menu, item);
else if(condition->m_else_elements)
else if (condition->m_else_elements)
ConvertEventHandlerElements(elements, condition->m_else_elements.get(), menu, item);
}
else
@ -611,7 +649,9 @@ namespace IW4
}
}
void ConvertEventHandler(std::vector<MenuEventHandler*>& elements, const ICommonEventHandlerElement* eventHandler, const CommonMenuDef* menu,
void ConvertEventHandler(std::vector<MenuEventHandler*>& elements,
const ICommonEventHandlerElement* eventHandler,
const CommonMenuDef* menu,
const CommonItemDef* item) const
{
assert(eventHandler);
@ -634,13 +674,17 @@ namespace IW4
}
}
void ConvertEventHandlerElements(std::vector<MenuEventHandler*>& elements, const CommonEventHandlerSet* eventHandlerSet, const CommonMenuDef* menu, const CommonItemDef* item) const
void ConvertEventHandlerElements(std::vector<MenuEventHandler*>& elements,
const CommonEventHandlerSet* eventHandlerSet,
const CommonMenuDef* menu,
const CommonItemDef* item) const
{
for (const auto& element : eventHandlerSet->m_elements)
ConvertEventHandler(elements, element.get(), menu, item);
}
_NODISCARD MenuEventHandlerSet* ConvertEventHandlerSet(const CommonEventHandlerSet* eventHandlerSet, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
_NODISCARD MenuEventHandlerSet*
ConvertEventHandlerSet(const CommonEventHandlerSet* eventHandlerSet, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
{
if (!eventHandlerSet)
return nullptr;
@ -661,7 +705,9 @@ namespace IW4
return outputSet;
}
_NODISCARD ItemKeyHandler* ConvertKeyHandler(const std::multimap<int, std::unique_ptr<CommonEventHandlerSet>>& keyHandlers, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
_NODISCARD ItemKeyHandler* ConvertKeyHandler(const std::multimap<int, std::unique_ptr<CommonEventHandlerSet>>& keyHandlers,
const CommonMenuDef* menu,
const CommonItemDef* item = nullptr) const
{
if (keyHandlers.empty())
return nullptr;
@ -684,7 +730,8 @@ namespace IW4
return output;
}
ItemFloatExpression* ConvertFloatExpressions(const CommonItemDef* commonItem, itemDef_s* item, const CommonMenuDef* parentMenu, int& floatExpressionCount) const
ItemFloatExpression*
ConvertFloatExpressions(const CommonItemDef* commonItem, itemDef_s* item, const CommonMenuDef* parentMenu, int& floatExpressionCount) const
{
struct FloatExpressionLocation
{
@ -695,27 +742,42 @@ namespace IW4
unsigned m_static_value_array_size;
unsigned m_dynamic_flags_to_set;
};
FloatExpressionLocation locations[]
{
{commonItem->m_rect_x_exp.get(), false, ITEM_FLOATEXP_TGT_RECT_X, &item->window.rectClient.x, 1, 0},
{commonItem->m_rect_y_exp.get(), false, ITEM_FLOATEXP_TGT_RECT_Y, &item->window.rectClient.y, 1, 0},
{commonItem->m_rect_w_exp.get(), false, ITEM_FLOATEXP_TGT_RECT_W, &item->window.rectClient.w, 1, 0},
{commonItem->m_rect_h_exp.get(), false, ITEM_FLOATEXP_TGT_RECT_H, &item->window.rectClient.h, 1, 0},
{commonItem->m_forecolor_expressions.m_r_exp.get(), false, ITEM_FLOATEXP_TGT_FORECOLOR_R, &item->window.foreColor[0], 1, WINDOW_FLAG_NON_DEFAULT_FORECOLOR},
{commonItem->m_forecolor_expressions.m_g_exp.get(), false, ITEM_FLOATEXP_TGT_FORECOLOR_G, &item->window.foreColor[1], 1, WINDOW_FLAG_NON_DEFAULT_FORECOLOR},
{commonItem->m_forecolor_expressions.m_b_exp.get(), false, ITEM_FLOATEXP_TGT_FORECOLOR_B, &item->window.foreColor[2], 1, WINDOW_FLAG_NON_DEFAULT_FORECOLOR},
{commonItem->m_forecolor_expressions.m_a_exp.get(), false, ITEM_FLOATEXP_TGT_FORECOLOR_A, &item->window.foreColor[3], 1, WINDOW_FLAG_NON_DEFAULT_FORECOLOR},
{commonItem->m_forecolor_expressions.m_rgb_exp.get(), false, ITEM_FLOATEXP_TGT_FORECOLOR_RGB, &item->window.foreColor[0], 3, WINDOW_FLAG_NON_DEFAULT_FORECOLOR},
{commonItem->m_glowcolor_expressions.m_r_exp.get(), false, ITEM_FLOATEXP_TGT_GLOWCOLOR_R, &item->glowColor[0], 1, 0},
{commonItem->m_glowcolor_expressions.m_g_exp.get(), false, ITEM_FLOATEXP_TGT_GLOWCOLOR_G, &item->glowColor[1], 1, 0},
{commonItem->m_glowcolor_expressions.m_b_exp.get(), false, ITEM_FLOATEXP_TGT_GLOWCOLOR_B, &item->glowColor[2], 1, 0},
{commonItem->m_glowcolor_expressions.m_a_exp.get(), false, ITEM_FLOATEXP_TGT_GLOWCOLOR_A, &item->glowColor[3], 1, 0},
{commonItem->m_glowcolor_expressions.m_rgb_exp.get(), false, ITEM_FLOATEXP_TGT_GLOWCOLOR_RGB, &item->glowColor[0], 3, 0},
{commonItem->m_backcolor_expressions.m_r_exp.get(), false, ITEM_FLOATEXP_TGT_BACKCOLOR_R, &item->window.backColor[0], 1, 0},
{commonItem->m_backcolor_expressions.m_g_exp.get(), false, ITEM_FLOATEXP_TGT_BACKCOLOR_G, &item->window.backColor[1], 1, 0},
{commonItem->m_backcolor_expressions.m_b_exp.get(), false, ITEM_FLOATEXP_TGT_BACKCOLOR_B, &item->window.backColor[2], 1, 0},
{commonItem->m_backcolor_expressions.m_a_exp.get(), false, ITEM_FLOATEXP_TGT_BACKCOLOR_A, &item->window.backColor[3], 1, 0},
{commonItem->m_backcolor_expressions.m_rgb_exp.get(), false, ITEM_FLOATEXP_TGT_BACKCOLOR_RGB, &item->window.backColor[0], 3, 0},
FloatExpressionLocation locations[]{
{commonItem->m_rect_x_exp.get(), false, ITEM_FLOATEXP_TGT_RECT_X, &item->window.rectClient.x, 1, 0 },
{commonItem->m_rect_y_exp.get(), false, ITEM_FLOATEXP_TGT_RECT_Y, &item->window.rectClient.y, 1, 0 },
{commonItem->m_rect_w_exp.get(), false, ITEM_FLOATEXP_TGT_RECT_W, &item->window.rectClient.w, 1, 0 },
{commonItem->m_rect_h_exp.get(), false, ITEM_FLOATEXP_TGT_RECT_H, &item->window.rectClient.h, 1, 0 },
{commonItem->m_forecolor_expressions.m_r_exp.get(),
false, ITEM_FLOATEXP_TGT_FORECOLOR_R,
&item->window.foreColor[0],
1, WINDOW_FLAG_NON_DEFAULT_FORECOLOR},
{commonItem->m_forecolor_expressions.m_g_exp.get(),
false, ITEM_FLOATEXP_TGT_FORECOLOR_G,
&item->window.foreColor[1],
1, WINDOW_FLAG_NON_DEFAULT_FORECOLOR},
{commonItem->m_forecolor_expressions.m_b_exp.get(),
false, ITEM_FLOATEXP_TGT_FORECOLOR_B,
&item->window.foreColor[2],
1, WINDOW_FLAG_NON_DEFAULT_FORECOLOR},
{commonItem->m_forecolor_expressions.m_a_exp.get(),
false, ITEM_FLOATEXP_TGT_FORECOLOR_A,
&item->window.foreColor[3],
1, WINDOW_FLAG_NON_DEFAULT_FORECOLOR},
{commonItem->m_forecolor_expressions.m_rgb_exp.get(),
false, ITEM_FLOATEXP_TGT_FORECOLOR_RGB,
&item->window.foreColor[0],
3, WINDOW_FLAG_NON_DEFAULT_FORECOLOR},
{commonItem->m_glowcolor_expressions.m_r_exp.get(), false, ITEM_FLOATEXP_TGT_GLOWCOLOR_R, &item->glowColor[0], 1, 0 },
{commonItem->m_glowcolor_expressions.m_g_exp.get(), false, ITEM_FLOATEXP_TGT_GLOWCOLOR_G, &item->glowColor[1], 1, 0 },
{commonItem->m_glowcolor_expressions.m_b_exp.get(), false, ITEM_FLOATEXP_TGT_GLOWCOLOR_B, &item->glowColor[2], 1, 0 },
{commonItem->m_glowcolor_expressions.m_a_exp.get(), false, ITEM_FLOATEXP_TGT_GLOWCOLOR_A, &item->glowColor[3], 1, 0 },
{commonItem->m_glowcolor_expressions.m_rgb_exp.get(), false, ITEM_FLOATEXP_TGT_GLOWCOLOR_RGB, &item->glowColor[0], 3, 0 },
{commonItem->m_backcolor_expressions.m_r_exp.get(), false, ITEM_FLOATEXP_TGT_BACKCOLOR_R, &item->window.backColor[0], 1, 0 },
{commonItem->m_backcolor_expressions.m_g_exp.get(), false, ITEM_FLOATEXP_TGT_BACKCOLOR_G, &item->window.backColor[1], 1, 0 },
{commonItem->m_backcolor_expressions.m_b_exp.get(), false, ITEM_FLOATEXP_TGT_BACKCOLOR_B, &item->window.backColor[2], 1, 0 },
{commonItem->m_backcolor_expressions.m_a_exp.get(), false, ITEM_FLOATEXP_TGT_BACKCOLOR_A, &item->window.backColor[3], 1, 0 },
{commonItem->m_backcolor_expressions.m_rgb_exp.get(), false, ITEM_FLOATEXP_TGT_BACKCOLOR_RGB, &item->window.backColor[0], 3, 0 },
};
floatExpressionCount = 0;
@ -732,7 +794,7 @@ namespace IW4
item->window.dynamicFlags[0] |= dynamicFlagsToSet;
auto* staticValuePtr = staticValue;
for(auto i = 0u; i < staticValueArraySize; i++)
for (auto i = 0u; i < staticValueArraySize; i++)
{
*staticValuePtr = static_cast<float>(evaluatedValue.m_int_value);
staticValuePtr++;
@ -829,7 +891,10 @@ namespace IW4
return nullptr;
}
_NODISCARD listBoxDef_s* ConvertListBoxFeatures(itemDef_s* item, CommonItemFeaturesListBox* commonListBox, const CommonMenuDef& parentMenu, const CommonItemDef& commonItem) const
_NODISCARD listBoxDef_s* ConvertListBoxFeatures(itemDef_s* item,
CommonItemFeaturesListBox* commonListBox,
const CommonMenuDef& parentMenu,
const CommonItemDef& commonItem) const
{
if (commonListBox == nullptr)
return nullptr;
@ -863,7 +928,10 @@ namespace IW4
return listBox;
}
_NODISCARD editFieldDef_s* ConvertEditFieldFeatures(itemDef_s* item, CommonItemFeaturesEditField* commonEditField, const CommonMenuDef& parentMenu, const CommonItemDef& commonItem) const
_NODISCARD editFieldDef_s* ConvertEditFieldFeatures(itemDef_s* item,
CommonItemFeaturesEditField* commonEditField,
const CommonMenuDef& parentMenu,
const CommonItemDef& commonItem) const
{
if (commonEditField == nullptr)
return nullptr;
@ -882,7 +950,10 @@ namespace IW4
return editField;
}
_NODISCARD multiDef_s* ConvertMultiValueFeatures(itemDef_s* item, CommonItemFeaturesMultiValue* commonMultiValue, const CommonMenuDef& parentMenu, const CommonItemDef& commonItem) const
_NODISCARD multiDef_s* ConvertMultiValueFeatures(itemDef_s* item,
CommonItemFeaturesMultiValue* commonMultiValue,
const CommonMenuDef& parentMenu,
const CommonItemDef& commonItem) const
{
if (commonMultiValue == nullptr)
return nullptr;
@ -912,7 +983,10 @@ namespace IW4
return multiValue;
}
_NODISCARD newsTickerDef_s* ConvertNewsTickerFeatures(itemDef_s* item, CommonItemFeaturesNewsTicker* commonNewsTicker, const CommonMenuDef& parentMenu, const CommonItemDef& commonItem) const
_NODISCARD newsTickerDef_s* ConvertNewsTickerFeatures(itemDef_s* item,
CommonItemFeaturesNewsTicker* commonNewsTicker,
const CommonMenuDef& parentMenu,
const CommonItemDef& commonItem) const
{
if (commonNewsTicker == nullptr)
return nullptr;
@ -1016,7 +1090,7 @@ namespace IW4
case CommonItemFeatureType::NONE:
default:
if(item->type == ITEM_TYPE_TEXT_SCROLL)
if (item->type == ITEM_TYPE_TEXT_SCROLL)
{
item->typeData.scroll = static_cast<textScrollDef_s*>(m_memory->Alloc(sizeof(textScrollDef_s)));
memset(item->typeData.scroll, 0, sizeof(textScrollDef_s));
@ -1110,7 +1184,7 @@ namespace IW4
std::vector<XAssetInfoGeneric*> m_dependencies;
};
}
} // namespace IW4
MenuConverter::MenuConverter(const bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
: m_disable_optimizations(disableOptimizations),

View File

@ -1,11 +1,11 @@
#pragma once
#include "Utils/ClassUtils.h"
#include "AssetLoading/IAssetLoadingManager.h"
#include "Game/IW4/IW4.h"
#include "Parsing/Menu/Domain/CommonMenuDef.h"
#include "Utils/MemoryManager.h"
#include "SearchPath/ISearchPath.h"
#include "Utils/ClassUtils.h"
#include "Utils/MemoryManager.h"
namespace IW4
{
@ -23,4 +23,4 @@ namespace IW4
std::vector<XAssetInfoGeneric*>& GetDependencies();
_NODISCARD menuDef_t* ConvertMenu(const menu::CommonMenuDef& commonMenu);
};
}
} // namespace IW4

View File

@ -1,9 +1,5 @@
#include "ObjLoaderIW4.h"
#include "Game/IW4/GameIW4.h"
#include "Game/IW4/GameAssetPoolIW4.h"
#include "ObjContainer/IPak/IPak.h"
#include "ObjLoading.h"
#include "AssetLoaders/AssetLoaderAddonMapEnts.h"
#include "AssetLoaders/AssetLoaderClipMap.h"
#include "AssetLoaders/AssetLoaderComWorld.h"
@ -41,16 +37,24 @@
#include "AssetLoaders/AssetLoaderXModel.h"
#include "AssetLoaders/AssetLoaderXModelSurfs.h"
#include "AssetLoading/AssetLoadingManager.h"
#include "Game/IW4/GameAssetPoolIW4.h"
#include "Game/IW4/GameIW4.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 IW4;
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); \
}
REGISTER_ASSET_LOADER(AssetLoaderPhysPreset)
REGISTER_ASSET_LOADER(AssetLoaderPhysCollmap)
@ -89,7 +93,7 @@ ObjLoader::ObjLoader()
REGISTER_ASSET_LOADER(AssetLoaderTracer)
REGISTER_ASSET_LOADER(AssetLoaderVehicle)
REGISTER_ASSET_LOADER(AssetLoaderAddonMapEnts)
#undef REGISTER_ASSET_LOADER
}
@ -100,23 +104,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)
{

View File

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