mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-05-07 04:54:57 +00:00
refactor: make memory from zone a reference instead of ptr
This commit is contained in:
parent
9e940a6f53
commit
8b85cadb77
@ -11,7 +11,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// No compilers yet
|
// No compilers yet
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ namespace
|
|||||||
ZoneAssetCreationStateContainer& zoneStates,
|
ZoneAssetCreationStateContainer& zoneStates,
|
||||||
IOutputPath& outDir)
|
IOutputPath& outDir)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
||||||
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
||||||
|
@ -11,7 +11,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// No compilers yet
|
// No compilers yet
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ namespace
|
|||||||
ZoneAssetCreationStateContainer& zoneStates,
|
ZoneAssetCreationStateContainer& zoneStates,
|
||||||
IOutputPath& outDir)
|
IOutputPath& outDir)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
||||||
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
||||||
|
@ -11,7 +11,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// No compilers yet
|
// No compilers yet
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ namespace
|
|||||||
ZoneAssetCreationStateContainer& zoneStates,
|
ZoneAssetCreationStateContainer& zoneStates,
|
||||||
IOutputPath& outDir)
|
IOutputPath& outDir)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
||||||
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
||||||
|
@ -11,7 +11,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureCompilers(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// No compilers yet
|
// No compilers yet
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ namespace
|
|||||||
ZoneAssetCreationStateContainer& zoneStates,
|
ZoneAssetCreationStateContainer& zoneStates,
|
||||||
IOutputPath& outDir)
|
IOutputPath& outDir)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
if (ImageIwdPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
||||||
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
collection.AddAssetPostProcessor(std::make_unique<ImageIwdPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
||||||
|
@ -17,7 +17,7 @@ namespace
|
|||||||
ISearchPath& searchPath,
|
ISearchPath& searchPath,
|
||||||
ZoneAssetCreationStateContainer& zoneStates)
|
ZoneAssetCreationStateContainer& zoneStates)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddAssetCreator(CreateKeyValuePairsCompiler(memory, zone, zoneDefinition.m_zone_definition, zoneStates));
|
collection.AddAssetCreator(CreateKeyValuePairsCompiler(memory, zone, zoneDefinition.m_zone_definition, zoneStates));
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ namespace
|
|||||||
ZoneAssetCreationStateContainer& zoneStates,
|
ZoneAssetCreationStateContainer& zoneStates,
|
||||||
IOutputPath& outDir)
|
IOutputPath& outDir)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
if (ImageIPakPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
if (ImageIPakPostProcessor<AssetImage>::AppliesToZoneDefinition(zoneDefinition))
|
||||||
collection.AddAssetPostProcessor(std::make_unique<ImageIPakPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
collection.AddAssetPostProcessor(std::make_unique<ImageIPakPostProcessor<AssetImage>>(zoneDefinition, searchPath, zoneStates, outDir));
|
||||||
|
@ -21,7 +21,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetXAnim>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetXAnim>>(memory));
|
||||||
@ -85,7 +85,7 @@ namespace
|
|||||||
|
|
||||||
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
|
||||||
|
@ -12,10 +12,10 @@ MenuConversionZoneState::MenuConversionZoneState()
|
|||||||
|
|
||||||
void MenuConversionZoneState::Inject(ZoneAssetCreationInjection& inject)
|
void MenuConversionZoneState::Inject(ZoneAssetCreationInjection& inject)
|
||||||
{
|
{
|
||||||
auto* memory = inject.m_zone.GetMemory();
|
auto& memory = inject.m_zone.Memory();
|
||||||
|
|
||||||
m_zone = &inject.m_zone;
|
m_zone = &inject.m_zone;
|
||||||
m_supporting_data = memory->Alloc<ExpressionSupportingData>();
|
m_supporting_data = memory.Alloc<ExpressionSupportingData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement_s* MenuConversionZoneState::FindFunction(const std::string& functionName)
|
Statement_s* MenuConversionZoneState::FindFunction(const std::string& functionName)
|
||||||
@ -43,10 +43,10 @@ size_t MenuConversionZoneState::AddStaticDvar(const std::string& dvarName)
|
|||||||
if (foundDvar != m_dvars_by_name.end())
|
if (foundDvar != m_dvars_by_name.end())
|
||||||
return foundDvar->second;
|
return foundDvar->second;
|
||||||
|
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
auto* staticDvar = memory->Alloc<StaticDvar>();
|
auto* staticDvar = memory.Alloc<StaticDvar>();
|
||||||
|
|
||||||
staticDvar->dvarName = memory->Dup(dvarName.c_str());
|
staticDvar->dvarName = memory.Dup(dvarName.c_str());
|
||||||
staticDvar->dvar = nullptr;
|
staticDvar->dvar = nullptr;
|
||||||
|
|
||||||
const auto staticDvarIndex = m_static_dvars.size();
|
const auto staticDvarIndex = m_static_dvars.size();
|
||||||
@ -63,8 +63,8 @@ const char* MenuConversionZoneState::AddString(const std::string& str)
|
|||||||
if (foundString != m_strings_by_value.end())
|
if (foundString != m_strings_by_value.end())
|
||||||
return foundString->second;
|
return foundString->second;
|
||||||
|
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
const auto* strDuped = memory->Dup(str.c_str());
|
const auto* strDuped = memory.Dup(str.c_str());
|
||||||
|
|
||||||
m_strings.push_back(strDuped);
|
m_strings.push_back(strDuped);
|
||||||
m_strings_by_value.emplace(std::make_pair(str, strDuped));
|
m_strings_by_value.emplace(std::make_pair(str, strDuped));
|
||||||
@ -79,24 +79,24 @@ void MenuConversionZoneState::AddLoadedFile(std::string loadedFileName, std::vec
|
|||||||
|
|
||||||
void MenuConversionZoneState::FinalizeSupportingData() const
|
void MenuConversionZoneState::FinalizeSupportingData() const
|
||||||
{
|
{
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
|
|
||||||
m_supporting_data->uifunctions.totalFunctions = static_cast<int>(m_functions.size());
|
m_supporting_data->uifunctions.totalFunctions = static_cast<int>(m_functions.size());
|
||||||
m_supporting_data->staticDvarList.numStaticDvars = static_cast<int>(m_static_dvars.size());
|
m_supporting_data->staticDvarList.numStaticDvars = static_cast<int>(m_static_dvars.size());
|
||||||
m_supporting_data->uiStrings.totalStrings = static_cast<int>(m_strings.size());
|
m_supporting_data->uiStrings.totalStrings = static_cast<int>(m_strings.size());
|
||||||
|
|
||||||
if (m_supporting_data->uifunctions.functions)
|
if (m_supporting_data->uifunctions.functions)
|
||||||
memory->Free(m_supporting_data->uifunctions.functions);
|
memory.Free(m_supporting_data->uifunctions.functions);
|
||||||
|
|
||||||
if (m_supporting_data->staticDvarList.staticDvars)
|
if (m_supporting_data->staticDvarList.staticDvars)
|
||||||
memory->Free(m_supporting_data->staticDvarList.staticDvars);
|
memory.Free(m_supporting_data->staticDvarList.staticDvars);
|
||||||
|
|
||||||
if (m_supporting_data->uiStrings.strings)
|
if (m_supporting_data->uiStrings.strings)
|
||||||
memory->Free(m_supporting_data->uiStrings.strings);
|
memory.Free(m_supporting_data->uiStrings.strings);
|
||||||
|
|
||||||
if (!m_functions.empty())
|
if (!m_functions.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->uifunctions.functions = memory->Alloc<Statement_s*>(m_functions.size());
|
m_supporting_data->uifunctions.functions = memory.Alloc<Statement_s*>(m_functions.size());
|
||||||
memcpy(m_supporting_data->uifunctions.functions, m_functions.data(), sizeof(void*) * m_functions.size());
|
memcpy(m_supporting_data->uifunctions.functions, m_functions.data(), sizeof(void*) * m_functions.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -104,7 +104,7 @@ void MenuConversionZoneState::FinalizeSupportingData() const
|
|||||||
|
|
||||||
if (!m_static_dvars.empty())
|
if (!m_static_dvars.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->staticDvarList.staticDvars = memory->Alloc<StaticDvar*>(m_static_dvars.size());
|
m_supporting_data->staticDvarList.staticDvars = memory.Alloc<StaticDvar*>(m_static_dvars.size());
|
||||||
memcpy(m_supporting_data->staticDvarList.staticDvars, m_static_dvars.data(), sizeof(void*) * m_static_dvars.size());
|
memcpy(m_supporting_data->staticDvarList.staticDvars, m_static_dvars.data(), sizeof(void*) * m_static_dvars.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -112,7 +112,7 @@ void MenuConversionZoneState::FinalizeSupportingData() const
|
|||||||
|
|
||||||
if (!m_strings.empty())
|
if (!m_strings.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->uiStrings.strings = memory->Alloc<const char*>(m_strings.size());
|
m_supporting_data->uiStrings.strings = memory.Alloc<const char*>(m_strings.size());
|
||||||
memcpy(m_supporting_data->uiStrings.strings, m_strings.data(), sizeof(void*) * m_strings.size());
|
memcpy(m_supporting_data->uiStrings.strings, m_strings.data(), sizeof(void*) * m_strings.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -34,7 +34,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysCollMap>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysCollMap>>(memory));
|
||||||
@ -118,7 +118,7 @@ namespace
|
|||||||
|
|
||||||
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddAssetCreator(std::make_unique<RawLoaderPhysPreset>(memory, searchPath, zone));
|
collection.AddAssetCreator(std::make_unique<RawLoaderPhysPreset>(memory, searchPath, zone));
|
||||||
collection.AddAssetCreator(std::make_unique<GdtLoaderPhysPreset>(memory, gdt, zone));
|
collection.AddAssetCreator(std::make_unique<GdtLoaderPhysPreset>(memory, gdt, zone));
|
||||||
|
@ -12,10 +12,10 @@ MenuConversionZoneState::MenuConversionZoneState()
|
|||||||
|
|
||||||
void MenuConversionZoneState::Inject(ZoneAssetCreationInjection& inject)
|
void MenuConversionZoneState::Inject(ZoneAssetCreationInjection& inject)
|
||||||
{
|
{
|
||||||
auto* memory = inject.m_zone.GetMemory();
|
auto& memory = inject.m_zone.Memory();
|
||||||
|
|
||||||
m_zone = &inject.m_zone;
|
m_zone = &inject.m_zone;
|
||||||
m_supporting_data = memory->Alloc<ExpressionSupportingData>();
|
m_supporting_data = memory.Alloc<ExpressionSupportingData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement_s* MenuConversionZoneState::FindFunction(const std::string& functionName)
|
Statement_s* MenuConversionZoneState::FindFunction(const std::string& functionName)
|
||||||
@ -43,10 +43,10 @@ size_t MenuConversionZoneState::AddStaticDvar(const std::string& dvarName)
|
|||||||
if (foundDvar != m_dvars_by_name.end())
|
if (foundDvar != m_dvars_by_name.end())
|
||||||
return foundDvar->second;
|
return foundDvar->second;
|
||||||
|
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
auto* staticDvar = memory->Alloc<StaticDvar>();
|
auto* staticDvar = memory.Alloc<StaticDvar>();
|
||||||
|
|
||||||
staticDvar->dvarName = memory->Dup(dvarName.c_str());
|
staticDvar->dvarName = memory.Dup(dvarName.c_str());
|
||||||
staticDvar->dvar = nullptr;
|
staticDvar->dvar = nullptr;
|
||||||
|
|
||||||
const auto staticDvarIndex = m_static_dvars.size();
|
const auto staticDvarIndex = m_static_dvars.size();
|
||||||
@ -63,8 +63,8 @@ const char* MenuConversionZoneState::AddString(const std::string& str)
|
|||||||
if (foundString != m_strings_by_value.end())
|
if (foundString != m_strings_by_value.end())
|
||||||
return foundString->second;
|
return foundString->second;
|
||||||
|
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
const auto* strDuped = memory->Dup(str.c_str());
|
const auto* strDuped = memory.Dup(str.c_str());
|
||||||
|
|
||||||
m_strings.push_back(strDuped);
|
m_strings.push_back(strDuped);
|
||||||
m_strings_by_value.emplace(std::make_pair(str, strDuped));
|
m_strings_by_value.emplace(std::make_pair(str, strDuped));
|
||||||
@ -79,24 +79,24 @@ void MenuConversionZoneState::AddLoadedFile(std::string loadedFileName, std::vec
|
|||||||
|
|
||||||
void MenuConversionZoneState::FinalizeSupportingData() const
|
void MenuConversionZoneState::FinalizeSupportingData() const
|
||||||
{
|
{
|
||||||
auto* memory = m_zone->GetMemory();
|
auto& memory = m_zone->Memory();
|
||||||
|
|
||||||
m_supporting_data->uifunctions.totalFunctions = static_cast<int>(m_functions.size());
|
m_supporting_data->uifunctions.totalFunctions = static_cast<int>(m_functions.size());
|
||||||
m_supporting_data->staticDvarList.numStaticDvars = static_cast<int>(m_static_dvars.size());
|
m_supporting_data->staticDvarList.numStaticDvars = static_cast<int>(m_static_dvars.size());
|
||||||
m_supporting_data->uiStrings.totalStrings = static_cast<int>(m_strings.size());
|
m_supporting_data->uiStrings.totalStrings = static_cast<int>(m_strings.size());
|
||||||
|
|
||||||
if (m_supporting_data->uifunctions.functions)
|
if (m_supporting_data->uifunctions.functions)
|
||||||
memory->Free(m_supporting_data->uifunctions.functions);
|
memory.Free(m_supporting_data->uifunctions.functions);
|
||||||
|
|
||||||
if (m_supporting_data->staticDvarList.staticDvars)
|
if (m_supporting_data->staticDvarList.staticDvars)
|
||||||
memory->Free(m_supporting_data->staticDvarList.staticDvars);
|
memory.Free(m_supporting_data->staticDvarList.staticDvars);
|
||||||
|
|
||||||
if (m_supporting_data->uiStrings.strings)
|
if (m_supporting_data->uiStrings.strings)
|
||||||
memory->Free(m_supporting_data->uiStrings.strings);
|
memory.Free(m_supporting_data->uiStrings.strings);
|
||||||
|
|
||||||
if (!m_functions.empty())
|
if (!m_functions.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->uifunctions.functions = memory->Alloc<Statement_s*>(m_functions.size());
|
m_supporting_data->uifunctions.functions = memory.Alloc<Statement_s*>(m_functions.size());
|
||||||
memcpy(m_supporting_data->uifunctions.functions, m_functions.data(), sizeof(void*) * m_functions.size());
|
memcpy(m_supporting_data->uifunctions.functions, m_functions.data(), sizeof(void*) * m_functions.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -104,7 +104,7 @@ void MenuConversionZoneState::FinalizeSupportingData() const
|
|||||||
|
|
||||||
if (!m_static_dvars.empty())
|
if (!m_static_dvars.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->staticDvarList.staticDvars = memory->Alloc<StaticDvar*>(m_static_dvars.size());
|
m_supporting_data->staticDvarList.staticDvars = memory.Alloc<StaticDvar*>(m_static_dvars.size());
|
||||||
memcpy(m_supporting_data->staticDvarList.staticDvars, m_static_dvars.data(), sizeof(void*) * m_static_dvars.size());
|
memcpy(m_supporting_data->staticDvarList.staticDvars, m_static_dvars.data(), sizeof(void*) * m_static_dvars.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -112,7 +112,7 @@ void MenuConversionZoneState::FinalizeSupportingData() const
|
|||||||
|
|
||||||
if (!m_strings.empty())
|
if (!m_strings.empty())
|
||||||
{
|
{
|
||||||
m_supporting_data->uiStrings.strings = memory->Alloc<const char*>(m_strings.size());
|
m_supporting_data->uiStrings.strings = memory.Alloc<const char*>(m_strings.size());
|
||||||
memcpy(m_supporting_data->uiStrings.strings, m_strings.data(), sizeof(void*) * m_strings.size());
|
memcpy(m_supporting_data->uiStrings.strings, m_strings.data(), sizeof(void*) * m_strings.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -29,7 +29,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysCollMap>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysCollMap>>(memory));
|
||||||
@ -119,7 +119,7 @@ namespace
|
|||||||
|
|
||||||
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysCollMap>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysCollMap>(memory));
|
||||||
|
@ -21,7 +21,7 @@ namespace
|
|||||||
{
|
{
|
||||||
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysConstraints>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysConstraints>>(memory));
|
||||||
@ -97,7 +97,7 @@ namespace
|
|||||||
|
|
||||||
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysPreset>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysConstraints>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysConstraints>(memory));
|
||||||
|
@ -284,7 +284,7 @@ namespace T6
|
|||||||
{
|
{
|
||||||
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
void ConfigureDefaultCreators(AssetCreatorCollection& collection, Zone& zone)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
|
||||||
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysConstraints>>(memory));
|
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysConstraints>>(memory));
|
||||||
@ -390,7 +390,7 @@ namespace T6
|
|||||||
|
|
||||||
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
||||||
{
|
{
|
||||||
auto& memory = *zone.GetMemory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddAssetCreator(CreateRawPhysPresetLoader(memory, searchPath, zone));
|
collection.AddAssetCreator(CreateRawPhysPresetLoader(memory, searchPath, zone));
|
||||||
collection.AddAssetCreator(CreateGdtPhysPresetLoader(memory, searchPath, gdt, zone));
|
collection.AddAssetCreator(CreateGdtPhysPresetLoader(memory, searchPath, gdt, zone));
|
||||||
|
@ -1269,7 +1269,7 @@ namespace
|
|||||||
LINEF("{0} marker(m_zone);", MarkerClassName(m_env.m_asset))
|
LINEF("{0} marker(m_zone);", MarkerClassName(m_env.m_asset))
|
||||||
LINE("marker.Mark(*pAsset);")
|
LINE("marker.Mark(*pAsset);")
|
||||||
LINE("")
|
LINE("")
|
||||||
LINEF("auto* reallocatedAsset = m_zone.GetMemory()->Alloc<{0}>();", info->m_definition->GetFullName())
|
LINEF("auto* reallocatedAsset = m_zone.Memory().Alloc<{0}>();", info->m_definition->GetFullName())
|
||||||
LINEF("std::memcpy(reallocatedAsset, *pAsset, sizeof({0}));", info->m_definition->GetFullName())
|
LINEF("std::memcpy(reallocatedAsset, *pAsset, sizeof({0}));", info->m_definition->GetFullName())
|
||||||
LINE("")
|
LINE("")
|
||||||
LINEF("m_asset_info = reinterpret_cast<XAssetInfo<{0}>*>(LinkAsset(AssetNameAccessor<{1}>()(**pAsset), reallocatedAsset, marker.GetDependencies(), "
|
LINEF("m_asset_info = reinterpret_cast<XAssetInfo<{0}>*>(LinkAsset(AssetNameAccessor<{1}>()(**pAsset), reallocatedAsset, marker.GetDependencies(), "
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include "Zone.h"
|
#include "Zone.h"
|
||||||
|
|
||||||
Zone::Zone(std::string name, const zone_priority_t priority, IGame* game)
|
Zone::Zone(std::string name, const zone_priority_t priority, IGame* game)
|
||||||
: m_memory(std::make_unique<ZoneMemory>()),
|
: m_name(std::move(name)),
|
||||||
m_registered(false),
|
|
||||||
m_name(std::move(name)),
|
|
||||||
m_priority(priority),
|
m_priority(priority),
|
||||||
m_language(GameLanguage::LANGUAGE_NONE),
|
m_language(GameLanguage::LANGUAGE_NONE),
|
||||||
m_game(game),
|
m_game(game),
|
||||||
m_pools(ZoneAssetPools::CreateForGame(game->GetId(), this, priority))
|
m_pools(ZoneAssetPools::CreateForGame(game->GetId(), this, priority)),
|
||||||
|
m_memory(std::make_unique<ZoneMemory>()),
|
||||||
|
m_registered(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ void Zone::Register()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoneMemory* Zone::GetMemory() const
|
ZoneMemory& Zone::Memory() const
|
||||||
{
|
{
|
||||||
return m_memory.get();
|
return *m_memory;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "Game/GameLanguage.h"
|
#include "Game/GameLanguage.h"
|
||||||
#include "Game/IGame.h"
|
#include "Game/IGame.h"
|
||||||
#include "Pool/ZoneAssetPools.h"
|
#include "Pool/ZoneAssetPools.h"
|
||||||
#include "Utils/ClassUtils.h"
|
|
||||||
#include "Zone/ZoneTypes.h"
|
#include "Zone/ZoneTypes.h"
|
||||||
#include "ZoneMemory.h"
|
#include "ZoneMemory.h"
|
||||||
#include "ZoneScriptStrings.h"
|
#include "ZoneScriptStrings.h"
|
||||||
@ -16,10 +15,6 @@ class ZoneAssetPools;
|
|||||||
|
|
||||||
class Zone
|
class Zone
|
||||||
{
|
{
|
||||||
std::unique_ptr<ZoneMemory> m_memory;
|
|
||||||
|
|
||||||
bool m_registered;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
zone_priority_t m_priority;
|
zone_priority_t m_priority;
|
||||||
@ -37,5 +32,10 @@ public:
|
|||||||
|
|
||||||
void Register();
|
void Register();
|
||||||
|
|
||||||
_NODISCARD ZoneMemory* GetMemory() const;
|
[[nodiscard]] ZoneMemory& Memory() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<ZoneMemory> m_memory;
|
||||||
|
|
||||||
|
bool m_registered;
|
||||||
};
|
};
|
||||||
|
@ -19,6 +19,6 @@ void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image)
|
|||||||
{
|
{
|
||||||
const size_t loadDefSize = offsetof(IW3::GfxImageLoadDef, data) + loadDef->resourceSize;
|
const size_t loadDefSize = offsetof(IW3::GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||||
|
|
||||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.GetMemory()->AllocRaw(loadDefSize));
|
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.Memory().AllocRaw(loadDefSize));
|
||||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ void Actions_LoadedSound::SetSoundData(MssSound* sound) const
|
|||||||
if (sound->info.data_len > 0)
|
if (sound->info.data_len > 0)
|
||||||
{
|
{
|
||||||
const auto* tempData = sound->data;
|
const auto* tempData = sound->data;
|
||||||
sound->data = m_zone.GetMemory()->Alloc<char>(sound->info.data_len);
|
sound->data = m_zone.Memory().Alloc<char>(sound->info.data_len);
|
||||||
memcpy(sound->data, tempData, sound->info.data_len);
|
memcpy(sound->data, tempData, sound->info.data_len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -19,6 +19,6 @@ void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image)
|
|||||||
{
|
{
|
||||||
const size_t loadDefSize = offsetof(IW4::GfxImageLoadDef, data) + loadDef->resourceSize;
|
const size_t loadDefSize = offsetof(IW4::GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||||
|
|
||||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.GetMemory()->AllocRaw(loadDefSize));
|
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.Memory().AllocRaw(loadDefSize));
|
||||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ void Actions_LoadedSound::SetSoundData(MssSound* sound) const
|
|||||||
if (sound->info.data_len > 0)
|
if (sound->info.data_len > 0)
|
||||||
{
|
{
|
||||||
const auto* tempData = sound->data;
|
const auto* tempData = sound->data;
|
||||||
sound->data = m_zone.GetMemory()->Alloc<char>(sound->info.data_len);
|
sound->data = m_zone.Memory().Alloc<char>(sound->info.data_len);
|
||||||
memcpy(sound->data, tempData, sound->info.data_len);
|
memcpy(sound->data, tempData, sound->info.data_len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -13,7 +13,7 @@ void Actions_XModel::SetModelSurfs(XModelLodInfo* lodInfo, XModelSurfs* modelSur
|
|||||||
{
|
{
|
||||||
if (modelSurfs)
|
if (modelSurfs)
|
||||||
{
|
{
|
||||||
lodInfo->modelSurfs = m_zone.GetMemory()->Alloc<XModelSurfs>();
|
lodInfo->modelSurfs = m_zone.Memory().Alloc<XModelSurfs>();
|
||||||
memcpy(lodInfo->modelSurfs, modelSurfs, sizeof(XModelSurfs));
|
memcpy(lodInfo->modelSurfs, modelSurfs, sizeof(XModelSurfs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,6 @@ Actions_clipMap_t::Actions_clipMap_t(Zone& zone)
|
|||||||
|
|
||||||
void Actions_clipMap_t::ReallocClipInfo(const ClipInfo* clipInfo, clipMap_t* clipMap) const
|
void Actions_clipMap_t::ReallocClipInfo(const ClipInfo* clipInfo, clipMap_t* clipMap) const
|
||||||
{
|
{
|
||||||
clipMap->pInfo = m_zone.GetMemory()->Alloc<ClipInfo>();
|
clipMap->pInfo = m_zone.Memory().Alloc<ClipInfo>();
|
||||||
memcpy(clipMap->pInfo, clipInfo, sizeof(ClipInfo));
|
memcpy(clipMap->pInfo, clipInfo, sizeof(ClipInfo));
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,6 @@ void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image)
|
|||||||
{
|
{
|
||||||
const size_t loadDefSize = offsetof(IW5::GfxImageLoadDef, data) + loadDef->resourceSize;
|
const size_t loadDefSize = offsetof(IW5::GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||||
|
|
||||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.GetMemory()->AllocRaw(loadDefSize));
|
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.Memory().AllocRaw(loadDefSize));
|
||||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ void Actions_LoadedSound::SetSoundData(MssSound* sound) const
|
|||||||
if (sound->info.data_len > 0)
|
if (sound->info.data_len > 0)
|
||||||
{
|
{
|
||||||
char* tempData = sound->data;
|
char* tempData = sound->data;
|
||||||
sound->data = m_zone.GetMemory()->Alloc<char>(sound->info.data_len);
|
sound->data = m_zone.Memory().Alloc<char>(sound->info.data_len);
|
||||||
memcpy(sound->data, tempData, sound->info.data_len);
|
memcpy(sound->data, tempData, sound->info.data_len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -13,7 +13,7 @@ void Actions_XModel::SetModelSurfs(XModelLodInfo* lodInfo, XModelSurfs* modelSur
|
|||||||
{
|
{
|
||||||
if (modelSurfs)
|
if (modelSurfs)
|
||||||
{
|
{
|
||||||
lodInfo->modelSurfs = m_zone.GetMemory()->Alloc<XModelSurfs>();
|
lodInfo->modelSurfs = m_zone.Memory().Alloc<XModelSurfs>();
|
||||||
memcpy(lodInfo->modelSurfs, modelSurfs, sizeof(XModelSurfs));
|
memcpy(lodInfo->modelSurfs, modelSurfs, sizeof(XModelSurfs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,6 @@ void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image)
|
|||||||
{
|
{
|
||||||
const size_t loadDefSize = offsetof(GfxImageLoadDef, data) + loadDef->resourceSize;
|
const size_t loadDefSize = offsetof(GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||||
|
|
||||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.GetMemory()->AllocRaw(loadDefSize));
|
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.Memory().AllocRaw(loadDefSize));
|
||||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,6 @@ void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image)
|
|||||||
{
|
{
|
||||||
const size_t loadDefSize = offsetof(T6::GfxImageLoadDef, data) + loadDef->resourceSize;
|
const size_t loadDefSize = offsetof(T6::GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||||
|
|
||||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.GetMemory()->AllocRaw(loadDefSize));
|
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.Memory().AllocRaw(loadDefSize));
|
||||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
ContentLoaderBase::ContentLoaderBase(Zone& zone)
|
ContentLoaderBase::ContentLoaderBase(Zone& zone)
|
||||||
: varXString(nullptr),
|
: varXString(nullptr),
|
||||||
m_zone(zone),
|
m_zone(zone),
|
||||||
m_memory(*zone.GetMemory()),
|
m_memory(zone.Memory()),
|
||||||
m_stream(nullptr)
|
m_stream(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -13,7 +13,7 @@ ContentLoaderBase::ContentLoaderBase(Zone& zone)
|
|||||||
ContentLoaderBase::ContentLoaderBase(Zone& zone, IZoneInputStream* stream)
|
ContentLoaderBase::ContentLoaderBase(Zone& zone, IZoneInputStream* stream)
|
||||||
: varXString(nullptr),
|
: varXString(nullptr),
|
||||||
m_zone(zone),
|
m_zone(zone),
|
||||||
m_memory(*zone.GetMemory()),
|
m_memory(zone.Memory()),
|
||||||
m_stream(stream)
|
m_stream(stream)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ void ZoneLoader::AddXBlock(std::unique_ptr<XBlock> block)
|
|||||||
return b1->m_index < b2->m_index;
|
return b1->m_index < b2->m_index;
|
||||||
});
|
});
|
||||||
|
|
||||||
m_zone->GetMemory()->AddBlock(std::move(block));
|
m_zone->Memory().AddBlock(std::move(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneLoader::AddLoadingStep(std::unique_ptr<ILoadingStep> step)
|
void ZoneLoader::AddLoadingStep(std::unique_ptr<ILoadingStep> step)
|
||||||
|
@ -36,7 +36,7 @@ namespace test::game::iw4::menu::parsing::it
|
|||||||
m_ignored_asset_lookup(),
|
m_ignored_asset_lookup(),
|
||||||
m_context(m_zone, &m_creator_collection, &m_ignored_asset_lookup)
|
m_context(m_zone, &m_creator_collection, &m_ignored_asset_lookup)
|
||||||
{
|
{
|
||||||
m_asset_creator = CreateMenuListLoader(*m_zone.GetMemory(), m_search_path);
|
m_asset_creator = CreateMenuListLoader(m_zone.Memory(), m_search_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFile(std::string fileName, std::string data)
|
void AddFile(std::string fileName, std::string data)
|
||||||
@ -51,8 +51,8 @@ namespace test::game::iw4::menu::parsing::it
|
|||||||
|
|
||||||
Material* AddMaterial(const std::string& name)
|
Material* AddMaterial(const std::string& name)
|
||||||
{
|
{
|
||||||
auto* material = m_zone.GetMemory()->Alloc<Material>();
|
auto* material = m_zone.Memory().Alloc<Material>();
|
||||||
material->info.name = m_zone.GetMemory()->Dup(name.c_str());
|
material->info.name = m_zone.Memory().Dup(name.c_str());
|
||||||
|
|
||||||
m_context.AddAsset<AssetMaterial>(name, material);
|
m_context.AddAsset<AssetMaterial>(name, material);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user