mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-12 07:48:16 -05:00
Reformat code with clang format
This commit is contained in:
@ -1,14 +1,14 @@
|
||||
#include "AssetLoaderFontIcon.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
#include "Csv/CsvStream.h"
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
void* AssetLoaderFontIcon::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
@ -48,10 +48,12 @@ void AssetLoaderFontIcon::PreprocessRow(std::vector<std::string>& row)
|
||||
|
||||
bool AssetLoaderFontIcon::RowIsEmpty(const std::vector<std::string>& row)
|
||||
{
|
||||
return std::all_of(row.begin(), row.end(), [](const std::string& cell)
|
||||
{
|
||||
return cell.empty();
|
||||
});
|
||||
return std::all_of(row.begin(),
|
||||
row.end(),
|
||||
[](const std::string& cell)
|
||||
{
|
||||
return cell.empty();
|
||||
});
|
||||
}
|
||||
|
||||
bool AssetLoaderFontIcon::ParseInt(int& value, const std::string& str)
|
||||
@ -90,8 +92,13 @@ bool AssetLoaderFontIcon::ParseHashStr(int& value, const std::string& str)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderFontIcon::ReadIconRow(const std::vector<std::string>& row, FontIconEntry& icon, const std::string& assetName, const unsigned rowIndex, MemoryManager* memory,
|
||||
IAssetLoadingManager* manager, std::vector<XAssetInfoGeneric*>& dependencies)
|
||||
bool AssetLoaderFontIcon::ReadIconRow(const std::vector<std::string>& row,
|
||||
FontIconEntry& icon,
|
||||
const std::string& assetName,
|
||||
const unsigned rowIndex,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
std::vector<XAssetInfoGeneric*>& dependencies)
|
||||
{
|
||||
if (row.size() < COL_COUNT_ICON)
|
||||
{
|
||||
@ -105,8 +112,7 @@ bool AssetLoaderFontIcon::ReadIconRow(const std::vector<std::string>& row, FontI
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ParseFloat(icon.xScale, row[ROW_ICON_XSCALE])
|
||||
|| !ParseFloat(icon.yScale, row[ROW_ICON_YSCALE]))
|
||||
if (!ParseFloat(icon.xScale, row[ROW_ICON_XSCALE]) || !ParseFloat(icon.yScale, row[ROW_ICON_YSCALE]))
|
||||
{
|
||||
std::cout << ErrorPrefix(assetName, rowIndex) << "Failed to parse scale" << std::endl;
|
||||
return false;
|
||||
@ -126,7 +132,11 @@ bool AssetLoaderFontIcon::ReadIconRow(const std::vector<std::string>& row, FontI
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderFontIcon::ReadAliasRow(const std::vector<std::string>& row, FontIconAlias& alias, const std::string& assetName, const unsigned rowIndex, MemoryManager* memory,
|
||||
bool AssetLoaderFontIcon::ReadAliasRow(const std::vector<std::string>& row,
|
||||
FontIconAlias& alias,
|
||||
const std::string& assetName,
|
||||
const unsigned rowIndex,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager)
|
||||
{
|
||||
if (row.size() < COL_COUNT_ALIAS)
|
||||
@ -150,7 +160,8 @@ bool AssetLoaderFontIcon::ReadAliasRow(const std::vector<std::string>& row, Font
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderFontIcon::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderFontIcon::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
@ -254,7 +265,7 @@ bool AssetLoaderFontIcon::LoadFromRaw(const std::string& assetName, ISearchPath*
|
||||
}
|
||||
else
|
||||
fontIcon->fontIconAlias = nullptr;
|
||||
|
||||
|
||||
manager->AddAsset(ASSET_TYPE_FONTICON, assetName, fontIcon);
|
||||
|
||||
return true;
|
||||
|
@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetLoaderFontIcon final : public BasicAssetLoader<ASSET_TYPE_FONTICON, FontIcon>
|
||||
@ -40,13 +40,24 @@ namespace T6
|
||||
static bool ParseFloat(float& value, const std::string& str);
|
||||
static bool ParseHashStr(int& value, const std::string& str);
|
||||
|
||||
static bool ReadIconRow(const std::vector<std::string>& row, FontIconEntry& icon, const std::string& assetName, unsigned rowIndex, MemoryManager* memory, IAssetLoadingManager* manager,
|
||||
static bool ReadIconRow(const std::vector<std::string>& row,
|
||||
FontIconEntry& icon,
|
||||
const std::string& assetName,
|
||||
unsigned rowIndex,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
std::vector<XAssetInfoGeneric*>& dependencies);
|
||||
static bool ReadAliasRow(const std::vector<std::string>& row, FontIconAlias& alias, const std::string& assetName, unsigned rowIndex, MemoryManager* memory, IAssetLoadingManager* manager);
|
||||
static bool ReadAliasRow(const std::vector<std::string>& row,
|
||||
FontIconAlias& alias,
|
||||
const std::string& assetName,
|
||||
unsigned rowIndex,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager);
|
||||
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include "AssetLoaderGfxImage.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Image/IwiLoader.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <zlib.h>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
void* AssetLoaderGfxImage::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
@ -25,7 +25,8 @@ bool AssetLoaderGfxImage::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderGfxImage::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderGfxImage::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = "images/" + assetName + ".iwi";
|
||||
const auto file = searchPath->Open(fileName);
|
||||
@ -64,7 +65,7 @@ bool AssetLoaderGfxImage::LoadFromRaw(const std::string& assetName, ISearchPath*
|
||||
image->streamedParts[0].levelSize = static_cast<uint32_t>(fileSize);
|
||||
image->streamedParts[0].hash = dataHash & 0x1FFFFFFF;
|
||||
image->streamedPartCount = 1;
|
||||
|
||||
|
||||
manager->AddAsset(ASSET_TYPE_IMAGE, assetName, image);
|
||||
|
||||
return true;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace T6
|
||||
@ -11,6 +11,7 @@ namespace T6
|
||||
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 T6
|
||||
|
@ -1,11 +1,10 @@
|
||||
#include "AssetLoaderLocalizeEntry.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
#include "Localize/LocalizeCommon.h"
|
||||
#include "Parsing/LocalizeFile/LocalizeFileReader.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
XAssetInfoGeneric* AssetLoaderLocalizeEntry::LoadFromGlobalAssetPools(const std::string& assetName) const
|
||||
@ -23,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;
|
||||
{
|
||||
@ -39,7 +39,7 @@ bool AssetLoaderLocalizeEntry::LoadFromRaw(const std::string& assetName, ISearch
|
||||
LocalizeFileReader reader(*file.m_stream, assetName, zone->m_language);
|
||||
const auto localizeEntries = reader.ReadLocalizeFile();
|
||||
|
||||
for(const auto& entry : localizeEntries)
|
||||
for (const auto& entry : localizeEntries)
|
||||
{
|
||||
auto* localizeEntry = memory->Create<LocalizeEntry>();
|
||||
localizeEntry->name = memory->Dup(entry.m_key.c_str());
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace T6
|
||||
@ -12,6 +12,7 @@ namespace T6
|
||||
_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 T6
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "AssetLoaderPhysConstraints.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/InfoString/EnumStrings.h"
|
||||
#include "Game/T6/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/T6/InfoString/PhysConstraintsFields.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace T6
|
||||
@ -32,17 +32,22 @@ namespace T6
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringToPhysConstraintsConverter(const InfoString& infoString, PhysConstraints* physConstraints, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager,
|
||||
const cspField_t* fields, const size_t fieldCount)
|
||||
InfoStringToPhysConstraintsConverter(const InfoString& infoString,
|
||||
PhysConstraints* physConstraints,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverter(infoString, physConstraints, zoneScriptStrings, memory, manager, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
||||
void AssetLoaderPhysConstraints::CalculatePhysConstraintsFields(PhysConstraints* physConstraints, Zone* zone)
|
||||
{
|
||||
for(auto& constraint : physConstraints->data)
|
||||
for (auto& constraint : physConstraints->data)
|
||||
{
|
||||
constraint.targetname = zone->m_script_strings.AddOrGetScriptString("");
|
||||
constraint.target_ent1 = zone->m_script_strings.AddOrGetScriptString("");
|
||||
@ -71,12 +76,14 @@ void AssetLoaderPhysConstraints::CalculatePhysConstraintsFields(PhysConstraints*
|
||||
}
|
||||
}
|
||||
|
||||
bool AssetLoaderPhysConstraints::LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
bool AssetLoaderPhysConstraints::LoadFromInfoString(
|
||||
const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
{
|
||||
auto* physConstraints = memory->Create<PhysConstraints>();
|
||||
memset(physConstraints, 0, sizeof(PhysConstraints));
|
||||
|
||||
InfoStringToPhysConstraintsConverter converter(infoString, physConstraints, zone->m_script_strings, memory, manager, phys_constraints_fields, std::extent<decltype(phys_constraints_fields)>::value);
|
||||
InfoStringToPhysConstraintsConverter converter(
|
||||
infoString, physConstraints, zone->m_script_strings, memory, manager, phys_constraints_fields, std::extent<decltype(phys_constraints_fields)>::value);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse phys constraints: \"" << assetName << "\"" << std::endl;
|
||||
@ -106,7 +113,8 @@ bool AssetLoaderPhysConstraints::CanLoadFromGdt() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderPhysConstraints::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderPhysConstraints::LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_PHYS_CONSTRAINTS, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
@ -127,7 +135,8 @@ bool AssetLoaderPhysConstraints::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderPhysConstraints::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderPhysConstraints::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = "physconstraints/" + assetName;
|
||||
const auto file = searchPath->Open(fileName);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
@ -11,13 +11,16 @@ namespace T6
|
||||
{
|
||||
static void CalculatePhysConstraintsFields(PhysConstraints* physConstraints, Zone* zone);
|
||||
|
||||
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 T6
|
||||
|
@ -1,17 +1,17 @@
|
||||
#include "AssetLoaderPhysPreset.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/T6/InfoString/PhysPresetFields.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace T6
|
||||
@ -26,13 +26,18 @@ namespace T6
|
||||
}
|
||||
|
||||
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 T6
|
||||
|
||||
void AssetLoaderPhysPreset::CopyFromPhysPresetInfo(const PhysPresetInfo* physPresetInfo, PhysPreset* physPreset)
|
||||
{
|
||||
@ -55,11 +60,13 @@ void AssetLoaderPhysPreset::CopyFromPhysPresetInfo(const PhysPresetInfo* physPre
|
||||
physPreset->buoyancyBoxMax = physPresetInfo->buoyancyBoxMax;
|
||||
}
|
||||
|
||||
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;
|
||||
@ -89,7 +96,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)
|
||||
@ -110,7 +118,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);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
@ -11,13 +11,16 @@ namespace T6
|
||||
{
|
||||
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 T6
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "AssetLoaderQdb.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
void* AssetLoaderQdb::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace T6
|
||||
@ -11,6 +11,7 @@ namespace T6
|
||||
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 T6
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "AssetLoaderRawFile.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
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())
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace T6
|
||||
@ -11,6 +11,7 @@ namespace T6
|
||||
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 T6
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "AssetLoaderScriptParseTree.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
void* AssetLoaderScriptParseTree::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
@ -20,7 +20,8 @@ bool AssetLoaderScriptParseTree::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderScriptParseTree::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderScriptParseTree::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace T6
|
||||
@ -11,6 +11,7 @@ namespace T6
|
||||
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 T6
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "AssetLoaderSlug.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
void* AssetLoaderSlug::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace T6
|
||||
@ -11,6 +11,7 @@ namespace T6
|
||||
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 T6
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "AssetLoaderStringTable.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Csv/CsvStream.h"
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
void* AssetLoaderStringTable::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
@ -22,7 +22,8 @@ bool AssetLoaderStringTable::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderStringTable::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderStringTable::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
@ -71,13 +72,15 @@ bool AssetLoaderStringTable::LoadFromRaw(const std::string& assetName, ISearchPa
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(&stringTable->cellIndex[0], &stringTable->cellIndex[cellCount - 1], [stringTable, maxCols](const int16_t a, const int16_t b)
|
||||
{
|
||||
auto compareResult = stringTable->values[a].hash - stringTable->values[b].hash;
|
||||
if (compareResult == 0)
|
||||
compareResult = a % maxCols - b % maxCols;
|
||||
return compareResult < 0;
|
||||
});
|
||||
std::sort(&stringTable->cellIndex[0],
|
||||
&stringTable->cellIndex[cellCount - 1],
|
||||
[stringTable, maxCols](const int16_t a, const int16_t b)
|
||||
{
|
||||
auto compareResult = stringTable->values[a].hash - stringTable->values[b].hash;
|
||||
if (compareResult == 0)
|
||||
compareResult = a % maxCols - b % maxCols;
|
||||
return compareResult < 0;
|
||||
});
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace T6
|
||||
@ -11,6 +11,7 @@ namespace T6
|
||||
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 T6
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "AssetLoaderTracer.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/InfoString/EnumStrings.h"
|
||||
#include "Game/T6/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/T6/InfoString/TracerFields.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace T6
|
||||
@ -33,20 +33,27 @@ namespace T6
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringToTracerConverter(const InfoString& infoString, TracerDef* tracer, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager,
|
||||
const cspField_t* fields, const size_t fieldCount)
|
||||
InfoStringToTracerConverter(const InfoString& infoString,
|
||||
TracerDef* tracer,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverter(infoString, tracer, zoneScriptStrings, memory, manager, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
||||
bool AssetLoaderTracer::LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
bool AssetLoaderTracer::LoadFromInfoString(
|
||||
const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
{
|
||||
auto* tracer = memory->Create<TracerDef>();
|
||||
memset(tracer, 0, sizeof(TracerDef));
|
||||
|
||||
InfoStringToTracerConverter converter(infoString, tracer, zone->m_script_strings, memory, manager, tracer_fields, std::extent<decltype(tracer_fields)>::value);
|
||||
InfoStringToTracerConverter converter(
|
||||
infoString, tracer, zone->m_script_strings, memory, manager, tracer_fields, std::extent<decltype(tracer_fields)>::value);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse tracer: \"" << assetName << "\"" << std::endl;
|
||||
@ -73,7 +80,8 @@ bool AssetLoaderTracer::CanLoadFromGdt() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderTracer::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderTracer::LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_TRACER, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
@ -94,7 +102,8 @@ bool AssetLoaderTracer::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderTracer::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderTracer::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = "tracer/" + assetName;
|
||||
const auto file = searchPath->Open(fileName);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
@ -9,13 +9,16 @@ namespace T6
|
||||
{
|
||||
class AssetLoaderTracer final : public BasicAssetLoader<ASSET_TYPE_TRACER, TracerDef>
|
||||
{
|
||||
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 T6
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "AssetLoaderVehicle.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/InfoString/EnumStrings.h"
|
||||
#include "Game/T6/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/T6/InfoString/VehicleFields.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace T6
|
||||
@ -32,58 +32,58 @@ namespace T6
|
||||
return ConvertEnumInt(value, field.iOffset, s_tractionTypeNames, std::extent<decltype(s_tractionTypeNames)>::value);
|
||||
|
||||
case VFT_MPH_TO_INCHES_PER_SECOND:
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
case VFT_POUNDS_TO_GAME_MASS:
|
||||
{
|
||||
char* endPtr;
|
||||
*reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = strtof(value.c_str(), &endPtr) * 0.001f;
|
||||
|
||||
if (endPtr != &value[value.size()])
|
||||
{
|
||||
std::cout << "Failed to parse value \"" << value << "\" as pounds" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case VFT_TEAM:
|
||||
{
|
||||
if (value == "axis")
|
||||
{
|
||||
*reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = TEAM_AXIS;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value == "allies")
|
||||
{
|
||||
*reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = TEAM_ALLIES;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value == "neutral")
|
||||
{
|
||||
*reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = TEAM_FOUR;
|
||||
return true;
|
||||
}
|
||||
|
||||
*reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = TEAM_BAD;
|
||||
std::cout << "Failed to parse value \"" << value << "\" as team" << std::endl;
|
||||
std::cout << "Failed to parse value \"" << value << "\" as mph" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case VFT_POUNDS_TO_GAME_MASS:
|
||||
{
|
||||
char* endPtr;
|
||||
*reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = strtof(value.c_str(), &endPtr) * 0.001f;
|
||||
|
||||
if (endPtr != &value[value.size()])
|
||||
{
|
||||
std::cout << "Failed to parse value \"" << value << "\" as pounds" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case VFT_TEAM:
|
||||
{
|
||||
if (value == "axis")
|
||||
{
|
||||
*reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = TEAM_AXIS;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value == "allies")
|
||||
{
|
||||
*reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = TEAM_ALLIES;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value == "neutral")
|
||||
{
|
||||
*reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = TEAM_FOUR;
|
||||
return true;
|
||||
}
|
||||
|
||||
*reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = TEAM_BAD;
|
||||
std::cout << "Failed to parse value \"" << value << "\" as team" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
case VFT_KEY_BINDING:
|
||||
case VFT_GRAPH:
|
||||
case VFT_WIIUCONTROLOVERRIDE:
|
||||
@ -95,20 +95,27 @@ namespace T6
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringToVehicleConverter(const InfoString& infoString, VehicleDef* vehicleDef, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager,
|
||||
const cspField_t* fields, const size_t fieldCount)
|
||||
InfoStringToVehicleConverter(const InfoString& infoString,
|
||||
VehicleDef* vehicleDef,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverter(infoString, vehicleDef, zoneScriptStrings, memory, manager, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
||||
bool AssetLoaderVehicle::LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
bool AssetLoaderVehicle::LoadFromInfoString(
|
||||
const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
{
|
||||
auto* vehicleDef = memory->Create<VehicleDef>();
|
||||
memset(vehicleDef, 0, sizeof(VehicleDef));
|
||||
|
||||
InfoStringToVehicleConverter converter(infoString, vehicleDef, zone->m_script_strings, memory, manager, vehicle_fields, std::extent<decltype(vehicle_fields)>::value);
|
||||
InfoStringToVehicleConverter converter(
|
||||
infoString, vehicleDef, zone->m_script_strings, memory, manager, vehicle_fields, std::extent<decltype(vehicle_fields)>::value);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse vehicle: \"" << assetName << "\"" << std::endl;
|
||||
@ -135,7 +142,8 @@ bool AssetLoaderVehicle::CanLoadFromGdt() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderVehicle::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderVehicle::LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_VEHICLE, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
@ -156,7 +164,8 @@ bool AssetLoaderVehicle::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderVehicle::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderVehicle::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = "vehicles/" + assetName;
|
||||
const auto file = searchPath->Open(fileName);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
@ -9,13 +9,16 @@ namespace T6
|
||||
{
|
||||
class AssetLoaderVehicle final : public BasicAssetLoader<ASSET_TYPE_VEHICLEDEF, VehicleDef>
|
||||
{
|
||||
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 T6
|
||||
|
@ -1,18 +1,17 @@
|
||||
#include "AssetLoaderWeapon.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
#include "AssetLoaderWeaponAttachmentUnique.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/InfoString/EnumStrings.h"
|
||||
#include "Game/T6/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/T6/InfoString/WeaponFields.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
@ -88,7 +87,8 @@ namespace T6
|
||||
|
||||
if (pairs.size() > std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value)
|
||||
{
|
||||
std::cout << "Cannot have more than " << std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value << " notetracksoundmap entries!" << std::endl;
|
||||
std::cout << "Cannot have more than " << std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value << " notetracksoundmap entries!"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -166,15 +166,15 @@ namespace T6
|
||||
|
||||
if (static_cast<unsigned>(attachmentAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT)
|
||||
{
|
||||
std::cout << "Invalid attachment type " << attachmentAsset->attachmentType << " for attachment asset \"" << attachmentName << "\"" << std::endl;
|
||||
std::cout << "Invalid attachment type " << attachmentAsset->attachmentType << " for attachment asset \"" << attachmentName << "\""
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (attachments[attachmentAsset->attachmentType] != nullptr)
|
||||
{
|
||||
std::cout << "Already loaded attachment with same type " << attachmentAsset->attachmentType
|
||||
<< ": \"" << attachments[attachmentAsset->attachmentType]->szInternalName << "\", \""
|
||||
<< attachmentName << "\"" << std::endl;
|
||||
std::cout << "Already loaded attachment with same type " << attachmentAsset->attachmentType << ": \""
|
||||
<< attachments[attachmentAsset->attachmentType]->szInternalName << "\", \"" << attachmentName << "\"" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -219,8 +219,8 @@ namespace T6
|
||||
if (attachmentCombinationIndex >= std::extent<decltype(WeaponFullDef::attachmentUniques)>::value)
|
||||
{
|
||||
std::cout << "Cannot have more than "
|
||||
<< (std::extent<decltype(WeaponFullDef::attachmentUniques)>::value - std::extent<decltype(WeaponFullDef::attachments)>::value)
|
||||
<< " combined attachment attachment unique entries!" << std::endl;
|
||||
<< (std::extent<decltype(WeaponFullDef::attachmentUniques)>::value - std::extent<decltype(WeaponFullDef::attachments)>::value)
|
||||
<< " combined attachment attachment unique entries!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -231,15 +231,16 @@ namespace T6
|
||||
{
|
||||
if (static_cast<unsigned>(attachmentUniqueAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT)
|
||||
{
|
||||
std::cout << "Invalid attachment type " << attachmentUniqueAsset->attachmentType << " for attachment unique asset \"" << attachmentUniqueName << "\"" << std::endl;
|
||||
std::cout << "Invalid attachment type " << attachmentUniqueAsset->attachmentType << " for attachment unique asset \""
|
||||
<< attachmentUniqueName << "\"" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (attachmentUniques[attachmentUniqueAsset->attachmentType] != nullptr)
|
||||
{
|
||||
std::cout << "Already loaded attachment unique with same type " << attachmentUniqueAsset->attachmentType
|
||||
<< ": \"" << attachmentUniques[attachmentUniqueAsset->attachmentType]->szInternalName << "\", \""
|
||||
<< attachmentUniqueName << "\"" << std::endl;
|
||||
std::cout << "Already loaded attachment unique with same type " << attachmentUniqueAsset->attachmentType << ": \""
|
||||
<< attachmentUniques[attachmentUniqueAsset->attachmentType]->szInternalName << "\", \"" << attachmentUniqueName << "\""
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -352,13 +353,18 @@ namespace T6
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringToWeaponConverter(const InfoString& infoString, WeaponFullDef* weaponFullDef, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager,
|
||||
const cspField_t* fields, const size_t fieldCount)
|
||||
InfoStringToWeaponConverter(const InfoString& infoString,
|
||||
WeaponFullDef* weaponFullDef,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverter(infoString, weaponFullDef, zoneScriptStrings, memory, manager, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
||||
void AssetLoaderWeapon::LinkWeaponFullDefSubStructs(WeaponFullDef* weapon)
|
||||
{
|
||||
@ -423,13 +429,19 @@ bool AssetLoaderWeapon::IsFxOverride(FxEffectDef* effect1, FxEffectDef* effect2)
|
||||
return strcmp(effect1->name, effect2->name) != 0;
|
||||
}
|
||||
|
||||
void AssetLoaderWeapon::HandleSoundOverride(WeaponAttachmentUnique* attachmentUnique, const char* snd1, const char* snd2, const eAttachmentOverrideSounds sndOverrideIndex)
|
||||
void AssetLoaderWeapon::HandleSoundOverride(WeaponAttachmentUnique* attachmentUnique,
|
||||
const char* snd1,
|
||||
const char* snd2,
|
||||
const eAttachmentOverrideSounds sndOverrideIndex)
|
||||
{
|
||||
if (IsStringOverride(snd1, snd2))
|
||||
attachmentUnique->soundOverrides |= 1 << static_cast<unsigned>(sndOverrideIndex);
|
||||
}
|
||||
|
||||
void AssetLoaderWeapon::HandleFxOverride(WeaponAttachmentUnique* attachmentUnique, FxEffectDef* effect1, FxEffectDef* effect2, const eAttachmentOverrideEffects fxOverrideIndex)
|
||||
void AssetLoaderWeapon::HandleFxOverride(WeaponAttachmentUnique* attachmentUnique,
|
||||
FxEffectDef* effect1,
|
||||
FxEffectDef* effect2,
|
||||
const eAttachmentOverrideEffects fxOverrideIndex)
|
||||
{
|
||||
if (IsFxOverride(effect1, effect2))
|
||||
attachmentUnique->effectOverrides |= 1 << static_cast<unsigned>(fxOverrideIndex);
|
||||
@ -450,15 +462,20 @@ void AssetLoaderWeapon::CalculateAttachmentFields(WeaponFullDef* weapon, unsigne
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireSound, attachmentUnique->fireSound, ATTACHMENT_OVERRIDE_SOUND_FIRE);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireSoundPlayer, attachmentUnique->fireSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_PLAYER);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireLoopSound, attachmentUnique->fireLoopSound, ATTACHMENT_OVERRIDE_SOUND_FIRE_LOOP);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireLoopSoundPlayer, attachmentUnique->fireLoopSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_LOOP_PLAYER);
|
||||
HandleSoundOverride(
|
||||
attachmentUnique, weapon->weapDef.fireLoopSoundPlayer, attachmentUnique->fireLoopSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_LOOP_PLAYER);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireLoopEndSound, attachmentUnique->fireLoopEndSound, ATTACHMENT_OVERRIDE_SOUND_FIRE_LOOP_END);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireLoopEndSoundPlayer, attachmentUnique->fireLoopEndSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_LOOP_END_PLAYER);
|
||||
HandleSoundOverride(
|
||||
attachmentUnique, weapon->weapDef.fireLoopEndSoundPlayer, attachmentUnique->fireLoopEndSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_LOOP_END_PLAYER);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireStartSound, attachmentUnique->fireStartSound, ATTACHMENT_OVERRIDE_SOUND_FIRE_START);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireStopSound, attachmentUnique->fireStopSound, ATTACHMENT_OVERRIDE_SOUND_FIRE_STOP);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireStartSoundPlayer, attachmentUnique->fireStartSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_START_PLAYER);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireStopSoundPlayer, attachmentUnique->fireStopSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_STOP_PLAYER);
|
||||
HandleSoundOverride(
|
||||
attachmentUnique, weapon->weapDef.fireStartSoundPlayer, attachmentUnique->fireStartSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_START_PLAYER);
|
||||
HandleSoundOverride(
|
||||
attachmentUnique, weapon->weapDef.fireStopSoundPlayer, attachmentUnique->fireStopSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_STOP_PLAYER);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireLastSound, attachmentUnique->fireLastSound, ATTACHMENT_OVERRIDE_SOUND_FIRE_LAST);
|
||||
HandleSoundOverride(attachmentUnique, weapon->weapDef.fireLastSoundPlayer, attachmentUnique->fireLastSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_LAST_PLAYER);
|
||||
HandleSoundOverride(
|
||||
attachmentUnique, weapon->weapDef.fireLastSoundPlayer, attachmentUnique->fireLastSoundPlayer, ATTACHMENT_OVERRIDE_SOUND_FIRE_LAST_PLAYER);
|
||||
|
||||
attachmentUnique->effectOverrides = 0;
|
||||
HandleFxOverride(attachmentUnique, weapon->weapDef.viewFlashEffect, attachmentUnique->viewFlashEffect, ATTACHMENT_OVERRIDE_EFFECT_VIEW_FLASH);
|
||||
@ -468,7 +485,8 @@ void AssetLoaderWeapon::CalculateAttachmentFields(WeaponFullDef* weapon, unsigne
|
||||
if (attachmentUnique->combinedAttachmentTypeMask == 0)
|
||||
{
|
||||
WeaponAttachmentUnique* lastSibling = nullptr;
|
||||
for (auto attachmentUniqueIndex = std::extent<decltype(WeaponFullDef::attachments)>::value; attachmentUniqueIndex < std::extent<decltype(WeaponFullDef::attachmentUniques)>::value;
|
||||
for (auto attachmentUniqueIndex = std::extent<decltype(WeaponFullDef::attachments)>::value;
|
||||
attachmentUniqueIndex < std::extent<decltype(WeaponFullDef::attachmentUniques)>::value;
|
||||
attachmentUniqueIndex++)
|
||||
{
|
||||
if (weapon->attachmentUniques[attachmentUniqueIndex] != nullptr
|
||||
@ -476,7 +494,8 @@ void AssetLoaderWeapon::CalculateAttachmentFields(WeaponFullDef* weapon, unsigne
|
||||
&& weapon->attachmentUniques[attachmentUniqueIndex]->attachmentType != attachmentUnique->attachmentType)
|
||||
{
|
||||
std::vector<eAttachment> attachments;
|
||||
if(AssetLoaderWeaponAttachmentUnique::ExtractAttachmentsFromAssetName(weapon->attachmentUniques[attachmentUniqueIndex]->szInternalName, attachments)
|
||||
if (AssetLoaderWeaponAttachmentUnique::ExtractAttachmentsFromAssetName(weapon->attachmentUniques[attachmentUniqueIndex]->szInternalName,
|
||||
attachments)
|
||||
&& attachments.front() == attachmentUnique->attachmentType)
|
||||
{
|
||||
if (lastSibling == nullptr)
|
||||
@ -506,13 +525,15 @@ void AssetLoaderWeapon::CalculateAttachmentFields(WeaponFullDef* weapon)
|
||||
}
|
||||
}
|
||||
|
||||
bool AssetLoaderWeapon::LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
bool AssetLoaderWeapon::LoadFromInfoString(
|
||||
const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
{
|
||||
auto* weaponFullDef = memory->Create<WeaponFullDef>();
|
||||
memset(weaponFullDef, 0, sizeof(WeaponFullDef));
|
||||
LinkWeaponFullDefSubStructs(weaponFullDef);
|
||||
|
||||
InfoStringToWeaponConverter converter(infoString, weaponFullDef, zone->m_script_strings, memory, manager, weapon_fields, std::extent<decltype(weapon_fields)>::value);
|
||||
InfoStringToWeaponConverter converter(
|
||||
infoString, weaponFullDef, zone->m_script_strings, memory, manager, weapon_fields, std::extent<decltype(weapon_fields)>::value);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse weapon: \"" << assetName << "\"" << std::endl;
|
||||
@ -545,14 +566,15 @@ bool AssetLoaderWeapon::CanLoadFromGdt() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderWeapon::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderWeapon::LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_WEAPON, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
return false;
|
||||
|
||||
InfoString infoString;
|
||||
if(!infoString.FromGdtProperties(*gdtEntry))
|
||||
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||
{
|
||||
std::cout << "Failed to read weapon gdt entry: \"" << assetName << "\"" << std::endl;
|
||||
return true;
|
||||
@ -566,7 +588,8 @@ bool AssetLoaderWeapon::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderWeapon::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderWeapon::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = "weapons/" + assetName;
|
||||
const auto file = searchPath->Open(fileName);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
@ -13,20 +13,25 @@ namespace T6
|
||||
|
||||
static bool IsStringOverride(const char* str1, const char* str2);
|
||||
static bool IsFxOverride(FxEffectDef* effect1, FxEffectDef* effect2);
|
||||
static void HandleSoundOverride(WeaponAttachmentUnique* attachmentUnique, const char* snd1, const char* snd2, eAttachmentOverrideSounds sndOverrideIndex);
|
||||
static void HandleFxOverride(WeaponAttachmentUnique* attachmentUnique, FxEffectDef* effect1, FxEffectDef* effect2, eAttachmentOverrideEffects fxOverrideIndex);
|
||||
static void
|
||||
HandleSoundOverride(WeaponAttachmentUnique* attachmentUnique, const char* snd1, const char* snd2, eAttachmentOverrideSounds sndOverrideIndex);
|
||||
static void
|
||||
HandleFxOverride(WeaponAttachmentUnique* attachmentUnique, FxEffectDef* effect1, FxEffectDef* effect2, eAttachmentOverrideEffects fxOverrideIndex);
|
||||
|
||||
static void CalculateWeaponFields(WeaponFullDef* weapon);
|
||||
static void CalculateAttachmentFields(WeaponFullDef* weapon, unsigned attachmentIndex, WeaponAttachmentUnique* attachmentUnique);
|
||||
static void CalculateAttachmentFields(WeaponFullDef* weapon);
|
||||
|
||||
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 T6
|
||||
|
@ -1,52 +1,51 @@
|
||||
#include "AssetLoaderWeaponAttachment.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/InfoString/EnumStrings.h"
|
||||
#include "Game/T6/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/T6/InfoString/WeaponAttachmentFields.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace T6
|
||||
{
|
||||
eAttachmentPoint attachmentPointByAttachmentTable[]
|
||||
{
|
||||
ATTACHMENT_POINT_NONE, // none
|
||||
ATTACHMENT_POINT_TOP, // acog
|
||||
ATTACHMENT_POINT_TRIGGER, // dualclip
|
||||
ATTACHMENT_POINT_TOP, // dualoptic
|
||||
ATTACHMENT_POINT_BOTTOM, // dw
|
||||
ATTACHMENT_POINT_MUZZLE, // extbarrel
|
||||
ATTACHMENT_POINT_TRIGGER, // extclip
|
||||
ATTACHMENT_POINT_TRIGGER, // extramags
|
||||
ATTACHMENT_POINT_GUNPERK, // fastads
|
||||
ATTACHMENT_POINT_TOP, // fastreload
|
||||
ATTACHMENT_POINT_TRIGGER, // fmj
|
||||
ATTACHMENT_POINT_BOTTOM, // gl
|
||||
ATTACHMENT_POINT_BOTTOM, // grip
|
||||
ATTACHMENT_POINT_TOP, // holo
|
||||
ATTACHMENT_POINT_BOTTOM, // ir
|
||||
ATTACHMENT_POINT_BOTTOM, // is
|
||||
ATTACHMENT_POINT_GUNPERK, // longbreath
|
||||
ATTACHMENT_POINT_BOTTOM, // mk
|
||||
ATTACHMENT_POINT_TOP, // mms
|
||||
ATTACHMENT_POINT_TOP, // rangefinder
|
||||
ATTACHMENT_POINT_TOP, // reflex
|
||||
ATTACHMENT_POINT_MUZZLE, // rf
|
||||
ATTACHMENT_POINT_BOTTOM, // sf
|
||||
ATTACHMENT_POINT_MUZZLE, // silencer
|
||||
ATTACHMENT_POINT_TRIGGER, // stackfire
|
||||
ATTACHMENT_POINT_GUNPERK, // stalker
|
||||
ATTACHMENT_POINT_GUNPERK, // steadyaim
|
||||
ATTACHMENT_POINT_GUNPERK, // swayreduc
|
||||
ATTACHMENT_POINT_TOP, // tacknife
|
||||
ATTACHMENT_POINT_TOP, // vzoom
|
||||
eAttachmentPoint attachmentPointByAttachmentTable[]{
|
||||
ATTACHMENT_POINT_NONE, // none
|
||||
ATTACHMENT_POINT_TOP, // acog
|
||||
ATTACHMENT_POINT_TRIGGER, // dualclip
|
||||
ATTACHMENT_POINT_TOP, // dualoptic
|
||||
ATTACHMENT_POINT_BOTTOM, // dw
|
||||
ATTACHMENT_POINT_MUZZLE, // extbarrel
|
||||
ATTACHMENT_POINT_TRIGGER, // extclip
|
||||
ATTACHMENT_POINT_TRIGGER, // extramags
|
||||
ATTACHMENT_POINT_GUNPERK, // fastads
|
||||
ATTACHMENT_POINT_TOP, // fastreload
|
||||
ATTACHMENT_POINT_TRIGGER, // fmj
|
||||
ATTACHMENT_POINT_BOTTOM, // gl
|
||||
ATTACHMENT_POINT_BOTTOM, // grip
|
||||
ATTACHMENT_POINT_TOP, // holo
|
||||
ATTACHMENT_POINT_BOTTOM, // ir
|
||||
ATTACHMENT_POINT_BOTTOM, // is
|
||||
ATTACHMENT_POINT_GUNPERK, // longbreath
|
||||
ATTACHMENT_POINT_BOTTOM, // mk
|
||||
ATTACHMENT_POINT_TOP, // mms
|
||||
ATTACHMENT_POINT_TOP, // rangefinder
|
||||
ATTACHMENT_POINT_TOP, // reflex
|
||||
ATTACHMENT_POINT_MUZZLE, // rf
|
||||
ATTACHMENT_POINT_BOTTOM, // sf
|
||||
ATTACHMENT_POINT_MUZZLE, // silencer
|
||||
ATTACHMENT_POINT_TRIGGER, // stackfire
|
||||
ATTACHMENT_POINT_GUNPERK, // stalker
|
||||
ATTACHMENT_POINT_GUNPERK, // steadyaim
|
||||
ATTACHMENT_POINT_GUNPERK, // swayreduc
|
||||
ATTACHMENT_POINT_TOP, // tacknife
|
||||
ATTACHMENT_POINT_TOP, // vzoom
|
||||
};
|
||||
|
||||
static_assert(std::extent<decltype(attachmentPointByAttachmentTable)>::value == ATTACHMENT_TYPE_COUNT);
|
||||
@ -74,29 +73,36 @@ namespace T6
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringToWeaponAttachmentConverter(const InfoString& infoString, WeaponAttachment* weaponAttachment, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager,
|
||||
const cspField_t* fields, const size_t fieldCount)
|
||||
InfoStringToWeaponAttachmentConverter(const InfoString& infoString,
|
||||
WeaponAttachment* weaponAttachment,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverter(infoString, weaponAttachment, zoneScriptStrings, memory, manager, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
||||
void AssetLoaderWeaponAttachment::CalculateAttachmentFields(WeaponAttachment* attachment)
|
||||
{
|
||||
// attachmentPoint
|
||||
if(static_cast<unsigned>(attachment->attachmentType) < ATTACHMENT_TYPE_COUNT)
|
||||
if (static_cast<unsigned>(attachment->attachmentType) < ATTACHMENT_TYPE_COUNT)
|
||||
{
|
||||
attachment->attachmentPoint = attachmentPointByAttachmentTable[attachment->attachmentType];
|
||||
}
|
||||
}
|
||||
|
||||
bool AssetLoaderWeaponAttachment::LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
bool AssetLoaderWeaponAttachment::LoadFromInfoString(
|
||||
const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
{
|
||||
auto* attachment = memory->Create<WeaponAttachment>();
|
||||
memset(attachment, 0, sizeof(WeaponAttachment));
|
||||
|
||||
InfoStringToWeaponAttachmentConverter converter(infoString, attachment, zone->m_script_strings, memory, manager, attachment_fields, std::extent<decltype(attachment_fields)>::value);
|
||||
InfoStringToWeaponAttachmentConverter converter(
|
||||
infoString, attachment, zone->m_script_strings, memory, manager, attachment_fields, std::extent<decltype(attachment_fields)>::value);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse attachment: \"" << assetName << "\"" << std::endl;
|
||||
@ -125,7 +131,8 @@ bool AssetLoaderWeaponAttachment::CanLoadFromGdt() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderWeaponAttachment::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderWeaponAttachment::LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_WEAPON_ATTACHMENT, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
@ -146,7 +153,8 @@ bool AssetLoaderWeaponAttachment::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderWeaponAttachment::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderWeaponAttachment::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = "attachment/" + assetName;
|
||||
const auto file = searchPath->Open(fileName);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
@ -11,13 +11,16 @@ namespace T6
|
||||
{
|
||||
static void CalculateAttachmentFields(WeaponAttachment* attachment);
|
||||
|
||||
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 T6
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "AssetLoaderWeaponAttachmentUnique.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/InfoString/EnumStrings.h"
|
||||
#include "Game/T6/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/T6/InfoString/WeaponAttachmentUniqueFields.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
@ -102,13 +102,18 @@ namespace T6
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringToWeaponAttachmentUniqueConverter(const InfoString& infoString, WeaponAttachmentUniqueFull* attachmentUniqueFull, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager,
|
||||
const cspField_t* fields, const size_t fieldCount)
|
||||
InfoStringToWeaponAttachmentUniqueConverter(const InfoString& infoString,
|
||||
WeaponAttachmentUniqueFull* attachmentUniqueFull,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverter(infoString, attachmentUniqueFull, zoneScriptStrings, memory, manager, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
||||
bool AssetLoaderWeaponAttachmentUnique::ExtractAttachmentsFromAssetName(const std::string& assetName, std::vector<eAttachment>& attachmentList)
|
||||
{
|
||||
@ -116,14 +121,14 @@ bool AssetLoaderWeaponAttachmentUnique::ExtractAttachmentsFromAssetName(const st
|
||||
|
||||
auto attachCount = 1u;
|
||||
auto partStart = 0u;
|
||||
for(auto ci = 0u; ci < assetName.size(); ci++)
|
||||
for (auto ci = 0u; ci < assetName.size(); ci++)
|
||||
{
|
||||
if(assetName[ci] == '_')
|
||||
if (assetName[ci] == '_')
|
||||
{
|
||||
parts.emplace_back(assetName, partStart, ci - partStart);
|
||||
partStart = ci + 1;
|
||||
}
|
||||
else if(assetName[ci] == '+')
|
||||
else if (assetName[ci] == '+')
|
||||
{
|
||||
attachCount++;
|
||||
parts.emplace_back(assetName, partStart, ci - partStart);
|
||||
@ -131,10 +136,10 @@ bool AssetLoaderWeaponAttachmentUnique::ExtractAttachmentsFromAssetName(const st
|
||||
}
|
||||
}
|
||||
|
||||
if(partStart < assetName.size())
|
||||
if (partStart < assetName.size())
|
||||
parts.emplace_back(assetName, partStart, assetName.size() - partStart);
|
||||
|
||||
for(auto attachPartOffset = parts.size() - attachCount; attachPartOffset < parts.size(); attachPartOffset++)
|
||||
for (auto attachPartOffset = parts.size() - attachCount; attachPartOffset < parts.size(); attachPartOffset++)
|
||||
{
|
||||
auto& specifiedAttachName = parts[attachPartOffset];
|
||||
|
||||
@ -142,9 +147,9 @@ bool AssetLoaderWeaponAttachmentUnique::ExtractAttachmentsFromAssetName(const st
|
||||
c = static_cast<char>(tolower(c));
|
||||
|
||||
auto foundAttachment = false;
|
||||
for(auto attachIndex = 0u; attachIndex < std::extent<decltype(szAttachmentTypeNames)>::value; attachIndex++)
|
||||
for (auto attachIndex = 0u; attachIndex < std::extent<decltype(szAttachmentTypeNames)>::value; attachIndex++)
|
||||
{
|
||||
if(specifiedAttachName == szAttachmentTypeNames[attachIndex])
|
||||
if (specifiedAttachName == szAttachmentTypeNames[attachIndex])
|
||||
{
|
||||
attachmentList.push_back(static_cast<eAttachment>(attachIndex));
|
||||
foundAttachment = true;
|
||||
@ -152,7 +157,7 @@ bool AssetLoaderWeaponAttachmentUnique::ExtractAttachmentsFromAssetName(const st
|
||||
}
|
||||
}
|
||||
|
||||
if(!foundAttachment)
|
||||
if (!foundAttachment)
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -170,7 +175,7 @@ bool AssetLoaderWeaponAttachmentUnique::CalculateAttachmentUniqueFields(const st
|
||||
{
|
||||
// combinedAttachmentTypeMask
|
||||
std::vector<eAttachment> attachmentsFromName;
|
||||
if(!ExtractAttachmentsFromAssetName(assetName, attachmentsFromName))
|
||||
if (!ExtractAttachmentsFromAssetName(assetName, attachmentsFromName))
|
||||
{
|
||||
std::cout << "Failed to determine attachments from attachment unique name \"" << assetName << "\"" << std::endl;
|
||||
return false;
|
||||
@ -178,7 +183,7 @@ bool AssetLoaderWeaponAttachmentUnique::CalculateAttachmentUniqueFields(const st
|
||||
|
||||
if (attachmentsFromName.size() > 1)
|
||||
{
|
||||
for(auto attachment : attachmentsFromName)
|
||||
for (auto attachment : attachmentsFromName)
|
||||
{
|
||||
attachmentUnique->attachment.combinedAttachmentTypeMask |= 1 << attachment;
|
||||
}
|
||||
@ -187,14 +192,21 @@ bool AssetLoaderWeaponAttachmentUnique::CalculateAttachmentUniqueFields(const st
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderWeaponAttachmentUnique::LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
bool AssetLoaderWeaponAttachmentUnique::LoadFromInfoString(
|
||||
const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
{
|
||||
|
||||
auto* attachmentUniqueFull = memory->Create<WeaponAttachmentUniqueFull>();
|
||||
memset(attachmentUniqueFull, 0, sizeof(WeaponAttachmentUniqueFull));
|
||||
LinkAttachmentUniqueFullSubStructs(attachmentUniqueFull);
|
||||
|
||||
InfoStringToWeaponAttachmentUniqueConverter converter(infoString, attachmentUniqueFull, zone->m_script_strings, memory, manager, attachment_unique_fields, std::extent<decltype(attachment_unique_fields)>::value);
|
||||
InfoStringToWeaponAttachmentUniqueConverter converter(infoString,
|
||||
attachmentUniqueFull,
|
||||
zone->m_script_strings,
|
||||
memory,
|
||||
manager,
|
||||
attachment_unique_fields,
|
||||
std::extent<decltype(attachment_unique_fields)>::value);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse attachment unique: \"" << assetName << "\"" << std::endl;
|
||||
@ -209,7 +221,8 @@ bool AssetLoaderWeaponAttachmentUnique::LoadFromInfoString(const InfoString& inf
|
||||
auto* assetInfo = GlobalAssetPool<WeaponAttachmentUnique>::GetAssetByName(assetName);
|
||||
auto* asset = assetInfo ? assetInfo->Asset() : nullptr;
|
||||
|
||||
manager->AddAsset(ASSET_TYPE_ATTACHMENT_UNIQUE, assetName, &attachmentUniqueFull->attachment, converter.GetDependencies(), converter.GetUsedScriptStrings());
|
||||
manager->AddAsset(
|
||||
ASSET_TYPE_ATTACHMENT_UNIQUE, assetName, &attachmentUniqueFull->attachment, converter.GetDependencies(), converter.GetUsedScriptStrings());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -229,7 +242,8 @@ bool AssetLoaderWeaponAttachmentUnique::CanLoadFromGdt() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderWeaponAttachmentUnique::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderWeaponAttachmentUnique::LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_WEAPON_ATTACHMENT_UNIQUE, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
@ -250,7 +264,8 @@ bool AssetLoaderWeaponAttachmentUnique::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderWeaponAttachmentUnique::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderWeaponAttachmentUnique::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = "attachmentunique/" + assetName;
|
||||
const auto file = searchPath->Open(fileName);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
@ -12,15 +12,18 @@ namespace T6
|
||||
static void LinkAttachmentUniqueFullSubStructs(WeaponAttachmentUniqueFull* attachmentUnique);
|
||||
static bool CalculateAttachmentUniqueFields(const std::string& assetName, WeaponAttachmentUniqueFull* attachmentUnique);
|
||||
|
||||
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:
|
||||
static bool ExtractAttachmentsFromAssetName(const std::string& assetName, std::vector<eAttachment>& attachmentList);
|
||||
|
||||
_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 T6
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include "AssetLoaderZBarrier.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/T6/InfoString/ZBarrierFields.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace T6
|
||||
@ -24,13 +24,18 @@ namespace T6
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringToZBarrierConverter(const InfoString& infoString, ZBarrierDef* zbarrier, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager,
|
||||
const cspField_t* fields, const size_t fieldCount)
|
||||
InfoStringToZBarrierConverter(const InfoString& infoString,
|
||||
ZBarrierDef* zbarrier,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverter(infoString, zbarrier, zoneScriptStrings, memory, manager, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
||||
void AssetLoaderZBarrier::CalculateZBarrierFields(ZBarrierDef* zbarrier)
|
||||
{
|
||||
@ -52,12 +57,14 @@ void AssetLoaderZBarrier::CalculateZBarrierFields(ZBarrierDef* zbarrier)
|
||||
}
|
||||
}
|
||||
|
||||
bool AssetLoaderZBarrier::LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
bool AssetLoaderZBarrier::LoadFromInfoString(
|
||||
const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
{
|
||||
auto* zbarrier = memory->Create<ZBarrierDef>();
|
||||
memset(zbarrier, 0, sizeof(ZBarrierDef));
|
||||
|
||||
InfoStringToZBarrierConverter converter(infoString, zbarrier, zone->m_script_strings, memory, manager, zbarrier_fields, std::extent<decltype(zbarrier_fields)>::value);
|
||||
InfoStringToZBarrierConverter converter(
|
||||
infoString, zbarrier, zone->m_script_strings, memory, manager, zbarrier_fields, std::extent<decltype(zbarrier_fields)>::value);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse zbarrier: \"" << assetName << "\"" << std::endl;
|
||||
@ -86,7 +93,8 @@ bool AssetLoaderZBarrier::CanLoadFromGdt() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderZBarrier::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderZBarrier::LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_ZBARRIER, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
@ -107,7 +115,8 @@ bool AssetLoaderZBarrier::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderZBarrier::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderZBarrier::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = "zbarrier/" + assetName;
|
||||
const auto file = searchPath->Open(fileName);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
@ -11,13 +11,16 @@ namespace T6
|
||||
{
|
||||
static void CalculateZBarrierFields(ZBarrierDef* zbarrier);
|
||||
|
||||
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 T6
|
||||
|
@ -1,14 +1,19 @@
|
||||
#include "InfoStringToStructConverter.h"
|
||||
|
||||
#include "Game/T6/CommonT6.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include "Game/T6/CommonT6.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
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),
|
||||
@ -64,132 +69,132 @@ 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:
|
||||
case CSPFT_MATERIAL_STREAM:
|
||||
{
|
||||
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_PHYS_PRESET:
|
||||
{
|
||||
if (value.empty())
|
||||
{
|
||||
if (value.empty())
|
||||
{
|
||||
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* physPreset = m_loading_manager->LoadDependency(ASSET_TYPE_PHYSPRESET, value);
|
||||
|
||||
if (physPreset == nullptr)
|
||||
{
|
||||
std::cout << "Failed to load physpreset asset \"" << value << "\"" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dependencies.emplace(physPreset);
|
||||
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = physPreset->m_ptr;
|
||||
|
||||
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* physPreset = m_loading_manager->LoadDependency(ASSET_TYPE_PHYSPRESET, value);
|
||||
|
||||
if (physPreset == nullptr)
|
||||
{
|
||||
std::cout << "Failed to load physpreset asset \"" << value << "\"" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dependencies.emplace(physPreset);
|
||||
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = physPreset->m_ptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case CSPFT_SCRIPT_STRING:
|
||||
return ConvertScriptString(value, field.iOffset);
|
||||
|
||||
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_SOUND_ALIAS_ID:
|
||||
{
|
||||
unsigned int soundAliasHash;
|
||||
if (!GetHashValue(value, soundAliasHash))
|
||||
{
|
||||
unsigned int soundAliasHash;
|
||||
if (!GetHashValue(value, soundAliasHash))
|
||||
{
|
||||
std::cout << "Failed to parse value \"" << value << "\" as hash" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
*reinterpret_cast<unsigned int*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = soundAliasHash;
|
||||
return true;
|
||||
std::cout << "Failed to parse value \"" << value << "\" as hash" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
*reinterpret_cast<unsigned int*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = soundAliasHash;
|
||||
return true;
|
||||
}
|
||||
|
||||
case CSPFT_NUM_BASE_FIELD_TYPES:
|
||||
default:
|
||||
assert(false);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "InfoString/InfoStringToStructConverterBase.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "InfoString/InfoStringToStructConverterBase.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
@ -18,8 +18,13 @@ namespace T6
|
||||
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,
|
||||
InfoStringToStructConverter(const InfoString& infoString,
|
||||
void* structure,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
const cspField_t* fields,
|
||||
size_t fieldCount);
|
||||
bool Convert() override;
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
@ -1,11 +1,5 @@
|
||||
#include "ObjLoaderT6.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "Game/T6/GameT6.h"
|
||||
#include "Game/T6/GameAssetPoolT6.h"
|
||||
#include "ObjContainer/IPak/IPak.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "AssetLoaders/AssetLoaderFontIcon.h"
|
||||
#include "AssetLoaders/AssetLoaderGfxImage.h"
|
||||
#include "AssetLoaders/AssetLoaderLocalizeEntry.h"
|
||||
@ -23,11 +17,17 @@
|
||||
#include "AssetLoaders/AssetLoaderWeaponAttachmentUnique.h"
|
||||
#include "AssetLoaders/AssetLoaderZBarrier.h"
|
||||
#include "AssetLoading/AssetLoadingManager.h"
|
||||
#include "Image/Texture.h"
|
||||
#include "Image/IwiLoader.h"
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/GameAssetPoolT6.h"
|
||||
#include "Game/T6/GameT6.h"
|
||||
#include "Image/Dx12TextureLoader.h"
|
||||
#include "Image/IwiLoader.h"
|
||||
#include "Image/IwiTypes.h"
|
||||
#include "Image/Texture.h"
|
||||
#include "ObjContainer/IPak/IPak.h"
|
||||
#include "ObjLoading.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
@ -36,7 +36,11 @@ namespace T6
|
||||
|
||||
ObjLoader::ObjLoader()
|
||||
{
|
||||
#define REGISTER_ASSET_LOADER(t) {auto l = std::make_unique<t>(); m_asset_loaders_by_type[l->GetHandlingAssetType()] = std::move(l);}
|
||||
#define REGISTER_ASSET_LOADER(t) \
|
||||
{ \
|
||||
auto l = std::make_unique<t>(); \
|
||||
m_asset_loaders_by_type[l->GetHandlingAssetType()] = std::move(l); \
|
||||
}
|
||||
#define BASIC_LOADER(assetType, assetClass) BasicAssetLoader<assetType, assetClass>
|
||||
|
||||
REGISTER_ASSET_LOADER(AssetLoaderPhysPreset)
|
||||
@ -146,8 +150,12 @@ namespace T6
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ObjLoader::LoadSoundBankFromLinkedInfo(ISearchPath* searchPath, const std::string& soundBankFileName, const SndRuntimeAssetBank* sndBankLinkedInfo, Zone* zone,
|
||||
std::set<std::string>& loadedBanksForZone, std::stack<std::string>& dependenciesToLoad)
|
||||
void ObjLoader::LoadSoundBankFromLinkedInfo(ISearchPath* searchPath,
|
||||
const std::string& soundBankFileName,
|
||||
const SndRuntimeAssetBank* sndBankLinkedInfo,
|
||||
Zone* zone,
|
||||
std::set<std::string>& loadedBanksForZone,
|
||||
std::stack<std::string>& dependenciesToLoad)
|
||||
{
|
||||
if (loadedBanksForZone.find(soundBankFileName) == loadedBanksForZone.end())
|
||||
{
|
||||
@ -245,14 +253,12 @@ namespace T6
|
||||
|
||||
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::LoadCommonIPaks(ISearchPath* searchPath, Zone* zone)
|
||||
@ -462,4 +468,4 @@ namespace T6
|
||||
for (const auto& [type, loader] : m_asset_loaders_by_type)
|
||||
loader->FinalizeAssetsForZone(context);
|
||||
}
|
||||
}
|
||||
} // namespace T6
|
||||
|
@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/IAssetLoader.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "IObjLoader.h"
|
||||
#include "ObjContainer/SoundBank/SoundBank.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <stack>
|
||||
|
||||
#include "IObjLoader.h"
|
||||
#include "AssetLoading/IAssetLoader.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "ObjContainer/SoundBank/SoundBank.h"
|
||||
#include <string>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
@ -23,8 +23,12 @@ namespace T6
|
||||
|
||||
static bool VerifySoundBankChecksum(const SoundBank* soundBank, const SndRuntimeAssetBank& sndRuntimeAssetBank);
|
||||
static SoundBank* LoadSoundBankForZone(ISearchPath* searchPath, const std::string& soundBankFileName, Zone* zone);
|
||||
static void LoadSoundBankFromLinkedInfo(ISearchPath* searchPath, const std::string& soundBankFileName, const SndRuntimeAssetBank* sndBankLinkedInfo, Zone* zone,
|
||||
std::set<std::string>& loadedBanksForZone, std::stack<std::string>& dependenciesToLoad);
|
||||
static void LoadSoundBankFromLinkedInfo(ISearchPath* searchPath,
|
||||
const std::string& soundBankFileName,
|
||||
const SndRuntimeAssetBank* sndBankLinkedInfo,
|
||||
Zone* zone,
|
||||
std::set<std::string>& loadedBanksForZone,
|
||||
std::stack<std::string>& dependenciesToLoad);
|
||||
static void LoadSoundBanksFromAsset(ISearchPath* searchPath, const SndBank* sndBank, Zone* zone, std::set<std::string>& loadedBanksForZone);
|
||||
|
||||
static void LoadIPakForZone(ISearchPath* searchPath, const std::string& ipakName, Zone* zone);
|
||||
@ -50,4 +54,4 @@ namespace T6
|
||||
bool LoadAssetForZone(AssetLoadingContext* context, asset_type_t assetType, const std::string& assetName) const override;
|
||||
void FinalizeAssetsForZone(AssetLoadingContext* context) const override;
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
Reference in New Issue
Block a user