Skip to content

Commit

Permalink
VG MTL
Browse files Browse the repository at this point in the history
  • Loading branch information
Scobalula committed Feb 14, 2022
1 parent 75ecfb9 commit b6f0e54
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 30 deletions.
3 changes: 3 additions & 0 deletions src/WraithXCOD/WraithXCOD/CoDAssets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,9 @@ ExportGameResult CoDAssets::ExportMaterialAsset(const CoDMaterial_t* Material, c
case SupportedGames::BlackOpsCW:
XMaterial = GameBlackOpsCW::ReadXMaterial(Material->AssetPointer);
break;
case SupportedGames::Vanguard:
XMaterial = GameVanguard::ReadXMaterial(Material->AssetPointer);
break;
}

// Process Image Names
Expand Down
60 changes: 57 additions & 3 deletions src/WraithXCOD/WraithXCOD/GameModernWarfare4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ bool GameModernWarfare4::LoadOffsets()
auto StringPoolSize = DBReader.Read<uint64_t>();

// Apply game offset info
CoDAssets::GameOffsetInfos.emplace_back(CoDAssets::GameInstance->Read<CeleriumXAssetPool>(XAssetPools + sizeof(CeleriumXAssetPool) * 19).FirstXAsset);
CoDAssets::GameOffsetInfos.emplace_back(StringPool);
CoDAssets::GameOffsetInfos.emplace_back(CoDAssets::GameInstance->Read<CeleriumXAssetPool>(XAssetPools + sizeof(CeleriumXAssetPool) * 9).FirstXAsset);
CoDAssets::GameOffsetInfos.emplace_back(CoDAssets::GameInstance->Read<CeleriumXAssetPool>(XAssetPools + sizeof(CeleriumXAssetPool) * 7).FirstXAsset);
CoDAssets::GameOffsetInfos.emplace_back(CoDAssets::GameInstance->Read<CeleriumXAssetPool>(XAssetPools + sizeof(CeleriumXAssetPool) * 19).FirstXAsset);

// Celerium doesn't use pool sizes
CoDAssets::GamePoolSizes.emplace_back(0);
Expand Down Expand Up @@ -219,10 +221,36 @@ bool GameModernWarfare4::LoadAssets()
bool NeedsRawFiles = (SettingsManager::GetSetting("showxrawfiles", "false") == "true");
bool NeedsMaterials = (SettingsManager::GetSetting("showxmtl", "false") == "true");

if (NeedsModels)
{
CeleriumPoolParser(CoDAssets::GameOffsetInfos[1], [](CeleriumXAsset& Asset)
{
// Read
auto ModelResult = CoDAssets::GameInstance->Read<MW4XModel>(Asset.Header);
// Validate and load if need be
auto ModelName = FileSystems::GetFileName(CoDAssets::GameInstance->ReadNullTerminatedString(ModelResult.NamePtr));
// Make and add
auto LoadedModel = new CoDModel_t();
// Set
LoadedModel->AssetName = ModelName;
LoadedModel->AssetPointer = Asset.Header;
// Bone counts (check counts, since there's some weird models that we don't want, they have thousands of bones with no info)
if ((ModelResult.NumBones + ModelResult.UnkBoneCount) > 1 && ModelResult.ParentListPtr == 0)
LoadedModel->BoneCount = 0;
else
LoadedModel->BoneCount = ModelResult.NumBones + ModelResult.UnkBoneCount;
LoadedModel->LodCount = ModelResult.NumLods;
LoadedModel->AssetStatus = Asset.Temp == 1 ? WraithAssetStatus::Placeholder : WraithAssetStatus::Loaded;
// Log it
CoDAssets::LogXAsset("Model", ModelName);
// Add
CoDAssets::GameAssets->LoadedAssets.push_back(LoadedModel);
});
}

