From 6cca00b8d8daef495ba5c4251d84ce45640abaa2 Mon Sep 17 00:00:00 2001 From: Jan Date: Sat, 24 Oct 2020 13:46:37 +0200 Subject: [PATCH] Add dumping of t6 physpreset, tracer and zbarrier in their respective infostring files --- src/ObjCommon/Game/T6/InfoStringT6.cpp | 12 +- .../T6/AssetDumpers/AssetDumperPhysPreset.cpp | 126 ++++++++++ .../T6/AssetDumpers/AssetDumperPhysPreset.h | 19 ++ .../T6/AssetDumpers/AssetDumperTracer.cpp | 120 ++++++++++ .../Game/T6/AssetDumpers/AssetDumperTracer.h | 17 ++ .../Game/T6/AssetDumpers/AssetDumperVehicle.h | 3 - .../T6/AssetDumpers/AssetDumperZBarrier.cpp | 218 ++++++++++++++++++ .../T6/AssetDumpers/AssetDumperZBarrier.h | 17 ++ src/ObjWriting/Game/T6/ZoneDumperT6.cpp | 11 +- src/ZoneCommon/Game/T6/T6_Assets.h | 16 ++ 10 files changed, 547 insertions(+), 12 deletions(-) create mode 100644 src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp create mode 100644 src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.h create mode 100644 src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp create mode 100644 src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.h create mode 100644 src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp create mode 100644 src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.h diff --git a/src/ObjCommon/Game/T6/InfoStringT6.cpp b/src/ObjCommon/Game/T6/InfoStringT6.cpp index e8ac4961..97ae97df 100644 --- a/src/ObjCommon/Game/T6/InfoStringT6.cpp +++ b/src/ObjCommon/Game/T6/InfoStringT6.cpp @@ -113,8 +113,7 @@ void InfoStringFromStructConverter::FillFromBaseField(const cspField_t& field) case CSPFT_TRACER: { - const auto* tracer = *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset - ); + const auto* tracer = *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset); if (tracer) m_info_string.SetValueForKey(std::string(field.szName), std::string(tracer->name)); @@ -124,9 +123,12 @@ void InfoStringFromStructConverter::FillFromBaseField(const cspField_t& field) } case CSPFT_SOUND_ALIAS_ID: - assert(false); - FillFromUint(std::string(field.szName), field.iOffset); - break; + { + // TODO: Search sound files for files matching the hash + const auto* hash = reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset); + m_info_string.SetValueForKey(std::string(field.szName), "@" + std::to_string(*hash)); + break; + } case CSPFT_NUM_BASE_FIELD_TYPES: default: diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp new file mode 100644 index 00000000..1e2cae48 --- /dev/null +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp @@ -0,0 +1,126 @@ +#include "AssetDumperPhysPreset.h" + +#include +#include +#include + +#include "Game/T6/InfoStringT6.h" + +using namespace T6; + +cspField_t AssetDumperPhysPreset::physpreset_fields[] +{ + { "mass", offsetof(PhysPresetInfo, mass), CSPFT_FLOAT }, + { "bounce", offsetof(PhysPresetInfo, bounce), CSPFT_FLOAT }, + { "friction", offsetof(PhysPresetInfo, friction), CSPFT_FLOAT }, + { "isFrictionInfinity", offsetof(PhysPresetInfo, isFrictionInfinity), CSPFT_QBOOLEAN }, + { "bulletForceScale", offsetof(PhysPresetInfo, bulletForceScale), CSPFT_FLOAT }, + { "explosiveForceScale", offsetof(PhysPresetInfo, explosiveForceScale), CSPFT_FLOAT }, + { "piecesSpreadFraction", offsetof(PhysPresetInfo, piecesSpreadFraction), CSPFT_FLOAT }, + { "piecesUpwardVelocity", offsetof(PhysPresetInfo, piecesUpwardVelocity), CSPFT_FLOAT }, + { "canFloat", offsetof(PhysPresetInfo, canFloat), CSPFT_INT }, + { "gravityScale", offsetof(PhysPresetInfo, gravityScale), CSPFT_FLOAT }, + { "massOffsetX", offsetof(PhysPresetInfo, centerOfMassOffset.x), CSPFT_FLOAT }, + { "massOffsetY", offsetof(PhysPresetInfo, centerOfMassOffset.y), CSPFT_FLOAT }, + { "massOffsetZ", offsetof(PhysPresetInfo, centerOfMassOffset.z), CSPFT_FLOAT }, + { "buoyancyMinX", offsetof(PhysPresetInfo, buoyancyBoxMin.x), CSPFT_FLOAT }, + { "buoyancyMinY", offsetof(PhysPresetInfo, buoyancyBoxMin.y), CSPFT_FLOAT }, + { "buoyancyMinZ", offsetof(PhysPresetInfo, buoyancyBoxMin.z), CSPFT_FLOAT }, + { "buoyancyMaxX", offsetof(PhysPresetInfo, buoyancyBoxMax.x), CSPFT_FLOAT }, + { "buoyancyMaxY", offsetof(PhysPresetInfo, buoyancyBoxMax.y), CSPFT_FLOAT }, + { "buoyancyMaxZ", offsetof(PhysPresetInfo, buoyancyBoxMax.z), CSPFT_FLOAT }, +}; + +namespace T6 +{ + class InfoStringFromPhysPresetConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + assert(false); + } + + public: + InfoStringFromPhysPresetConverter(const PhysPresetInfo* structure, const cspField_t* fields, const size_t fieldCount, std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; +} + +void AssetDumperPhysPreset::CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo) +{ + physPresetInfo->mass = std::clamp(physPreset->mass * 1000.0f, 1.0f, 2000.0f); + physPresetInfo->bounce = physPreset->bounce; + + if(isinf(physPreset->friction)) + { + physPresetInfo->isFrictionInfinity = 1; + physPresetInfo->friction = 0; + } + else + { + physPresetInfo->isFrictionInfinity = 0; + physPresetInfo->friction = physPreset->friction; + } + + physPresetInfo->bulletForceScale = physPreset->bulletForceScale; + physPresetInfo->explosiveForceScale = physPreset->explosiveForceScale; + physPresetInfo->piecesSpreadFraction = physPreset->piecesSpreadFraction; + physPresetInfo->piecesUpwardVelocity = physPreset->piecesUpwardVelocity; + physPresetInfo->canFloat = physPreset->canFloat; + physPresetInfo->gravityScale = std::clamp(physPreset->gravityScale, 0.01f, 10.0f); + physPresetInfo->centerOfMassOffset = physPreset->centerOfMassOffset; + physPresetInfo->buoyancyBoxMin = physPreset->buoyancyBoxMin; + physPresetInfo->buoyancyBoxMax = physPreset->buoyancyBoxMax; +} + +bool AssetDumperPhysPreset::ShouldDump(XAssetInfo* asset) +{ + return true; +} + +std::string AssetDumperPhysPreset::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) +{ + return "physic/" + asset->m_name; +} + +void AssetDumperPhysPreset::DumpAsset(Zone* zone, XAssetInfo* asset, FileAPI::File* out) +{ + auto* physPresetInfo = new PhysPresetInfo; + CopyToPhysPresetInfo(asset->Asset(), physPresetInfo); + + InfoStringFromPhysPresetConverter converter(physPresetInfo, physpreset_fields, _countof(physpreset_fields), [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.size()); + if (scrStr >= asset->m_zone->m_script_strings.size()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + const auto infoString = converter.Convert(); + const auto stringValue = infoString.ToString("PHYSIC"); + out->Write(stringValue.c_str(), 1, stringValue.length()); + + delete physPresetInfo; +} + +//void AssetDumperPhysPreset::CheckFields() +//{ +// assert(_countof(physpreset_fields) == _countof(fields222)); +// +// for(auto i = 0u; i < _countof(physpreset_fields); i++) +// { +// if(physpreset_fields[i].iOffset != fields222[i].iOffset) +// { +// std::string error = "Error in field: " + std::string(physpreset_fields[i].szName); +// MessageBoxA(NULL, error.c_str(), "", 0); +// exit(0); +// } +// } +// +// MessageBoxA(NULL, "No error", "", 0); +// exit(0); +//} \ No newline at end of file diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.h new file mode 100644 index 00000000..9ee991d5 --- /dev/null +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.h @@ -0,0 +1,19 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/T6/T6.h" + +namespace T6 +{ + class AssetDumperPhysPreset final : public AbstractAssetDumper + { + static cspField_t physpreset_fields[]; + + static void CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo); + + protected: + bool ShouldDump(XAssetInfo* asset) override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; + void DumpAsset(Zone* zone, XAssetInfo* asset, FileAPI::File* out) override; + }; +} diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp new file mode 100644 index 00000000..2aacc25a --- /dev/null +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp @@ -0,0 +1,120 @@ +#include "AssetDumperTracer.h" + +#include + +#include "Game/T6/InfoStringT6.h" + +using namespace T6; + +cspField_t AssetDumperTracer::tracer_fields[] +{ + { "type", offsetof(TracerDef, type), TFT_TRACERTYPE }, + { "material", offsetof(TracerDef, material), CSPFT_MATERIAL }, + { "drawInterval", offsetof(TracerDef, drawInterval), CSPFT_INT }, + { "speed", offsetof(TracerDef, speed), CSPFT_FLOAT }, + { "beamLength", offsetof(TracerDef, beamLength), CSPFT_FLOAT }, + { "beamWidth", offsetof(TracerDef, beamWidth), CSPFT_FLOAT }, + { "screwRadius", offsetof(TracerDef, screwRadius), CSPFT_FLOAT }, + { "screwDist", offsetof(TracerDef, screwDist), CSPFT_FLOAT }, + { "fadeTime", offsetof(TracerDef, fadeTime), CSPFT_FLOAT }, + { "fadeScale", offsetof(TracerDef, fadeScale), CSPFT_FLOAT }, + { "texRepeatRate", offsetof(TracerDef, texRepeatRate), CSPFT_FLOAT }, + { "colorR0", offsetof(TracerDef, colors[0].r), CSPFT_FLOAT }, + { "colorG0", offsetof(TracerDef, colors[0].g), CSPFT_FLOAT }, + { "colorB0", offsetof(TracerDef, colors[0].b), CSPFT_FLOAT }, + { "colorA0", offsetof(TracerDef, colors[0].a), CSPFT_FLOAT }, + { "colorR1", offsetof(TracerDef, colors[1].r), CSPFT_FLOAT }, + { "colorG1", offsetof(TracerDef, colors[1].g), CSPFT_FLOAT }, + { "colorB1", offsetof(TracerDef, colors[1].b), CSPFT_FLOAT }, + { "colorA1", offsetof(TracerDef, colors[1].a), CSPFT_FLOAT }, + { "colorR2", offsetof(TracerDef, colors[2].r), CSPFT_FLOAT }, + { "colorG2", offsetof(TracerDef, colors[2].g), CSPFT_FLOAT }, + { "colorB2", offsetof(TracerDef, colors[2].b), CSPFT_FLOAT }, + { "colorA2", offsetof(TracerDef, colors[2].a), CSPFT_FLOAT }, + { "colorR3", offsetof(TracerDef, colors[3].r), CSPFT_FLOAT }, + { "colorG3", offsetof(TracerDef, colors[3].g), CSPFT_FLOAT }, + { "colorB3", offsetof(TracerDef, colors[3].b), CSPFT_FLOAT }, + { "colorA3", offsetof(TracerDef, colors[3].a), CSPFT_FLOAT }, + { "colorR4", offsetof(TracerDef, colors[4].r), CSPFT_FLOAT }, + { "colorG4", offsetof(TracerDef, colors[4].g), CSPFT_FLOAT }, + { "colorB4", offsetof(TracerDef, colors[4].b), CSPFT_FLOAT }, + { "colorA4", offsetof(TracerDef, colors[4].a), CSPFT_FLOAT } +}; + +namespace T6 +{ + const char* tracerTypeNames[] + { + "Laser", + "Smoke" + }; + + class InfoStringFromTracerConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + switch (static_cast(field.iFieldType)) + { + case TFT_TRACERTYPE: + FillFromEnumInt(std::string(field.szName), field.iOffset, tracerTypeNames, _countof(tracerTypeNames)); + break; + + case TFT_NUM_FIELD_TYPES: + default: + assert(false); + break; + } + } + + public: + InfoStringFromTracerConverter(const TracerDef* structure, const cspField_t* fields, const size_t fieldCount, std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; +} + +bool AssetDumperTracer::ShouldDump(XAssetInfo* asset) +{ + return true; +} + +std::string AssetDumperTracer::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) +{ + return "tracer/" + asset->m_name; +} + +void AssetDumperTracer::DumpAsset(Zone* zone, XAssetInfo* asset, FileAPI::File* out) +{ + InfoStringFromTracerConverter converter(asset->Asset(), tracer_fields, _countof(tracer_fields), [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.size()); + if (scrStr >= asset->m_zone->m_script_strings.size()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + const auto infoString = converter.Convert(); + const auto stringValue = infoString.ToString("TRACER"); + out->Write(stringValue.c_str(), 1, stringValue.length()); +} + +//void AssetDumperTracer::CheckFields() +//{ +// assert(_countof(tracer_fields) == _countof(fields222)); +// +// for(auto i = 0u; i < _countof(tracer_fields); i++) +// { +// if(tracer_fields[i].iOffset != fields222[i].iOffset) +// { +// std::string error = "Error in field: " + std::string(tracer_fields[i].szName); +// MessageBoxA(NULL, error.c_str(), "", 0); +// exit(0); +// } +// } +// +// MessageBoxA(NULL, "No error", "", 0); +// exit(0); +//} \ No newline at end of file diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.h new file mode 100644 index 00000000..61e16c9a --- /dev/null +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.h @@ -0,0 +1,17 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/T6/T6.h" + +namespace T6 +{ + class AssetDumperTracer final : public AbstractAssetDumper + { + static cspField_t tracer_fields[]; + + protected: + bool ShouldDump(XAssetInfo* asset) override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; + void DumpAsset(Zone* zone, XAssetInfo* asset, FileAPI::File* out) override; + }; +} diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.h index 662f4e3d..164f6707 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.h @@ -13,8 +13,5 @@ namespace T6 bool ShouldDump(XAssetInfo* asset) override; std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; void DumpAsset(Zone* zone, XAssetInfo* asset, FileAPI::File* out) override; - - public: - static void CheckFields(); }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp new file mode 100644 index 00000000..de03e58b --- /dev/null +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp @@ -0,0 +1,218 @@ +#include "AssetDumperZBarrier.h" + +#include + +#include "Game/T6/InfoStringT6.h" + +using namespace T6; + +cspField_t AssetDumperZBarrier::zbarrier_fields[] +{ + { "delayBetweenGeneralRepSounds", offsetof(ZBarrierDef, delayBetweenRepSoundsDuration), CSPFT_FLOAT }, + { "earthquakeMaxDuration", offsetof(ZBarrierDef, earthquakeMaxDuration), CSPFT_FLOAT }, + { "earthquakeMaxScale", offsetof(ZBarrierDef, earthquakeMaxScale), CSPFT_FLOAT }, + { "earthquakeMinDuration", offsetof(ZBarrierDef, earthquakeMinDuration), CSPFT_FLOAT }, + { "earthquakeMinScale", offsetof(ZBarrierDef, earthquakeMinScale), CSPFT_FLOAT }, + { "earthquakeOnRepair", offsetof(ZBarrierDef, earthquakeOnRepair), CSPFT_UINT }, + { "earthquakeRadius", offsetof(ZBarrierDef, earthquakeRadius), CSPFT_FLOAT }, + { "generalRepairSound0", offsetof(ZBarrierDef, generalRepairSound1), CSPFT_SOUND_ALIAS_ID }, + { "generalRepairSound1", offsetof(ZBarrierDef, generalRepairSound2), CSPFT_SOUND_ALIAS_ID }, + { "upgradedGeneralRepairSound0", offsetof(ZBarrierDef, upgradedGeneralRepairSound1), CSPFT_SOUND_ALIAS_ID }, + { "upgradedGeneralRepairSound1", offsetof(ZBarrierDef, upgradedGeneralRepairSound2), CSPFT_SOUND_ALIAS_ID }, + { "useDelayBetweenGeneralRepSounds", offsetof(ZBarrierDef, delayBetweenRepSounds), CSPFT_UINT }, + { "taunts", offsetof(ZBarrierDef, taunts), CSPFT_UINT }, + { "reachThroughAttacks", offsetof(ZBarrierDef, reachThroughAttacks), CSPFT_UINT }, + { "zombieTauntAnimState", offsetof(ZBarrierDef, zombieTauntAnimState), CSPFT_SCRIPT_STRING }, + { "zombieReachThroughAnimState", offsetof(ZBarrierDef, zombieReachThroughAnimState), CSPFT_SCRIPT_STRING }, + { "numAttackSlots", offsetof(ZBarrierDef, numAttackSlots), CSPFT_UINT }, + { "attackSpotHorzOffset", offsetof(ZBarrierDef, attackSpotHorzOffset), CSPFT_FLOAT }, + { "autoHideOpenPieces", offsetof(ZBarrierDef, autoHideOpenPieces), CSPFT_UINT }, + { "alternateBoardModel1", offsetof(ZBarrierDef, boards[0].pAlternateBoardModel), CSPFT_XMODEL }, + { "boardAnim1", offsetof(ZBarrierDef, boards[0].pBoardAnim), CSPFT_STRING }, + { "boardModel1", offsetof(ZBarrierDef, boards[0].pBoardModel), CSPFT_XMODEL }, + { "boardRepairSound1", offsetof(ZBarrierDef, boards[0].boardRepairSound), CSPFT_SOUND_ALIAS_ID }, + { "boardRepairHoverSound1", offsetof(ZBarrierDef, boards[0].boardRepairHoverSound), CSPFT_SOUND_ALIAS_ID }, + { "OffsetRepairFxX10", offsetof(ZBarrierDef, boards[0].repairEffect1Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxX11", offsetof(ZBarrierDef, boards[0].repairEffect2Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxY10", offsetof(ZBarrierDef, boards[0].repairEffect1Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxY11", offsetof(ZBarrierDef, boards[0].repairEffect2Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxZ10", offsetof(ZBarrierDef, boards[0].repairEffect1Offset.z), CSPFT_FLOAT }, + { "OffsetRepairFxZ11", offsetof(ZBarrierDef, boards[0].repairEffect2Offset.z), CSPFT_FLOAT }, + { "pauseAndRepeatBoardRepairSound1", offsetof(ZBarrierDef, boards[0].pauseAndRepeatRepSound), CSPFT_UINT }, + { "pauseBetweenRepSoundsMax1", offsetof(ZBarrierDef, boards[0].maxPause), CSPFT_FLOAT }, + { "pauseBetweenRepSoundsMin1", offsetof(ZBarrierDef, boards[0].minPause), CSPFT_FLOAT }, + { "proBoardNumRepsToTear1", offsetof(ZBarrierDef, boards[0].numRepsToPullProBoard), CSPFT_UINT }, + { "repairFx10", offsetof(ZBarrierDef, boards[0].repairEffect1), CSPFT_FX }, + { "repairFx11", offsetof(ZBarrierDef, boards[0].repairEffect2), CSPFT_FX }, + { "tearAnim1", offsetof(ZBarrierDef, boards[0].pTearAnim), CSPFT_STRING }, + { "upgradedBoardModel1", offsetof(ZBarrierDef, boards[0].pUpgradedBoardModel), CSPFT_XMODEL }, + { "zombieBoardTearAnimState1", offsetof(ZBarrierDef, boards[0].zombieBoardTearStateName), CSPFT_SCRIPT_STRING }, + { "zombieBoardTearAnimSubState1", offsetof(ZBarrierDef, boards[0].zombieBoardTearSubStateName), CSPFT_SCRIPT_STRING }, + { "alternateBoardModel2", offsetof(ZBarrierDef, boards[1].pAlternateBoardModel), CSPFT_XMODEL }, + { "boardAnim2", offsetof(ZBarrierDef, boards[1].pBoardAnim), CSPFT_STRING }, + { "boardModel2", offsetof(ZBarrierDef, boards[1].pBoardModel), CSPFT_XMODEL }, + { "boardRepairSound2", offsetof(ZBarrierDef, boards[1].boardRepairSound), CSPFT_SOUND_ALIAS_ID }, + { "boardRepairHoverSound2", offsetof(ZBarrierDef, boards[1].boardRepairHoverSound), CSPFT_SOUND_ALIAS_ID }, + { "OffsetRepairFxX20", offsetof(ZBarrierDef, boards[1].repairEffect1Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxX21", offsetof(ZBarrierDef, boards[1].repairEffect2Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxY20", offsetof(ZBarrierDef, boards[1].repairEffect1Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxY21", offsetof(ZBarrierDef, boards[1].repairEffect2Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxZ20", offsetof(ZBarrierDef, boards[1].repairEffect1Offset.z), CSPFT_FLOAT }, + { "OffsetRepairFxZ21", offsetof(ZBarrierDef, boards[1].repairEffect2Offset.z), CSPFT_FLOAT }, + { "pauseAndRepeatBoardRepairSound2", offsetof(ZBarrierDef, boards[1].pauseAndRepeatRepSound), CSPFT_UINT }, + { "pauseBetweenRepSoundsMax2", offsetof(ZBarrierDef, boards[1].maxPause), CSPFT_FLOAT }, + { "pauseBetweenRepSoundsMin2", offsetof(ZBarrierDef, boards[1].minPause), CSPFT_FLOAT }, + { "proBoardNumRepsToTear2", offsetof(ZBarrierDef, boards[1].numRepsToPullProBoard), CSPFT_UINT }, + { "repairFx20", offsetof(ZBarrierDef, boards[1].repairEffect1), CSPFT_FX }, + { "repairFx21", offsetof(ZBarrierDef, boards[1].repairEffect2), CSPFT_FX }, + { "tearAnim2", offsetof(ZBarrierDef, boards[1].pTearAnim), CSPFT_STRING }, + { "upgradedBoardModel2", offsetof(ZBarrierDef, boards[1].pUpgradedBoardModel), CSPFT_XMODEL }, + { "zombieBoardTearAnimState2", offsetof(ZBarrierDef, boards[1].zombieBoardTearStateName), CSPFT_SCRIPT_STRING }, + { "zombieBoardTearAnimSubState2", offsetof(ZBarrierDef, boards[1].zombieBoardTearSubStateName), CSPFT_SCRIPT_STRING }, + { "alternateBoardModel3", offsetof(ZBarrierDef, boards[2].pAlternateBoardModel), CSPFT_XMODEL }, + { "boardAnim3", offsetof(ZBarrierDef, boards[2].pBoardAnim), CSPFT_STRING }, + { "boardModel3", offsetof(ZBarrierDef, boards[2].pBoardModel), CSPFT_XMODEL }, + { "boardRepairSound3", offsetof(ZBarrierDef, boards[2].boardRepairSound), CSPFT_SOUND_ALIAS_ID }, + { "boardRepairHoverSound3", offsetof(ZBarrierDef, boards[2].boardRepairHoverSound), CSPFT_SOUND_ALIAS_ID }, + { "OffsetRepairFxX30", offsetof(ZBarrierDef, boards[2].repairEffect1Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxX31", offsetof(ZBarrierDef, boards[2].repairEffect2Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxY30", offsetof(ZBarrierDef, boards[2].repairEffect1Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxY31", offsetof(ZBarrierDef, boards[2].repairEffect2Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxZ30", offsetof(ZBarrierDef, boards[2].repairEffect1Offset.z), CSPFT_FLOAT }, + { "OffsetRepairFxZ31", offsetof(ZBarrierDef, boards[2].repairEffect2Offset.z), CSPFT_FLOAT }, + { "pauseAndRepeatBoardRepairSound3", offsetof(ZBarrierDef, boards[2].pauseAndRepeatRepSound), CSPFT_UINT }, + { "pauseBetweenRepSoundsMax3", offsetof(ZBarrierDef, boards[2].maxPause), CSPFT_FLOAT }, + { "pauseBetweenRepSoundsMin3", offsetof(ZBarrierDef, boards[2].minPause), CSPFT_FLOAT }, + { "proBoardNumRepsToTear3", offsetof(ZBarrierDef, boards[2].numRepsToPullProBoard), CSPFT_UINT }, + { "repairFx30", offsetof(ZBarrierDef, boards[2].repairEffect1), CSPFT_FX }, + { "repairFx31", offsetof(ZBarrierDef, boards[2].repairEffect2), CSPFT_FX }, + { "tearAnim3", offsetof(ZBarrierDef, boards[2].pTearAnim), CSPFT_STRING }, + { "upgradedBoardModel3", offsetof(ZBarrierDef, boards[2].pUpgradedBoardModel), CSPFT_XMODEL }, + { "zombieBoardTearAnimState3", offsetof(ZBarrierDef, boards[2].zombieBoardTearStateName), CSPFT_SCRIPT_STRING }, + { "zombieBoardTearAnimSubState3", offsetof(ZBarrierDef, boards[2].zombieBoardTearSubStateName), CSPFT_SCRIPT_STRING }, + { "alternateBoardModel4", offsetof(ZBarrierDef, boards[3].pAlternateBoardModel), CSPFT_XMODEL }, + { "boardAnim4", offsetof(ZBarrierDef, boards[3].pBoardAnim), CSPFT_STRING }, + { "boardModel4", offsetof(ZBarrierDef, boards[3].pBoardModel), CSPFT_XMODEL }, + { "boardRepairSound4", offsetof(ZBarrierDef, boards[3].boardRepairSound), CSPFT_SOUND_ALIAS_ID }, + { "boardRepairHoverSound4", offsetof(ZBarrierDef, boards[3].boardRepairHoverSound), CSPFT_SOUND_ALIAS_ID }, + { "OffsetRepairFxX40", offsetof(ZBarrierDef, boards[3].repairEffect1Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxX41", offsetof(ZBarrierDef, boards[3].repairEffect2Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxY40", offsetof(ZBarrierDef, boards[3].repairEffect1Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxY41", offsetof(ZBarrierDef, boards[3].repairEffect2Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxZ40", offsetof(ZBarrierDef, boards[3].repairEffect1Offset.z), CSPFT_FLOAT }, + { "OffsetRepairFxZ41", offsetof(ZBarrierDef, boards[3].repairEffect2Offset.z), CSPFT_FLOAT }, + { "pauseAndRepeatBoardRepairSound4", offsetof(ZBarrierDef, boards[3].pauseAndRepeatRepSound), CSPFT_UINT }, + { "pauseBetweenRepSoundsMax4", offsetof(ZBarrierDef, boards[3].maxPause), CSPFT_FLOAT }, + { "pauseBetweenRepSoundsMin4", offsetof(ZBarrierDef, boards[3].minPause), CSPFT_FLOAT }, + { "proBoardNumRepsToTear4", offsetof(ZBarrierDef, boards[3].numRepsToPullProBoard), CSPFT_UINT }, + { "repairFx40", offsetof(ZBarrierDef, boards[3].repairEffect1), CSPFT_FX }, + { "repairFx41", offsetof(ZBarrierDef, boards[3].repairEffect2), CSPFT_FX }, + { "tearAnim4", offsetof(ZBarrierDef, boards[3].pTearAnim), CSPFT_STRING }, + { "upgradedBoardModel4", offsetof(ZBarrierDef, boards[3].pUpgradedBoardModel), CSPFT_XMODEL }, + { "zombieBoardTearAnimState4", offsetof(ZBarrierDef, boards[3].zombieBoardTearStateName), CSPFT_SCRIPT_STRING }, + { "zombieBoardTearAnimSubState4", offsetof(ZBarrierDef, boards[3].zombieBoardTearSubStateName), CSPFT_SCRIPT_STRING }, + { "alternateBoardModel5", offsetof(ZBarrierDef, boards[4].pAlternateBoardModel), CSPFT_XMODEL }, + { "boardAnim5", offsetof(ZBarrierDef, boards[4].pBoardAnim), CSPFT_STRING }, + { "boardModel5", offsetof(ZBarrierDef, boards[4].pBoardModel), CSPFT_XMODEL }, + { "boardRepairSound5", offsetof(ZBarrierDef, boards[4].boardRepairSound), CSPFT_SOUND_ALIAS_ID }, + { "boardRepairHoverSound5", offsetof(ZBarrierDef, boards[4].boardRepairHoverSound), CSPFT_SOUND_ALIAS_ID }, + { "OffsetRepairFxX50", offsetof(ZBarrierDef, boards[4].repairEffect1Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxX51", offsetof(ZBarrierDef, boards[4].repairEffect2Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxY50", offsetof(ZBarrierDef, boards[4].repairEffect1Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxY51", offsetof(ZBarrierDef, boards[4].repairEffect2Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxZ50", offsetof(ZBarrierDef, boards[4].repairEffect1Offset.z), CSPFT_FLOAT }, + { "OffsetRepairFxZ51", offsetof(ZBarrierDef, boards[4].repairEffect2Offset.z), CSPFT_FLOAT }, + { "pauseAndRepeatBoardRepairSound5", offsetof(ZBarrierDef, boards[4].pauseAndRepeatRepSound), CSPFT_UINT }, + { "pauseBetweenRepSoundsMax5", offsetof(ZBarrierDef, boards[4].maxPause), CSPFT_FLOAT }, + { "pauseBetweenRepSoundsMin5", offsetof(ZBarrierDef, boards[4].minPause), CSPFT_FLOAT }, + { "proBoardNumRepsToTear5", offsetof(ZBarrierDef, boards[4].numRepsToPullProBoard), CSPFT_UINT }, + { "repairFx50", offsetof(ZBarrierDef, boards[4].repairEffect1), CSPFT_FX }, + { "repairFx51", offsetof(ZBarrierDef, boards[4].repairEffect2), CSPFT_FX }, + { "tearAnim5", offsetof(ZBarrierDef, boards[4].pTearAnim), CSPFT_STRING }, + { "upgradedBoardModel5", offsetof(ZBarrierDef, boards[4].pUpgradedBoardModel), CSPFT_XMODEL }, + { "zombieBoardTearAnimState5", offsetof(ZBarrierDef, boards[4].zombieBoardTearStateName), CSPFT_SCRIPT_STRING }, + { "zombieBoardTearAnimSubState5", offsetof(ZBarrierDef, boards[4].zombieBoardTearSubStateName), CSPFT_SCRIPT_STRING }, + { "alternateBoardModel6", offsetof(ZBarrierDef, boards[5].pAlternateBoardModel), CSPFT_XMODEL }, + { "boardAnim6", offsetof(ZBarrierDef, boards[5].pBoardAnim), CSPFT_STRING }, + { "boardModel6", offsetof(ZBarrierDef, boards[5].pBoardModel), CSPFT_XMODEL }, + { "boardRepairSound6", offsetof(ZBarrierDef, boards[5].boardRepairSound), CSPFT_SOUND_ALIAS_ID }, + { "boardRepairHoverSound6", offsetof(ZBarrierDef, boards[5].boardRepairHoverSound), CSPFT_SOUND_ALIAS_ID }, + { "OffsetRepairFxX60", offsetof(ZBarrierDef, boards[5].repairEffect1Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxX61", offsetof(ZBarrierDef, boards[5].repairEffect2Offset.x), CSPFT_FLOAT }, + { "OffsetRepairFxY60", offsetof(ZBarrierDef, boards[5].repairEffect1Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxY61", offsetof(ZBarrierDef, boards[5].repairEffect2Offset.y), CSPFT_FLOAT }, + { "OffsetRepairFxZ60", offsetof(ZBarrierDef, boards[5].repairEffect1Offset.z), CSPFT_FLOAT }, + { "OffsetRepairFxZ61", offsetof(ZBarrierDef, boards[5].repairEffect2Offset.z), CSPFT_FLOAT }, + { "pauseAndRepeatBoardRepairSound6", offsetof(ZBarrierDef, boards[5].pauseAndRepeatRepSound), CSPFT_UINT }, + { "pauseBetweenRepSoundsMax6", offsetof(ZBarrierDef, boards[5].maxPause), CSPFT_FLOAT }, + { "pauseBetweenRepSoundsMin6", offsetof(ZBarrierDef, boards[5].minPause), CSPFT_FLOAT }, + { "proBoardNumRepsToTear6", offsetof(ZBarrierDef, boards[5].numRepsToPullProBoard), CSPFT_UINT }, + { "repairFx60", offsetof(ZBarrierDef, boards[5].repairEffect1), CSPFT_FX }, + { "repairFx61", offsetof(ZBarrierDef, boards[5].repairEffect2), CSPFT_FX }, + { "tearAnim6", offsetof(ZBarrierDef, boards[5].pTearAnim), CSPFT_STRING }, + { "upgradedBoardModel6", offsetof(ZBarrierDef, boards[5].pUpgradedBoardModel), CSPFT_XMODEL }, + { "zombieBoardTearAnimState6", offsetof(ZBarrierDef, boards[5].zombieBoardTearStateName), CSPFT_SCRIPT_STRING }, + { "zombieBoardTearAnimSubState6", offsetof(ZBarrierDef, boards[5].zombieBoardTearSubStateName), CSPFT_SCRIPT_STRING }, +}; + +namespace T6 +{ + class InfoStringFromZBarrierConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + assert(false); + } + + public: + InfoStringFromZBarrierConverter(const ZBarrierDef* structure, const cspField_t* fields, const size_t fieldCount, std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; +} + +bool AssetDumperZBarrier::ShouldDump(XAssetInfo* asset) +{ + return true; +} + +std::string AssetDumperZBarrier::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) +{ + return "zbarrier/" + asset->m_name; +} + +void AssetDumperZBarrier::DumpAsset(Zone* zone, XAssetInfo* asset, FileAPI::File* out) +{ + InfoStringFromZBarrierConverter converter(asset->Asset(), zbarrier_fields, _countof(zbarrier_fields), [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.size()); + if (scrStr >= asset->m_zone->m_script_strings.size()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + const auto infoString = converter.Convert(); + const auto stringValue = infoString.ToString("ZBARRIER"); + out->Write(stringValue.c_str(), 1, stringValue.length()); +} + +//void AssetDumperZBarrier::CheckFields() +//{ +// assert(_countof(zbarrier_fields) == _countof(fields222)); +// +// for(auto i = 0u; i < _countof(zbarrier_fields); i++) +// { +// if(zbarrier_fields[i].iOffset != fields222[i].iOffset) +// { +// std::string error = "Error in field: " + std::string(zbarrier_fields[i].szName); +// MessageBoxA(NULL, error.c_str(), "", 0); +// exit(0); +// } +// } +// +// MessageBoxA(NULL, "No error", "", 0); +// exit(0); +//} \ No newline at end of file diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.h new file mode 100644 index 00000000..59888e44 --- /dev/null +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.h @@ -0,0 +1,17 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/T6/T6.h" + +namespace T6 +{ + class AssetDumperZBarrier final : public AbstractAssetDumper + { + static cspField_t zbarrier_fields[]; + + protected: + bool ShouldDump(XAssetInfo* asset) override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; + void DumpAsset(Zone* zone, XAssetInfo* asset, FileAPI::File* out) override; + }; +} diff --git a/src/ObjWriting/Game/T6/ZoneDumperT6.cpp b/src/ObjWriting/Game/T6/ZoneDumperT6.cpp index b896ca36..13c5767b 100644 --- a/src/ObjWriting/Game/T6/ZoneDumperT6.cpp +++ b/src/ObjWriting/Game/T6/ZoneDumperT6.cpp @@ -11,8 +11,11 @@ #include "AssetDumpers/AssetDumperLocalizeEntry.h" #include "AssetDumpers/AssetDumperGfxImage.h" #include "AssetDumpers/AssetDumperFontIcon.h" +#include "AssetDumpers/AssetDumperPhysPreset.h" +#include "AssetDumpers/AssetDumperTracer.h" #include "AssetDumpers/AssetDumperVehicle.h" #include "AssetDumpers/AssetDumperWeapon.h" +#include "AssetDumpers/AssetDumperZBarrier.h" using namespace T6; @@ -30,9 +33,9 @@ bool ZoneDumper::DumpZone(Zone* zone, const std::string& basePath) const dumper.DumpPool(zone, assetPools->poolName, basePath); \ } - const auto assetPools = dynamic_cast(zone->m_pools.get()); + const auto* assetPools = dynamic_cast(zone->m_pools.get()); - // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset); + DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset); // DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints); // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def); // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts); @@ -73,13 +76,13 @@ bool ZoneDumper::DumpZone(Zone* zone, const std::string& basePath) const DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle); // DUMP_ASSET_POOL(AssetDumperMemoryBlock, m_memory_block); // DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents); - // DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer); + DUMP_ASSET_POOL(AssetDumperTracer, m_tracer); // DUMP_ASSET_POOL(AssetDumperSkinnedVertsDef, m_skinned_verts); DUMP_ASSET_POOL(AssetDumperQdb, m_qdb); DUMP_ASSET_POOL(AssetDumperSlug, m_slug); // DUMP_ASSET_POOL(AssetDumperFootstepTableDef, m_footstep_table); // DUMP_ASSET_POOL(AssetDumperFootstepFXTableDef, m_footstep_fx_table); - // DUMP_ASSET_POOL(AssetDumperZBarrierDef, m_zbarrier); + DUMP_ASSET_POOL(AssetDumperZBarrier, m_zbarrier); return true; diff --git a/src/ZoneCommon/Game/T6/T6_Assets.h b/src/ZoneCommon/Game/T6/T6_Assets.h index 95bcf713..313efc93 100644 --- a/src/ZoneCommon/Game/T6/T6_Assets.h +++ b/src/ZoneCommon/Game/T6/T6_Assets.h @@ -394,6 +394,22 @@ namespace T6 float v[3]; }; + struct PhysPresetInfo + { + float mass; + float bounce; + float friction; + int isFrictionInfinity; + float bulletForceScale; + float explosiveForceScale; + float piecesSpreadFraction; + float piecesUpwardVelocity; + int canFloat; + float gravityScale; + vec3_t centerOfMassOffset; + vec3_t buoyancyBoxMin; + vec3_t buoyancyBoxMax; + }; struct PhysPreset {