mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-01 08:41:52 +00:00
refactor: fix x64 compilation for ObjLoading
This commit is contained in:
@ -81,7 +81,7 @@ namespace
|
||||
const auto mipCount = texture->HasMipMaps() ? texture->GetMipMapCount() : 1;
|
||||
const auto faceCount = texture->GetFaceCount();
|
||||
|
||||
size_t dataSize = 0;
|
||||
auto dataSize = 0uz;
|
||||
for (auto mipLevel = 0; mipLevel < mipCount; mipLevel++)
|
||||
dataSize += texture->GetSizeOfMipLevel(mipLevel) * faceCount;
|
||||
|
||||
@ -99,7 +99,7 @@ namespace
|
||||
loadDef->dimensions[1] = image->height;
|
||||
loadDef->dimensions[2] = image->depth;
|
||||
loadDef->format = static_cast<int>(texture->GetFormat()->GetD3DFormat());
|
||||
loadDef->resourceSize = dataSize;
|
||||
loadDef->resourceSize = static_cast<unsigned>(dataSize);
|
||||
|
||||
char* currentDataBuffer = loadDef->data;
|
||||
for (auto mipLevel = 0; mipLevel < mipCount; mipLevel++)
|
||||
|
@ -83,7 +83,7 @@ namespace
|
||||
menu::MenuAssetZoneState& zoneState,
|
||||
MenuConversionZoneState& conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
AssetRegistration<AssetMenuList>& registration)
|
||||
AssetRegistration<AssetMenuList>& registration) const
|
||||
{
|
||||
const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath);
|
||||
if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end())
|
||||
@ -125,12 +125,12 @@ namespace
|
||||
menu::MenuAssetZoneState& zoneState,
|
||||
MenuConversionZoneState& conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
AssetRegistration<AssetMenuList>& registration)
|
||||
AssetRegistration<AssetMenuList>& registration) const
|
||||
{
|
||||
const auto menuCount = parsingResult.m_menus.size();
|
||||
const auto functionCount = parsingResult.m_functions.size();
|
||||
const auto menuLoadCount = parsingResult.m_menus_to_load.size();
|
||||
auto totalItemCount = 0u;
|
||||
auto totalItemCount = 0uz;
|
||||
for (const auto& menu : parsingResult.m_menus)
|
||||
totalItemCount += menu->m_items.size();
|
||||
|
||||
@ -182,7 +182,7 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus)
|
||||
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus) const
|
||||
{
|
||||
menuList.menuCount = static_cast<int>(menus.size());
|
||||
|
||||
@ -196,7 +196,8 @@ namespace
|
||||
menuList.menus = nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<menu::ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState)
|
||||
std::unique_ptr<menu::ParsingResult>
|
||||
ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const
|
||||
{
|
||||
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW4, m_search_path);
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace
|
||||
zs.zfree = Z_NULL;
|
||||
zs.opaque = Z_NULL;
|
||||
zs.avail_in = static_cast<uInt>(file.m_length);
|
||||
zs.avail_out = compressionBufferSize;
|
||||
zs.avail_out = static_cast<unsigned>(compressionBufferSize);
|
||||
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
||||
zs.next_out = reinterpret_cast<Bytef*>(compressedBuffer);
|
||||
|
||||
|
@ -38,38 +38,38 @@ namespace
|
||||
}
|
||||
|
||||
private:
|
||||
StructuredDataType ConvertType(CommonStructuredDataType inputType)
|
||||
static StructuredDataType ConvertType(const CommonStructuredDataType inputType)
|
||||
{
|
||||
switch (inputType.m_category)
|
||||
{
|
||||
case CommonStructuredDataTypeCategory::INT:
|
||||
return {DATA_INT, {0}};
|
||||
return {.type = DATA_INT, .u = {}};
|
||||
case CommonStructuredDataTypeCategory::BYTE:
|
||||
return {DATA_BYTE, {0}};
|
||||
return {.type = DATA_BYTE, .u = {}};
|
||||
case CommonStructuredDataTypeCategory::BOOL:
|
||||
return {DATA_BOOL, {0}};
|
||||
return {.type = DATA_BOOL, .u = {}};
|
||||
case CommonStructuredDataTypeCategory::FLOAT:
|
||||
return {DATA_FLOAT, {0}};
|
||||
return {.type = DATA_FLOAT, .u = {}};
|
||||
case CommonStructuredDataTypeCategory::SHORT:
|
||||
return {DATA_SHORT, {0}};
|
||||
return {.type = DATA_SHORT, .u = {}};
|
||||
case CommonStructuredDataTypeCategory::STRING:
|
||||
return {DATA_STRING, {static_cast<unsigned>(inputType.m_info.string_length)}};
|
||||
return {.type = DATA_STRING, .u = {static_cast<unsigned>(inputType.m_info.string_length)}};
|
||||
case CommonStructuredDataTypeCategory::ENUM:
|
||||
return {DATA_ENUM, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {.type = DATA_ENUM, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::STRUCT:
|
||||
return {DATA_STRUCT, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {.type = DATA_STRUCT, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::INDEXED_ARRAY:
|
||||
return {DATA_INDEXED_ARRAY, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {.type = DATA_INDEXED_ARRAY, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
||||
return {DATA_ENUM_ARRAY, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {.type = DATA_ENUM_ARRAY, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::UNKNOWN:
|
||||
default:
|
||||
assert(false);
|
||||
return {DATA_INT, {0}};
|
||||
return {.type = DATA_INT, .u = {0}};
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertEnum(CommonStructuredDataEnum& inputEnum, StructuredDataEnum& outputEnum)
|
||||
void ConvertEnum(CommonStructuredDataEnum& inputEnum, StructuredDataEnum& outputEnum) const
|
||||
{
|
||||
outputEnum.entryCount = static_cast<int>(inputEnum.m_entries.size());
|
||||
if (inputEnum.m_reserved_entry_count <= 0)
|
||||
@ -94,10 +94,10 @@ namespace
|
||||
outputEnum.entries = nullptr;
|
||||
}
|
||||
|
||||
void ConvertStruct(CommonStructuredDataStruct& inputStruct, StructuredDataStruct& outputStruct)
|
||||
void ConvertStruct(CommonStructuredDataStruct& inputStruct, StructuredDataStruct& outputStruct) const
|
||||
{
|
||||
outputStruct.size = static_cast<int>(inputStruct.m_size_in_byte);
|
||||
outputStruct.bitOffset = inputStruct.m_bit_offset;
|
||||
outputStruct.bitOffset = static_cast<unsigned>(inputStruct.m_bit_offset);
|
||||
|
||||
outputStruct.propertyCount = static_cast<int>(inputStruct.m_properties.size());
|
||||
inputStruct.SortPropertiesByName();
|
||||
@ -115,34 +115,34 @@ namespace
|
||||
if (outputProperty.type.type != DATA_BOOL)
|
||||
{
|
||||
assert(inputProperty.m_offset_in_bits % 8 == 0);
|
||||
outputProperty.offset = inputProperty.m_offset_in_bits / 8;
|
||||
outputProperty.offset = static_cast<unsigned>(inputProperty.m_offset_in_bits / 8uz);
|
||||
}
|
||||
else
|
||||
outputProperty.offset = inputProperty.m_offset_in_bits;
|
||||
outputProperty.offset = static_cast<unsigned>(inputProperty.m_offset_in_bits);
|
||||
}
|
||||
}
|
||||
else
|
||||
outputStruct.properties = nullptr;
|
||||
}
|
||||
|
||||
void ConvertIndexedArray(const CommonStructuredDataIndexedArray& inputIndexedArray, StructuredDataIndexedArray& outputIndexedArray)
|
||||
static void ConvertIndexedArray(const CommonStructuredDataIndexedArray& inputIndexedArray, StructuredDataIndexedArray& outputIndexedArray)
|
||||
{
|
||||
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, 8uz) / 8uz;
|
||||
outputIndexedArray.elementSize = static_cast<unsigned>(utils::Align(inputIndexedArray.m_element_size_in_bits, 8uz) / 8uz);
|
||||
}
|
||||
|
||||
void ConvertEnumedArray(const CommonStructuredDataEnumedArray& inputEnumedArray, StructuredDataEnumedArray& outputEnumedArray)
|
||||
{
|
||||
outputEnumedArray.enumIndex = static_cast<int>(inputEnumedArray.m_enum_index);
|
||||
outputEnumedArray.elementType = ConvertType(inputEnumedArray.m_array_type);
|
||||
outputEnumedArray.elementSize = utils::Align(inputEnumedArray.m_element_size_in_bits, 8uz) / 8uz;
|
||||
outputEnumedArray.elementSize = static_cast<unsigned>(utils::Align(inputEnumedArray.m_element_size_in_bits, 8uz) / 8uz);
|
||||
}
|
||||
|
||||
void ConvertDef(const CommonStructuredDataDef& inputDef, StructuredDataDef& outputDef)
|
||||
{
|
||||
outputDef.version = inputDef.m_version;
|
||||
outputDef.formatChecksum = inputDef.m_checksum;
|
||||
outputDef.formatChecksum = static_cast<unsigned>(inputDef.m_checksum);
|
||||
|
||||
outputDef.enumCount = static_cast<int>(inputDef.m_enums.size());
|
||||
if (!inputDef.m_enums.empty())
|
||||
@ -185,7 +185,7 @@ namespace
|
||||
outputDef.enumedArrays = nullptr;
|
||||
|
||||
outputDef.rootType = ConvertType(inputDef.m_root_type);
|
||||
outputDef.size = inputDef.m_size_in_byte;
|
||||
outputDef.size = static_cast<unsigned>(inputDef.m_size_in_byte);
|
||||
}
|
||||
|
||||
StructuredDataDefSet* ConvertSet(const std::string& assetName, const std::vector<std::unique_ptr<CommonStructuredDataDef>>& commonDefs)
|
||||
@ -193,7 +193,7 @@ namespace
|
||||
auto* set = m_memory.Alloc<StructuredDataDefSet>();
|
||||
set->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
set->defCount = commonDefs.size();
|
||||
set->defCount = static_cast<unsigned>(commonDefs.size());
|
||||
set->defs = m_memory.Alloc<StructuredDataDef>(commonDefs.size());
|
||||
|
||||
for (auto defIndex = 0u; defIndex < commonDefs.size(); defIndex++)
|
||||
|
@ -31,14 +31,14 @@ namespace
|
||||
class LoadedTechnique
|
||||
{
|
||||
public:
|
||||
MaterialTechnique* m_technique;
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
|
||||
LoadedTechnique(MaterialTechnique* technique, std::vector<XAssetInfoGeneric*> dependencies)
|
||||
: m_technique(technique),
|
||||
m_dependencies(std::move(dependencies))
|
||||
{
|
||||
}
|
||||
|
||||
MaterialTechnique* m_technique;
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
};
|
||||
|
||||
class TechniqueZoneLoadingState final : public IZoneAssetCreationState
|
||||
@ -46,8 +46,7 @@ namespace
|
||||
public:
|
||||
typedef const float (*literal_t)[4];
|
||||
|
||||
public:
|
||||
_NODISCARD const LoadedTechnique* FindLoadedTechnique(const std::string& techniqueName) const
|
||||
[[nodiscard]] const LoadedTechnique* FindLoadedTechnique(const std::string& techniqueName) const
|
||||
{
|
||||
const auto loadedTechnique = m_loaded_techniques.find(techniqueName);
|
||||
if (loadedTechnique != m_loaded_techniques.end())
|
||||
@ -86,8 +85,6 @@ namespace
|
||||
|
||||
class ShaderInfoFromFileSystemCacheState final : public IZoneAssetCreationState
|
||||
{
|
||||
std::unordered_map<std::string, std::unique_ptr<d3d9::ShaderInfo>> m_cached_shader_info;
|
||||
|
||||
public:
|
||||
[[nodiscard]] const d3d9::ShaderInfo* LoadShaderInfoFromDisk(ISearchPath& searchPath, const std::string& fileName)
|
||||
{
|
||||
@ -108,9 +105,9 @@ namespace
|
||||
}
|
||||
|
||||
const auto shaderData = std::make_unique<char[]>(shaderSize);
|
||||
file.m_stream->read(shaderData.get(), shaderSize);
|
||||
file.m_stream->read(shaderData.get(), static_cast<std::streamsize>(shaderSize));
|
||||
|
||||
auto shaderInfo = d3d9::ShaderAnalyser::GetShaderInfo(reinterpret_cast<const uint32_t*>(shaderData.get()), shaderSize);
|
||||
auto shaderInfo = d3d9::ShaderAnalyser::GetShaderInfo(shaderData.get(), shaderSize);
|
||||
if (!shaderInfo)
|
||||
return nullptr;
|
||||
|
||||
@ -118,6 +115,9 @@ namespace
|
||||
m_cached_shader_info.emplace(std::make_pair(fileName, std::move(shaderInfo)));
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::unique_ptr<d3d9::ShaderInfo>> m_cached_shader_info;
|
||||
};
|
||||
|
||||
class TechniqueCreator final : public techset::ITechniqueDefinitionAcceptor
|
||||
@ -126,10 +126,13 @@ namespace
|
||||
class PassShaderArgument
|
||||
{
|
||||
public:
|
||||
MaterialShaderArgument m_arg;
|
||||
MaterialUpdateFrequency m_update_frequency;
|
||||
explicit PassShaderArgument(const MaterialShaderArgument arg)
|
||||
: m_arg(arg),
|
||||
m_update_frequency(GetUpdateFrequencyForArg(arg))
|
||||
{
|
||||
}
|
||||
|
||||
static MaterialUpdateFrequency GetUpdateFrequencyForArg(MaterialShaderArgument arg)
|
||||
static MaterialUpdateFrequency GetUpdateFrequencyForArg(const MaterialShaderArgument arg)
|
||||
{
|
||||
switch (arg.type)
|
||||
{
|
||||
@ -160,15 +163,22 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
explicit PassShaderArgument(const MaterialShaderArgument arg)
|
||||
: m_arg(arg),
|
||||
m_update_frequency(GetUpdateFrequencyForArg(arg))
|
||||
{
|
||||
}
|
||||
MaterialShaderArgument m_arg;
|
||||
MaterialUpdateFrequency m_update_frequency;
|
||||
};
|
||||
|
||||
struct Pass
|
||||
{
|
||||
Pass()
|
||||
: m_vertex_shader(nullptr),
|
||||
m_vertex_shader_info(nullptr),
|
||||
m_pixel_shader(nullptr),
|
||||
m_pixel_shader_info(nullptr),
|
||||
m_vertex_decl{},
|
||||
m_vertex_decl_asset(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
XAssetInfo<MaterialVertexShader>* m_vertex_shader;
|
||||
const d3d9::ShaderInfo* m_vertex_shader_info;
|
||||
std::unique_ptr<d3d9::ShaderInfo> m_vertex_shader_info_unq;
|
||||
@ -184,21 +194,8 @@ namespace
|
||||
MaterialVertexDeclaration m_vertex_decl;
|
||||
XAssetInfo<MaterialVertexDeclaration>* m_vertex_decl_asset;
|
||||
std::vector<PassShaderArgument> m_arguments;
|
||||
|
||||
Pass()
|
||||
: m_vertex_shader(nullptr),
|
||||
m_vertex_shader_info(nullptr),
|
||||
m_pixel_shader(nullptr),
|
||||
m_pixel_shader_info(nullptr),
|
||||
m_vertex_decl{},
|
||||
m_vertex_decl_asset(nullptr)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<Pass> m_passes;
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
|
||||
TechniqueCreator(
|
||||
const std::string& techniqueName, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context, ITechsetCreator* techsetCreator)
|
||||
: m_technique_name(techniqueName),
|
||||
@ -217,10 +214,11 @@ namespace
|
||||
m_passes.emplace_back();
|
||||
}
|
||||
|
||||
static size_t RegisterCountPerElement(const d3d9::ShaderConstant& constant)
|
||||
static unsigned RegisterCountPerElement(const d3d9::ShaderConstant& constant)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -243,7 +241,7 @@ namespace
|
||||
if (shaderType == techset::ShaderSelector::VERTEX_SHADER && isSamplerArgument)
|
||||
return false;
|
||||
|
||||
MaterialShaderArgument argument{};
|
||||
MaterialShaderArgument argument;
|
||||
argument.dest = static_cast<uint16_t>(shaderArgument.m_register_index + registerOffset);
|
||||
|
||||
unsigned arrayCount;
|
||||
@ -258,7 +256,7 @@ namespace
|
||||
return false;
|
||||
|
||||
argument.type = MTL_ARG_CODE_PIXEL_SAMPLER;
|
||||
argument.u.codeSampler = samplerSource->source + elementOffset;
|
||||
argument.u.codeSampler = samplerSource->source + static_cast<unsigned>(elementOffset);
|
||||
|
||||
arrayCount = static_cast<unsigned>(samplerSource->arrayCount);
|
||||
}
|
||||
@ -304,13 +302,12 @@ namespace
|
||||
{
|
||||
if (!AutoCreateShaderArgument(techset::ShaderSelector::VERTEX_SHADER, argument, elementIndex, registerIndex))
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Unassigned vertex shader \"" << pass.m_vertex_shader->m_name << "\" arg: " << argument.m_name;
|
||||
|
||||
std::string elementIndexStr;
|
||||
if (argument.m_type_elements > 1)
|
||||
ss << '[' << elementIndex << ']';
|
||||
elementIndexStr = std::format("[{}]", elementIndex);
|
||||
|
||||
errorMessage = ss.str();
|
||||
errorMessage =
|
||||
std::format("Unassigned vertex shader \"{}\" arg: {}{}", pass.m_vertex_shader->m_name, argument.m_name, elementIndexStr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -572,11 +569,11 @@ namespace
|
||||
return foundSource;
|
||||
}
|
||||
|
||||
bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo,
|
||||
const techset::ShaderArgument& argument,
|
||||
size_t& constantIndex,
|
||||
size_t& registerOffset,
|
||||
std::string& errorMessage) const
|
||||
static bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo,
|
||||
const techset::ShaderArgument& argument,
|
||||
size_t& constantIndex,
|
||||
size_t& registerOffset,
|
||||
std::string& errorMessage)
|
||||
{
|
||||
const auto matchingShaderConstant = std::ranges::find_if(shaderInfo.m_constants,
|
||||
[argument](const d3d9::ShaderConstant& constant)
|
||||
@ -854,14 +851,14 @@ namespace
|
||||
}
|
||||
|
||||
bool AcceptShaderLiteralArgument(const techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentLiteralSource source,
|
||||
const techset::ShaderArgument shaderArgument,
|
||||
const techset::ShaderArgumentLiteralSource source,
|
||||
std::string& errorMessage) override
|
||||
{
|
||||
assert(!m_passes.empty());
|
||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||
|
||||
MaterialShaderArgument argument{};
|
||||
MaterialShaderArgument argument;
|
||||
const d3d9::ShaderInfo* shaderInfo;
|
||||
|
||||
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
||||
@ -913,14 +910,14 @@ namespace
|
||||
}
|
||||
|
||||
bool AcceptShaderMaterialArgument(const techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
const techset::ShaderArgument shaderArgument,
|
||||
const techset::ShaderArgumentMaterialSource source,
|
||||
std::string& errorMessage) override
|
||||
{
|
||||
assert(!m_passes.empty());
|
||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||
|
||||
MaterialShaderArgument argument{};
|
||||
MaterialShaderArgument argument;
|
||||
const d3d9::ShaderInfo* shaderInfo;
|
||||
|
||||
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
||||
@ -1016,6 +1013,8 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<Pass> m_passes;
|
||||
|
||||
private:
|
||||
const std::string& m_technique_name;
|
||||
ISearchPath& m_search_path;
|
||||
|
@ -83,7 +83,7 @@ namespace
|
||||
menu::MenuAssetZoneState& zoneState,
|
||||
MenuConversionZoneState& conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
AssetRegistration<AssetMenuList>& registration)
|
||||
AssetRegistration<AssetMenuList>& registration) const
|
||||
{
|
||||
const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath);
|
||||
if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end())
|
||||
@ -125,14 +125,14 @@ namespace
|
||||
menu::MenuAssetZoneState& zoneState,
|
||||
MenuConversionZoneState& conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
AssetRegistration<AssetMenuList>& registration)
|
||||
AssetRegistration<AssetMenuList>& registration) const
|
||||
{
|
||||
const auto menuCount = parsingResult.m_menus.size();
|
||||
const auto functionCount = parsingResult.m_functions.size();
|
||||
const auto menuLoadCount = parsingResult.m_menus_to_load.size();
|
||||
auto totalItemCount = 0u;
|
||||
for (const auto& menu : parsingResult.m_menus)
|
||||
totalItemCount += menu->m_items.size();
|
||||
totalItemCount += static_cast<unsigned>(menu->m_items.size());
|
||||
|
||||
std::cout << std::format("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)\n",
|
||||
fileName,
|
||||
@ -152,7 +152,7 @@ namespace
|
||||
// Convert all menus and add them as assets
|
||||
for (auto& commonMenu : parsingResult.m_menus)
|
||||
{
|
||||
auto converter = IMenuConverter::Create(ObjLoading::Configuration.MenuNoOptimization, m_search_path, m_memory, context);
|
||||
const auto converter = IMenuConverter::Create(ObjLoading::Configuration.MenuNoOptimization, m_search_path, m_memory, context);
|
||||
|
||||
auto* menuAsset = m_memory.Alloc<menuDef_t>();
|
||||
AssetRegistration<AssetMenu> menuRegistration(commonMenu->m_name, menuAsset);
|
||||
@ -182,7 +182,7 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus)
|
||||
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus) const
|
||||
{
|
||||
menuList.menuCount = static_cast<int>(menus.size());
|
||||
|
||||
@ -196,7 +196,8 @@ namespace
|
||||
menuList.menus = nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<menu::ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState)
|
||||
std::unique_ptr<menu::ParsingResult>
|
||||
ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const
|
||||
{
|
||||
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW5, m_search_path);
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace
|
||||
zs.zfree = Z_NULL;
|
||||
zs.opaque = Z_NULL;
|
||||
zs.avail_in = static_cast<uInt>(file.m_length);
|
||||
zs.avail_out = compressionBufferSize;
|
||||
zs.avail_out = static_cast<unsigned>(compressionBufferSize);
|
||||
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
||||
zs.next_out = reinterpret_cast<Bytef*>(compressedBuffer);
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
if (offset + (scriptFile->compressedLen + scriptFile->bytecodeLen) > file.m_length)
|
||||
if (offset + static_cast<size_t>(scriptFile->compressedLen + scriptFile->bytecodeLen) > static_cast<size_t>(file.m_length))
|
||||
{
|
||||
std::cerr << std::format("Error: Specified length in {} GSC BIN structure exceeds the actual file size\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
|
@ -232,7 +232,7 @@ namespace
|
||||
}
|
||||
|
||||
m_weapon.weapCompleteDef.animOverrides = animOverrides;
|
||||
m_weapon.weapCompleteDef.numAnimOverrides = valueArray.size();
|
||||
m_weapon.weapCompleteDef.numAnimOverrides = static_cast<unsigned>(valueArray.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -267,7 +267,7 @@ namespace
|
||||
}
|
||||
|
||||
m_weapon.weapCompleteDef.soundOverrides = soundOverrides;
|
||||
m_weapon.weapCompleteDef.numSoundOverrides = valueArray.size();
|
||||
m_weapon.weapCompleteDef.numSoundOverrides = static_cast<unsigned>(valueArray.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -305,7 +305,7 @@ namespace
|
||||
}
|
||||
|
||||
m_weapon.weapCompleteDef.fxOverrides = fxOverrides;
|
||||
m_weapon.weapCompleteDef.numFxOverrides = valueArray.size();
|
||||
m_weapon.weapCompleteDef.numFxOverrides = static_cast<unsigned>(valueArray.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -339,7 +339,7 @@ namespace
|
||||
}
|
||||
|
||||
m_weapon.weapCompleteDef.reloadOverrides = reloadOverrides;
|
||||
m_weapon.weapCompleteDef.numReloadStateTimerOverrides = valueArray.size();
|
||||
m_weapon.weapCompleteDef.numReloadStateTimerOverrides = static_cast<unsigned>(valueArray.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -392,7 +392,7 @@ namespace
|
||||
|
||||
m_weapon.weapCompleteDef.notetrackOverrides = m_memory.Alloc<NoteTrackToSoundEntry>(overrideVector.size());
|
||||
memcpy(m_weapon.weapCompleteDef.notetrackOverrides, overrideVector.data(), sizeof(NoteTrackToSoundEntry) * overrideVector.size());
|
||||
m_weapon.weapCompleteDef.numNotetrackOverrides = overrideVector.size();
|
||||
m_weapon.weapCompleteDef.numNotetrackOverrides = static_cast<unsigned>(overrideVector.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -437,7 +437,7 @@ namespace
|
||||
return false;
|
||||
}
|
||||
|
||||
void ParseAnim(const std::string& value, const char*& animName)
|
||||
void ParseAnim(const std::string& value, const char*& animName) const
|
||||
{
|
||||
if (value == "none")
|
||||
{
|
||||
@ -449,7 +449,7 @@ namespace
|
||||
m_registration.AddIndirectAssetReference(m_context.LoadIndirectAssetReference<AssetXAnim>(value));
|
||||
}
|
||||
|
||||
void ParseSoundAlias(const std::string& value, SndAliasCustom& soundAlias)
|
||||
void ParseSoundAlias(const std::string& value, SndAliasCustom& soundAlias) const
|
||||
{
|
||||
if (value == "none")
|
||||
{
|
||||
@ -462,7 +462,7 @@ namespace
|
||||
m_registration.AddIndirectAssetReference(m_context.LoadIndirectAssetReference<AssetSound>(value));
|
||||
}
|
||||
|
||||
bool ParseFxEffectDef(const std::string& value, FxEffectDef*& fx)
|
||||
bool ParseFxEffectDef(const std::string& value, FxEffectDef*& fx) const
|
||||
{
|
||||
if (value == "none")
|
||||
{
|
||||
@ -542,7 +542,7 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParseScriptString(const std::string& value, ScriptString& out)
|
||||
void ParseScriptString(const std::string& value, ScriptString& out) const
|
||||
{
|
||||
out = m_zone_script_strings.AddOrGetScriptString(value);
|
||||
m_registration.AddScriptString(out);
|
||||
@ -863,7 +863,7 @@ InfoStringLoaderWeapon::InfoStringLoaderWeapon(MemoryManager& memory, ISearchPat
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult InfoStringLoaderWeapon::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
AssetCreationResult InfoStringLoaderWeapon::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const
|
||||
{
|
||||
auto* weaponFullDef = m_memory.Alloc<WeaponFullDef>();
|
||||
|
||||
|
@ -11,7 +11,7 @@ namespace IW5
|
||||
public:
|
||||
InfoStringLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context);
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const;
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
|
@ -40,7 +40,7 @@ namespace
|
||||
}
|
||||
|
||||
private:
|
||||
AssetCreationResult LoadGsc(const SearchPathOpenFile& file, const std::string& assetName, AssetCreationContext& context)
|
||||
AssetCreationResult LoadGsc(const SearchPathOpenFile& file, const std::string& assetName, AssetCreationContext& context) const
|
||||
{
|
||||
const auto uncompressedBuffer = std::make_unique<char[]>(static_cast<size_t>(file.m_length + 1));
|
||||
|
||||
@ -58,7 +58,7 @@ namespace
|
||||
zs.zfree = Z_NULL;
|
||||
zs.opaque = Z_NULL;
|
||||
zs.avail_in = static_cast<uInt>(file.m_length + 1);
|
||||
zs.avail_out = compressionBufferSize;
|
||||
zs.avail_out = static_cast<unsigned>(compressionBufferSize);
|
||||
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
||||
zs.next_out = reinterpret_cast<Bytef*>(&compressedBuffer[sizeof(uint32_t) + sizeof(uint32_t)]);
|
||||
|
||||
@ -79,7 +79,7 @@ namespace
|
||||
const auto compressedSize = compressionBufferSize - zs.avail_out;
|
||||
|
||||
reinterpret_cast<uint32_t*>(compressedBuffer)[0] = static_cast<uint32_t>(file.m_length + 1); // outLen
|
||||
reinterpret_cast<uint32_t*>(compressedBuffer)[1] = compressedSize; // inLen
|
||||
reinterpret_cast<uint32_t*>(compressedBuffer)[1] = static_cast<uint32_t>(compressedSize); // inLen
|
||||
|
||||
auto* rawFile = m_memory.Alloc<RawFile>();
|
||||
rawFile->name = m_memory.Dup(assetName.c_str());
|
||||
@ -91,7 +91,7 @@ namespace
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetRawFile>(assetName, rawFile));
|
||||
}
|
||||
|
||||
AssetCreationResult LoadDefault(const SearchPathOpenFile& file, const std::string& assetName, AssetCreationContext& context)
|
||||
AssetCreationResult LoadDefault(const SearchPathOpenFile& file, const std::string& assetName, AssetCreationContext& context) const
|
||||
{
|
||||
auto* rawFile = m_memory.Alloc<RawFile>();
|
||||
rawFile->name = m_memory.Dup(assetName.c_str());
|
||||
|
@ -5,9 +5,7 @@
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <sstream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
@ -25,8 +23,8 @@ namespace
|
||||
constexpr unsigned ROW_ALIAS_NAME = 2;
|
||||
constexpr unsigned ROW_ALIAS_BUTTON = 3;
|
||||
|
||||
constexpr const char* VALUE_TYPE_ICON = "icon";
|
||||
constexpr const char* VALUE_TYPE_ALIAS = "alias";
|
||||
constexpr auto VALUE_TYPE_ICON = "icon";
|
||||
constexpr auto VALUE_TYPE_ALIAS = "alias";
|
||||
|
||||
constexpr unsigned COL_COUNT_ICON = 7;
|
||||
constexpr unsigned COL_COUNT_ALIAS = 4;
|
||||
@ -125,8 +123,8 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
fontIcon->numEntries = entries.size();
|
||||
fontIcon->numAliasEntries = aliases.size();
|
||||
fontIcon->numEntries = static_cast<unsigned>(entries.size());
|
||||
fontIcon->numAliasEntries = static_cast<unsigned>(aliases.size());
|
||||
|
||||
if (fontIcon->numEntries > 0)
|
||||
{
|
||||
@ -159,7 +157,7 @@ namespace
|
||||
{
|
||||
for (auto& cell : row)
|
||||
{
|
||||
for (auto c : cell)
|
||||
for (const auto c : cell)
|
||||
{
|
||||
if (isspace(c))
|
||||
continue;
|
||||
@ -220,7 +218,7 @@ namespace
|
||||
const std::string& assetName,
|
||||
const unsigned rowIndex,
|
||||
AssetCreationContext& context,
|
||||
AssetRegistration<AssetFontIcon>& registration)
|
||||
AssetRegistration<AssetFontIcon>& registration) const
|
||||
{
|
||||
if (row.size() < COL_COUNT_ICON)
|
||||
{
|
||||
@ -246,6 +244,7 @@ namespace
|
||||
std::cerr << std::format("{} Failed to load material \"{}\"\n", ErrorPrefix(assetName, rowIndex), row[ROW_ICON_MATERIAL]);
|
||||
return false;
|
||||
}
|
||||
registration.AddDependency(materialDependency);
|
||||
|
||||
icon.fontIconMaterialHandle = materialDependency->Asset();
|
||||
icon.fontIconName.string = m_memory.Dup(row[ROW_ICON_NAME].c_str());
|
||||
@ -254,7 +253,7 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadAliasRow(
|
||||
static bool ReadAliasRow(
|
||||
const std::vector<std::string>& row, FontIconAlias& alias, const std::string& assetName, const unsigned rowIndex, AssetCreationContext& context)
|
||||
{
|
||||
if (row.size() < COL_COUNT_ALIAS)
|
||||
|
@ -32,8 +32,8 @@ namespace
|
||||
|
||||
const auto fileSize = static_cast<size_t>(file.m_length);
|
||||
const auto fileData = std::make_unique<char[]>(fileSize);
|
||||
file.m_stream->read(fileData.get(), fileSize);
|
||||
const auto dataHash = static_cast<unsigned>(crc32(0u, reinterpret_cast<const Bytef*>(fileData.get()), fileSize));
|
||||
file.m_stream->read(fileData.get(), static_cast<std::streamsize>(fileSize));
|
||||
const auto dataHash = static_cast<unsigned>(crc32(0u, reinterpret_cast<const Bytef*>(fileData.get()), static_cast<unsigned>(fileSize)));
|
||||
|
||||
std::istringstream ss(std::string(fileData.get(), fileSize));
|
||||
const auto texture = iwi::LoadIwi(ss);
|
||||
|
@ -58,7 +58,7 @@ namespace
|
||||
zs.zfree = Z_NULL;
|
||||
zs.opaque = Z_NULL;
|
||||
zs.avail_in = static_cast<uInt>(file.m_length);
|
||||
zs.avail_out = compressionBufferSize;
|
||||
zs.avail_out = static_cast<unsigned>(compressionBufferSize);
|
||||
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
||||
zs.next_out = reinterpret_cast<Bytef*>(&compressedBuffer[sizeof(uint32_t)]);
|
||||
|
||||
@ -92,7 +92,7 @@ namespace
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetRawFile>(assetName, rawFile));
|
||||
}
|
||||
|
||||
AssetCreationResult LoadDefault(const SearchPathOpenFile& file, const std::string& assetName, AssetCreationContext& context)
|
||||
AssetCreationResult LoadDefault(const SearchPathOpenFile& file, const std::string& assetName, AssetCreationContext& context) const
|
||||
{
|
||||
auto* rawFile = m_memory.Alloc<RawFile>();
|
||||
rawFile->name = m_memory.Dup(assetName.c_str());
|
||||
|
@ -679,7 +679,7 @@ namespace
|
||||
if (!aliasList.empty())
|
||||
aliasLists.emplace_back(CreateAliasList(aliasList, memory));
|
||||
|
||||
sndBank->aliasCount = aliasLists.size();
|
||||
sndBank->aliasCount = static_cast<unsigned>(aliasLists.size());
|
||||
if (sndBank->aliasCount)
|
||||
{
|
||||
sndBank->alias = memory.Alloc<SndAliasList>(sndBank->aliasCount);
|
||||
@ -702,7 +702,7 @@ namespace
|
||||
const auto idx = sndBank->alias[i].id % sndBank->aliasCount;
|
||||
if (sndBank->aliasIndex[idx].value == std::numeric_limits<unsigned short>::max())
|
||||
{
|
||||
sndBank->aliasIndex[idx].value = i;
|
||||
sndBank->aliasIndex[idx].value = static_cast<unsigned short>(i);
|
||||
sndBank->aliasIndex[idx].next = std::numeric_limits<unsigned short>::max();
|
||||
setAliasIndexList[i] = true;
|
||||
}
|
||||
@ -720,14 +720,14 @@ namespace
|
||||
}
|
||||
|
||||
auto offset = 1u;
|
||||
auto freeIdx = std::numeric_limits<unsigned short>::max();
|
||||
unsigned short freeIdx;
|
||||
while (true)
|
||||
{
|
||||
freeIdx = (idx + offset) % sndBank->aliasCount;
|
||||
freeIdx = static_cast<unsigned short>((idx + offset) % sndBank->aliasCount);
|
||||
if (sndBank->aliasIndex[freeIdx].value == std::numeric_limits<unsigned short>::max())
|
||||
break;
|
||||
|
||||
freeIdx = (idx + sndBank->aliasCount - offset) % sndBank->aliasCount;
|
||||
freeIdx = static_cast<unsigned short>((idx + sndBank->aliasCount - offset) % sndBank->aliasCount);
|
||||
if (sndBank->aliasIndex[freeIdx].value == std::numeric_limits<unsigned short>::max())
|
||||
break;
|
||||
|
||||
@ -745,7 +745,7 @@ namespace
|
||||
}
|
||||
|
||||
sndBank->aliasIndex[idx].next = freeIdx;
|
||||
sndBank->aliasIndex[freeIdx].value = i;
|
||||
sndBank->aliasIndex[freeIdx].value = static_cast<unsigned short>(i);
|
||||
sndBank->aliasIndex[freeIdx].next = std::numeric_limits<unsigned short>::max();
|
||||
setAliasIndexList[i] = true;
|
||||
}
|
||||
@ -849,7 +849,7 @@ namespace
|
||||
radverbs.emplace_back(radverb);
|
||||
}
|
||||
|
||||
sndBank->radverbCount = radverbs.size();
|
||||
sndBank->radverbCount = static_cast<unsigned>(radverbs.size());
|
||||
if (sndBank->radverbCount)
|
||||
{
|
||||
sndBank->radverbs = memory.Alloc<SndRadverb>(sndBank->radverbCount);
|
||||
@ -912,7 +912,7 @@ namespace
|
||||
|
||||
for (auto& valueJson : duckJson["values"])
|
||||
{
|
||||
auto index = GetValueIndex(valueJson["duckGroup"].get<std::string>(), SOUND_DUCK_GROUPS, std::extent_v<decltype(SOUND_DUCK_GROUPS)>);
|
||||
const auto index = GetValueIndex(valueJson["duckGroup"].get<std::string>(), SOUND_DUCK_GROUPS, std::extent_v<decltype(SOUND_DUCK_GROUPS)>);
|
||||
|
||||
duck.attenuation[index] = valueJson["attenuation"].get<float>();
|
||||
duck.filter[index] = valueJson["filter"].get<float>();
|
||||
@ -921,7 +921,7 @@ namespace
|
||||
ducks.emplace_back(duck);
|
||||
}
|
||||
|
||||
sndBank->duckCount = ducks.size();
|
||||
sndBank->duckCount = static_cast<unsigned>(ducks.size());
|
||||
if (sndBank->duckCount)
|
||||
{
|
||||
sndBank->ducks = memory.Alloc<SndDuck>(sndBank->duckCount);
|
||||
@ -1046,7 +1046,7 @@ namespace
|
||||
|
||||
if (result)
|
||||
{
|
||||
sndBank->loadedAssets.dataSize = dataSize;
|
||||
sndBank->loadedAssets.dataSize = static_cast<unsigned>(dataSize);
|
||||
sndBank->loadedAssets.data = m_memory.Alloc<SndChar2048>(dataSize);
|
||||
}
|
||||
else
|
||||
|
@ -574,12 +574,12 @@ namespace
|
||||
{
|
||||
if (lastSibling == nullptr)
|
||||
{
|
||||
attachmentUnique.childLink = attachmentUniqueIndex;
|
||||
attachmentUnique.childLink = static_cast<int>(attachmentUniqueIndex);
|
||||
lastSibling = weapon.attachmentUniques[attachmentUniqueIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
lastSibling->siblingLink = attachmentUniqueIndex;
|
||||
lastSibling->siblingLink = static_cast<int>(attachmentUniqueIndex);
|
||||
lastSibling = weapon.attachmentUniques[attachmentUniqueIndex];
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ namespace
|
||||
{
|
||||
if (!jWeaponCamoMaterialSet.materials.empty())
|
||||
{
|
||||
weaponCamoMaterialSet.numMaterials = jWeaponCamoMaterialSet.materials.size();
|
||||
weaponCamoMaterialSet.numMaterials = static_cast<unsigned>(jWeaponCamoMaterialSet.materials.size());
|
||||
weaponCamoMaterialSet.materials = m_memory.Alloc<WeaponCamoMaterial>(weaponCamoMaterialSet.numMaterials);
|
||||
|
||||
for (auto i = 0u; i < weaponCamoMaterialSet.numMaterials; i++)
|
||||
@ -197,7 +197,7 @@ namespace
|
||||
|
||||
if (!jWeaponCamo.camoSets.empty())
|
||||
{
|
||||
weaponCamo.numCamoSets = jWeaponCamo.camoSets.size();
|
||||
weaponCamo.numCamoSets = static_cast<unsigned>(jWeaponCamo.camoSets.size());
|
||||
weaponCamo.camoSets = m_memory.Alloc<WeaponCamoSet>(weaponCamo.numCamoSets);
|
||||
|
||||
for (auto i = 0u; i < weaponCamo.numCamoSets; i++)
|
||||
@ -214,7 +214,7 @@ namespace
|
||||
|
||||
if (!jWeaponCamo.camoMaterials.empty())
|
||||
{
|
||||
weaponCamo.numCamoMaterials = jWeaponCamo.camoMaterials.size();
|
||||
weaponCamo.numCamoMaterials = static_cast<unsigned>(jWeaponCamo.camoMaterials.size());
|
||||
weaponCamo.camoMaterials = m_memory.Alloc<WeaponCamoMaterialSet>(weaponCamo.numCamoMaterials);
|
||||
|
||||
for (auto i = 0u; i < weaponCamo.numCamoMaterials; i++)
|
||||
|
Reference in New Issue
Block a user