if (NeedsImages)
{
CeleriumPoolParser(CoDAssets::GameOffsetInfos[0], [](CeleriumXAsset& Asset)
CeleriumPoolParser(CoDAssets::GameOffsetInfos[3], [](CeleriumXAsset& Asset)
{
// Read
auto ImageResult = CoDAssets::GameInstance->Read<MW4GfxImage>(Asset.Header);
Expand All @@ -249,6 +277,32 @@ bool GameModernWarfare4::LoadAssets()
});
}

if (NeedsAnims)
{
CeleriumPoolParser(CoDAssets::GameOffsetInfos[2], [](CeleriumXAsset& Asset)
{
// Read
auto AnimResult = CoDAssets::GameInstance->Read<MW4XAnim>(Asset.Header);
// Validate and load if need be
auto AnimName = CoDAssets::GameInstance->ReadNullTerminatedString(AnimResult.NamePtr);

// Log it
CoDAssets::LogXAsset("Anim", AnimName);

// Make and add
auto LoadedAnim = new CoDAnim_t();
// Set
LoadedAnim->AssetName = AnimName;
LoadedAnim->AssetPointer = Asset.Header;
LoadedAnim->Framerate = AnimResult.Framerate;
LoadedAnim->FrameCount = AnimResult.NumFrames;
LoadedAnim->AssetStatus = Asset.Temp == 1 ? WraithAssetStatus::Placeholder : WraithAssetStatus::Loaded;
LoadedAnim->BoneCount = AnimResult.TotalBoneCount;
// Add
CoDAssets::GameAssets->LoadedAssets.push_back(LoadedAnim);
});
}

return true;

// Check if we need assets
Expand Down Expand Up @@ -1330,7 +1384,7 @@ void GameModernWarfare4::LoadXModel(const XModelLod_t& ModelLOD, const std::uniq

std::string GameModernWarfare4::LoadStringEntry(uint64_t Index)
{
auto PtrToString = CoDAssets::GameInstance->Read<uint64_t>(CoDAssets::GameOffsetInfos[1] + Index * sizeof(uint64_t));
auto PtrToString = CoDAssets::GameInstance->Read<uint64_t>(CoDAssets::GameOffsetInfos[0] + Index * sizeof(uint64_t));
// Read and return (Offsets[3] = StringTable)
return CoDAssets::GameInstance->ReadNullTerminatedString(PtrToString);
}
Expand Down
47 changes: 24 additions & 23 deletions src/WraithXCOD/WraithXCOD/GameVanguard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,29 +679,29 @@ bool GameVanguard::LoadAssets()
});
}

//if (NeedsMaterials)
//{
// // Parse the Rawfile pool
// CoDXPoolParser<uint64_t, VGXMaterial>(CoDAssets::GameOffsetInfos[5], CoDAssets::GamePoolSizes[5], [](VGXMaterial& Asset, uint64_t& AssetOffset)
// {
// // Validate and load if need be
// auto MaterialName = CoDAssets::GameInstance->ReadNullTerminatedString(Asset.NamePtr);

// // Log it
// CoDAssets::LogXAsset("Material", MaterialName);

// // Make and add
// auto LoadedMaterial = new CoDMaterial_t();
// // Set
// LoadedMaterial->AssetName = FileSystems::GetFileName(MaterialName);
// LoadedMaterial->AssetPointer = AssetOffset;
// LoadedMaterial->ImageCount = Asset.ImageCount;
// LoadedMaterial->AssetStatus = WraithAssetStatus::Loaded;

// // Add
// CoDAssets::GameAssets->LoadedAssets.push_back(LoadedMaterial);
// });
//}
if (NeedsMaterials)
{
// Parse the Rawfile pool
CoDXPoolParser<uint64_t, VGXMaterial>(CoDAssets::GameOffsetInfos[5], CoDAssets::GamePoolSizes[5], [](VGXMaterial& Asset, uint64_t& AssetOffset)
{
// Validate and load if need be
auto MaterialName = CoDAssets::GameInstance->ReadNullTerminatedString(Asset.NamePtr);

// Log it
CoDAssets::LogXAsset("Material", MaterialName);

// Make and add
auto LoadedMaterial = new CoDMaterial_t();
// Set
LoadedMaterial->AssetName = FileSystems::GetFileName(Strings::Replace(MaterialName, "*", ""));
LoadedMaterial->AssetPointer = AssetOffset;
LoadedMaterial->ImageCount = Asset.ImageCount;
LoadedMaterial->AssetStatus = WraithAssetStatus::Loaded;

// Add
CoDAssets::GameAssets->LoadedAssets.push_back(LoadedMaterial);
});
}

// Success, error only on specific load
return true;
Expand Down Expand Up @@ -1052,6 +1052,7 @@ const XMaterial_t GameVanguard::ReadXMaterial(uint64_t MaterialPointer)
XMaterial_t Result(MaterialData.ImageCount);
// Clean the name, then apply it
Result.MaterialName = FileSystems::GetFileNameWithoutExtension(CoDAssets::GameInstance->ReadNullTerminatedString(MaterialData.NamePtr));
Result.MaterialName = Strings::Replace(Result.MaterialName, "*", "");

// Iterate over material images, assign proper references if available
for (uint32_t m = 0; m < MaterialData.ImageCount; m++)
Expand Down
8 changes: 4 additions & 4 deletions src/WraithXCOD/WraithXCOD/WraithXCOD.rc
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ IDI_CHECKMARK ICON "..\\..\\WraithX\\Resources\\Che
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,9,5,0
PRODUCTVERSION 1,9,5,0
FILEVERSION 1,9,6,0
PRODUCTVERSION 1,9,6,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -386,12 +386,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "DTZxPorter / Scobalula"
VALUE "FileDescription", "Greyhound"
VALUE "FileVersion", "1.9.5.0"
VALUE "FileVersion", "1.9.6.0"
VALUE "InternalName", "Greyhound"
VALUE "LegalCopyright", "Copyright (C) 2021 DTZxPorter / Scobalula"
VALUE "OriginalFilename", "Greyhound.exe"
VALUE "ProductName", "Greyhound"
VALUE "ProductVersion", "1.9.5.0"
VALUE "ProductVersion", "1.9.6.0"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit b6f0e54

Please sign in to comment.