diff --git a/src/ObjCommon/Utils/InfoString.cpp b/src/ObjCommon/Utils/InfoString.cpp index 8147e209..93174869 100644 --- a/src/ObjCommon/Utils/InfoString.cpp +++ b/src/ObjCommon/Utils/InfoString.cpp @@ -86,6 +86,17 @@ std::string InfoString::ToString(const std::string& prefix) const return ss.str(); } +void InfoString::ToGdtProperties(const std::string& prefix, GdtEntry& gdtEntry) const +{ + for (const auto& key : m_keys_by_insertion) + { + const auto value = m_values.find(key); + gdtEntry.m_properties[key] = value->second; + } + + gdtEntry.m_properties["configstringFileType"] = prefix; +} + void InfoString::FromString() { } diff --git a/src/ObjCommon/Utils/InfoString.h b/src/ObjCommon/Utils/InfoString.h index f638cee6..22ffb0b2 100644 --- a/src/ObjCommon/Utils/InfoString.h +++ b/src/ObjCommon/Utils/InfoString.h @@ -4,6 +4,8 @@ #include #include + +#include "Obj/GDT/GdtEntry.h" #include "Zone/ZoneTypes.h" class InfoString @@ -21,6 +23,7 @@ public: std::string ToString() const; std::string ToString(const std::string& prefix) const; + void ToGdtProperties(const std::string& prefix, GdtEntry& gdtEntry) const; void FromString(); void FromString(const std::string& prefix); diff --git a/src/ObjWriting/Dumping/AbstractAssetDumper.h b/src/ObjWriting/Dumping/AbstractAssetDumper.h new file mode 100644 index 00000000..6f001640 --- /dev/null +++ b/src/ObjWriting/Dumping/AbstractAssetDumper.h @@ -0,0 +1,91 @@ +#pragma once + +#include "IAssetDumper.h" + +#include +#include +#include + +template +class AbstractAssetDumper : public IAssetDumper +{ +protected: + virtual bool ShouldDump(XAssetInfo* asset) + { + return true; + } + + virtual bool CanDumpAsRaw() + { + return false; + } + + virtual bool CanDumpAsGdtEntry() + { + return false; + } + + virtual std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) + { + return asset->m_name; + } + + virtual void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) + { + + } + + virtual GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) + { + return GdtEntry(); + } + +public: + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override + { + if(context.m_gdt && CanDumpAsGdtEntry()) + { + for (auto assetInfo : *pool) + { + if (assetInfo->m_name[0] == ',' + || !ShouldDump(assetInfo)) + { + continue; + } + + auto entry = DumpGdtEntry(context, assetInfo); + context.m_gdt->WriteEntry(entry); + } + } + else if(CanDumpAsRaw()) + { + for (auto assetInfo : *pool) + { + if (assetInfo->m_name[0] == ',' + || !ShouldDump(assetInfo)) + { + continue; + } + + std::filesystem::path assetFilePath(context.m_base_path); + assetFilePath.append(GetFileNameForAsset(context.m_zone, assetInfo)); + + auto assetFileFolder(assetFilePath); + assetFileFolder.replace_filename(""); + create_directories(assetFileFolder); + + std::ofstream file(assetFilePath, std::fstream::out | std::fstream::binary); + if (file.is_open()) + { + DumpRaw(context, assetInfo, file); + + file.close(); + } + else + { + std::cout << "Failed to open file '" << assetFilePath.string() << "' to dump asset '" << assetInfo->m_name.c_str() << "'\n"; + } + } + } + } +}; diff --git a/src/ObjWriting/Dumping/AbstractFileDumper.h b/src/ObjWriting/Dumping/AbstractFileDumper.h deleted file mode 100644 index d74b6c85..00000000 --- a/src/ObjWriting/Dumping/AbstractFileDumper.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "IAssetDumper.h" - -#include -#include -#include - -template -class AbstractFileDumper : public IAssetDumper -{ -protected: - virtual bool ShouldDump(XAssetInfo* asset) = 0; - virtual std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) = 0; - virtual void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) = 0; - -public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override - { - for(auto assetInfo : *pool) - { - if(assetInfo->m_name[0] == ',' - || !ShouldDump(assetInfo)) - { - continue; - } - - std::filesystem::path assetFilePath(context.m_base_path); - assetFilePath.append(GetFileNameForAsset(context.m_zone, assetInfo)); - - auto assetFileFolder(assetFilePath); - assetFileFolder.replace_filename(""); - create_directories(assetFileFolder); - - std::ofstream file(assetFilePath, std::fstream::out | std::fstream::binary); - if(file.is_open()) - { - DumpAsset(context, assetInfo, file); - - file.close(); - } - else - { - std::cout << "Failed to open file '" << assetFilePath.string() << "' to dump asset '" << assetInfo->m_name.c_str() << "'\n"; - } - } - } -}; diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.cpp index 21db7c90..4e64366a 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.cpp @@ -10,12 +10,17 @@ bool AssetDumperAddonMapEnts::ShouldDump(XAssetInfo* asset) return true; } +bool AssetDumperAddonMapEnts::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperAddonMapEnts::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return asset->m_name; } -void AssetDumperAddonMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperAddonMapEnts::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* addonMapEnts = asset->Asset(); stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0)); diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.h b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.h index 65079f54..b6cc6729 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.h +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.h @@ -1,15 +1,16 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" namespace IW4 { - class AssetDumperAddonMapEnts final : public AbstractFileDumper + class AssetDumperAddonMapEnts final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.cpp index 909cd909..5554de59 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.cpp @@ -13,10 +13,10 @@ AssetDumperGfxImage::AssetDumperGfxImage() switch (ObjWriting::Configuration.ImageOutputFormat) { case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: - m_writer = new DdsWriter(); + m_writer = std::make_unique(); break; case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: - m_writer = new iwi8::IwiWriter(); + m_writer = std::make_unique(); break; default: assert(false); @@ -25,24 +25,23 @@ AssetDumperGfxImage::AssetDumperGfxImage() } } -AssetDumperGfxImage::~AssetDumperGfxImage() -{ - delete m_writer; - m_writer = nullptr; -} - bool AssetDumperGfxImage::ShouldDump(XAssetInfo* asset) { const auto* image = asset->Asset(); return image->cardMemory.platform[0] > 0; } +bool AssetDumperGfxImage::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperGfxImage::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return "images/" + asset->m_name + m_writer->GetFileExtension(); } -void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperGfxImage::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* image = asset->Asset(); m_writer->DumpImage(stream, image->texture.texture); diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.h b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.h index 4e75db43..1bd2019a 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.h +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.h @@ -1,27 +1,24 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include + +#include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" #include "Image/IImageWriter.h" namespace IW4 { - class AssetDumperGfxImage final : public AbstractFileDumper + class AssetDumperGfxImage final : public AbstractAssetDumper { - IImageWriter* m_writer; + std::unique_ptr m_writer; protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; public: AssetDumperGfxImage(); - ~AssetDumperGfxImage() override; - - AssetDumperGfxImage(const AssetDumperGfxImage& other) = delete; - AssetDumperGfxImage(AssetDumperGfxImage&& other) noexcept = delete; - AssetDumperGfxImage& operator=(const AssetDumperGfxImage& other) = delete; - AssetDumperGfxImage& operator=(AssetDumperGfxImage&& other) noexcept = delete; }; } diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.cpp index 9a9b47b6..80f5097e 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.cpp @@ -9,6 +9,11 @@ bool AssetDumperLoadedSound::ShouldDump(XAssetInfo* asset) return true; } +bool AssetDumperLoadedSound::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperLoadedSound::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return "sound/" + asset->m_name; @@ -55,7 +60,7 @@ void AssetDumperLoadedSound::DumpWavPcm(AssetDumpingContext& context, const Load stream.write(asset->sound.data, asset->sound.info.data_len); } -void AssetDumperLoadedSound::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperLoadedSound::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* loadedSound = asset->Asset(); switch (static_cast(loadedSound->sound.info.format)) diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.h b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.h index 21e87abf..7f614889 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.h +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.h @@ -1,16 +1,17 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" namespace IW4 { - class AssetDumperLoadedSound final : public AbstractFileDumper + class AssetDumperLoadedSound final : public AbstractAssetDumper { static void DumpWavPcm(AssetDumpingContext& context, const LoadedSound* asset, std::ostream& stream); protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLocalizeEntry.h index b5afe08d..69641d33 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLocalizeEntry.h +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLocalizeEntry.h @@ -1,6 +1,6 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" namespace IW4 diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp index d4914abf..e1acba04 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp @@ -10,12 +10,17 @@ bool AssetDumperRawFile::ShouldDump(XAssetInfo* asset) return true; } +bool AssetDumperRawFile::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperRawFile::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return asset->m_name; } -void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperRawFile::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* rawFile = asset->Asset(); if (rawFile->compressedLen > 0) diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.h b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.h index 6f77db7e..ffc6a713 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.h +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.h @@ -1,15 +1,16 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" namespace IW4 { - class AssetDumperRawFile final : public AbstractFileDumper + class AssetDumperRawFile final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.cpp index d09fe316..a54cf77a 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.cpp @@ -9,12 +9,17 @@ bool AssetDumperStringTable::ShouldDump(XAssetInfo* asset) return true; } +bool AssetDumperStringTable::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperStringTable::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return asset->m_name; } -void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperStringTable::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* stringTable = asset->Asset(); CsvWriter csv(stream); @@ -29,4 +34,4 @@ void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo< csv.NextRow(); } -} \ No newline at end of file +} diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.h b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.h index 96cdd4e2..a717bc18 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.h +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.h @@ -1,15 +1,17 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" namespace IW4 { - class AssetDumperStringTable final : public AbstractFileDumper + class AssetDumperStringTable final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.cpp index 0eafb8a6..5b97f8f4 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.cpp @@ -231,17 +231,7 @@ namespace IW4 }; } -bool AssetDumperVehicle::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -std::string AssetDumperVehicle::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) -{ - return "vehicles/" + asset->m_name; -} - -void AssetDumperVehicle::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +InfoString AssetDumperVehicle::CreateInfoString(XAssetInfo* asset) { InfoStringFromVehicleConverter converter(asset->Asset(), vehicle_fields, std::extent::value, [asset](const scr_string_t scrStr) -> std::string { @@ -252,7 +242,41 @@ void AssetDumperVehicle::DumpAsset(AssetDumpingContext& context, XAssetInfom_zone->m_script_strings[scrStr]; }); - const auto infoString = converter.Convert(); - const auto stringValue = infoString.ToString("VEHICLEFILE"); + return converter.Convert(); +} + +bool AssetDumperVehicle::ShouldDump(XAssetInfo* asset) +{ + return true; +} + +bool AssetDumperVehicle::CanDumpAsRaw() +{ + return true; +} + +bool AssetDumperVehicle::CanDumpAsGdtEntry() +{ + return true; +} + +std::string AssetDumperVehicle::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) +{ + return "vehicles/" + asset->m_name; +} + +GdtEntry AssetDumperVehicle::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) +{ + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, GDF_NAME); + infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry); + + return gdtEntry; +} + +void AssetDumperVehicle::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +{ + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(FILE_TYPE_STR); stream.write(stringValue.c_str(), stringValue.size()); -} \ No newline at end of file +} diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.h b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.h index 8f836935..6df71449 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.h +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.h @@ -1,18 +1,26 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" +#include "Utils/InfoString.h" namespace IW4 { - class AssetDumperVehicle final : public AbstractFileDumper + class AssetDumperVehicle final : public AbstractAssetDumper { + static constexpr const char* FILE_TYPE_STR = "VEHICLEFILE"; + static constexpr const char* GDF_NAME = "vehicle.gdf"; static cspField_t vehicle_fields[]; - static cspField_t vehicle_fields2[]; + + static InfoString CreateInfoString(XAssetInfo* asset); protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + bool CanDumpAsGdtEntry() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.cpp index 992f29ef..011b9564 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.cpp @@ -1162,34 +1162,56 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFul } } +InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo* asset) +{ + const auto fullDef = std::make_unique(); + memset(fullDef.get(), 0, sizeof(WeaponFullDef)); + CopyToFullDef(asset->Asset(), fullDef.get()); + + InfoStringFromWeaponConverter converter(fullDef.get(), weapon_fields, std::extent::value, [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]; + }); + + return converter.Convert(); +} + bool AssetDumperWeapon::ShouldDump(XAssetInfo* asset) { return true; } +bool AssetDumperWeapon::CanDumpAsRaw() +{ + return true; +} + +bool AssetDumperWeapon::CanDumpAsGdtEntry() +{ + return true; +} + std::string AssetDumperWeapon::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return "weapons/" + asset->m_name; } -void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +GdtEntry AssetDumperWeapon::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) { - auto* fullDef = new WeaponFullDef; - memset(fullDef, 0, sizeof(WeaponFullDef)); - CopyToFullDef(asset->Asset(), fullDef); + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, GDF_NAME); + infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry); - InfoStringFromWeaponConverter converter(fullDef, weapon_fields, std::extent::value, [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("WEAPONFILE"); - stream.write(stringValue.c_str(), stringValue.size()); - - delete fullDef; + return gdtEntry; +} + +void AssetDumperWeapon::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +{ + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(FILE_TYPE_STR); + stream.write(stringValue.c_str(), stringValue.size()); } diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.h b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.h index a890c66b..4597d81a 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.h +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.h @@ -1,19 +1,27 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" +#include "Utils/InfoString.h" namespace IW4 { - class AssetDumperWeapon final : public AbstractFileDumper + class AssetDumperWeapon final : public AbstractAssetDumper { + static constexpr const char* FILE_TYPE_STR = "WEAPONFILE"; + static constexpr const char* GDF_NAME = "weapon.gdf"; static cspField_t weapon_fields[]; static void CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFullDef* fullDef); + static InfoString CreateInfoString(XAssetInfo* asset); protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + bool CanDumpAsGdtEntry() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperFontIcon.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperFontIcon.cpp index e17fcba1..2e126213 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperFontIcon.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperFontIcon.cpp @@ -260,12 +260,17 @@ bool AssetDumperFontIcon::ShouldDump(XAssetInfo* asset) return true; } +bool AssetDumperFontIcon::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperFontIcon::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return asset->m_name; } -void AssetDumperFontIcon::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperFontIcon::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { AssetDumperFontIconInternal dumper(stream); dumper.DumpFontIcon(asset->Asset()); diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperFontIcon.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperFontIcon.h index 48c30922..05deaa99 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperFontIcon.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperFontIcon.h @@ -1,15 +1,17 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" namespace T6 { - class AssetDumperFontIcon final : public AbstractFileDumper + class AssetDumperFontIcon final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.cpp index 0a74a3b2..6bca064e 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.cpp @@ -13,10 +13,10 @@ AssetDumperGfxImage::AssetDumperGfxImage() switch (ObjWriting::Configuration.ImageOutputFormat) { case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: - m_writer = new DdsWriter(); + m_writer = std::make_unique(); break; case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: - m_writer = new iwi27::IwiWriter(); + m_writer = std::make_unique(); break; default: assert(false); @@ -25,24 +25,23 @@ AssetDumperGfxImage::AssetDumperGfxImage() } } -AssetDumperGfxImage::~AssetDumperGfxImage() -{ - delete m_writer; - m_writer = nullptr; -} - bool AssetDumperGfxImage::ShouldDump(XAssetInfo* asset) { const auto* image = asset->Asset(); return image->loadedSize > 0; } +bool AssetDumperGfxImage::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperGfxImage::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return "images/" + asset->m_name + m_writer->GetFileExtension(); } -void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperGfxImage::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* image = asset->Asset(); m_writer->DumpImage(stream, image->texture.texture); diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.h index 3256d4b6..b7458595 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.h @@ -1,27 +1,24 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include + +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" #include "Image/IImageWriter.h" namespace T6 { - class AssetDumperGfxImage final : public AbstractFileDumper + class AssetDumperGfxImage final : public AbstractAssetDumper { - IImageWriter* m_writer; + std::unique_ptr m_writer; protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; public: AssetDumperGfxImage(); - ~AssetDumperGfxImage() override; - - AssetDumperGfxImage(const AssetDumperGfxImage& other) = delete; - AssetDumperGfxImage(AssetDumperGfxImage&& other) noexcept = delete; - AssetDumperGfxImage& operator=(const AssetDumperGfxImage& other) = delete; - AssetDumperGfxImage& operator=(AssetDumperGfxImage&& other) noexcept = delete; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLocalizeEntry.h index f21b8a4e..06d7cfe2 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLocalizeEntry.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLocalizeEntry.h @@ -1,6 +1,6 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" namespace T6 diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.cpp index 15d97965..2a797c69 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.cpp @@ -129,30 +129,54 @@ namespace T6 }; } +InfoString AssetDumperPhysConstraints::CreateInfoString(XAssetInfo* asset) +{ + assert(asset->Asset()->count <= 4); + + InfoStringFromPhysConstraintsConverter converter(asset->Asset(), phys_constraints_fields, std::extent::value, [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]; + }); + + return converter.Convert(); +} + bool AssetDumperPhysConstraints::ShouldDump(XAssetInfo* asset) { return true; } +bool AssetDumperPhysConstraints::CanDumpAsRaw() +{ + return true; +} + +bool AssetDumperPhysConstraints::CanDumpAsGdtEntry() +{ + return true; +} + std::string AssetDumperPhysConstraints::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return "physconstraints/" + asset->m_name; } -void AssetDumperPhysConstraints::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +GdtEntry AssetDumperPhysConstraints::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) { - assert(asset->Asset()->count <= 4); + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, GDF_NAME); + infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry); - InfoStringFromPhysConstraintsConverter converter(asset->Asset(), phys_constraints_fields, std::extent::value, [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("PHYSCONSTRAINTS"); - stream.write(stringValue.c_str(), stringValue.size()); + return gdtEntry; } + +void AssetDumperPhysConstraints::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +{ + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(FILE_TYPE_STR); + stream.write(stringValue.c_str(), stringValue.size()); +} \ No newline at end of file diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.h index 605fd232..5f8e4a0d 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.h @@ -1,17 +1,26 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" +#include "Utils/InfoString.h" namespace T6 { - class AssetDumperPhysConstraints final : public AbstractFileDumper + class AssetDumperPhysConstraints final : public AbstractAssetDumper { + static constexpr const char* FILE_TYPE_STR = "PHYSCONSTRAINTS"; + static constexpr const char* GDF_NAME = "physconstraints.gdf"; static cspField_t phys_constraints_fields[]; + static InfoString CreateInfoString(XAssetInfo* asset); + protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + bool CanDumpAsGdtEntry() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp index 0a9dd8c7..fecac197 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp @@ -77,17 +77,7 @@ void AssetDumperPhysPreset::CopyToPhysPresetInfo(const PhysPreset* physPreset, P 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(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +InfoString AssetDumperPhysPreset::CreateInfoString(XAssetInfo* asset) { auto* physPresetInfo = new PhysPresetInfo; CopyToPhysPresetInfo(asset->Asset(), physPresetInfo); @@ -101,27 +91,41 @@ void AssetDumperPhysPreset::DumpAsset(AssetDumpingContext& context, XAssetInfo

m_zone->m_script_strings[scrStr]; }); - const auto infoString = converter.Convert(); - const auto stringValue = infoString.ToString("PHYSIC"); - stream.write(stringValue.c_str(), stringValue.size()); - - delete physPresetInfo; + return converter.Convert(); } -//void AssetDumperPhysPreset::CheckFields() -//{ -// assert(std::extent::value == std::extent::value); -// -// for(auto i = 0u; i < std::extent::value; 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 +bool AssetDumperPhysPreset::ShouldDump(XAssetInfo* asset) +{ + return true; +} + +bool AssetDumperPhysPreset::CanDumpAsRaw() +{ + return true; +} + +bool AssetDumperPhysPreset::CanDumpAsGdtEntry() +{ + return true; +} + +std::string AssetDumperPhysPreset::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) +{ + return "physic/" + asset->m_name; +} + +GdtEntry AssetDumperPhysPreset::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) +{ + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, GDF_NAME); + infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry); + + return gdtEntry; +} + +void AssetDumperPhysPreset::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +{ + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(FILE_TYPE_STR); + stream.write(stringValue.c_str(), stringValue.size()); +} \ No newline at end of file diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.h index af846de0..641b1ba6 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.h @@ -1,19 +1,27 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" +#include "Utils/InfoString.h" namespace T6 { - class AssetDumperPhysPreset final : public AbstractFileDumper + class AssetDumperPhysPreset final : public AbstractAssetDumper { + static constexpr const char* FILE_TYPE_STR = "PHYSIC"; + static constexpr const char* GDF_NAME = "physpreset.gdf"; static cspField_t physpreset_fields[]; static void CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo); + static InfoString CreateInfoString(XAssetInfo* asset); protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + bool CanDumpAsGdtEntry() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.cpp index 649cee81..129f5d8c 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.cpp @@ -7,12 +7,17 @@ bool AssetDumperQdb::ShouldDump(XAssetInfo* asset) return true; } +bool AssetDumperQdb::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperQdb::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return asset->m_name; } -void AssetDumperQdb::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperQdb::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* qdb = asset->Asset(); stream.write(qdb->buffer, qdb->len); diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.h index 92ed1219..2e6387da 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.h @@ -1,15 +1,17 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" namespace T6 { - class AssetDumperQdb final : public AbstractFileDumper + class AssetDumperQdb final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.cpp index 1460d82a..4a9af1fb 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.cpp @@ -7,12 +7,17 @@ bool AssetDumperRawFile::ShouldDump(XAssetInfo* asset) return true; } +bool AssetDumperRawFile::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperRawFile::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return asset->m_name; } -void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperRawFile::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* rawFile = asset->Asset(); stream.write(rawFile->buffer, rawFile->len); diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.h index 944c1610..82ccd7b7 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.h @@ -1,15 +1,17 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" namespace T6 { - class AssetDumperRawFile final : public AbstractFileDumper + class AssetDumperRawFile final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.cpp index ecd81d43..b9e4db57 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.cpp @@ -7,12 +7,17 @@ bool AssetDumperScriptParseTree::ShouldDump(XAssetInfo* asset) return true; } +bool AssetDumperScriptParseTree::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperScriptParseTree::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return asset->m_name; } -void AssetDumperScriptParseTree::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperScriptParseTree::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* scriptParseTree = asset->Asset(); stream.write(scriptParseTree->buffer, scriptParseTree->len); diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.h index 892760d0..ffb333b4 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.h @@ -1,15 +1,17 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" namespace T6 { - class AssetDumperScriptParseTree final : public AbstractFileDumper + class AssetDumperScriptParseTree final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.cpp index 3a26cd0a..0d2d94e8 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.cpp @@ -7,12 +7,17 @@ bool AssetDumperSlug::ShouldDump(XAssetInfo* asset) return true; } +bool AssetDumperSlug::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperSlug::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return asset->m_name; } -void AssetDumperSlug::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperSlug::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* slug = asset->Asset(); stream.write(slug->buffer, slug->len); diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.h index f07b8815..4dc62ef0 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.h @@ -1,15 +1,17 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" namespace T6 { - class AssetDumperSlug final : public AbstractFileDumper + class AssetDumperSlug final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.cpp index 7fd0dac7..ee1378c6 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.cpp @@ -9,12 +9,17 @@ bool AssetDumperStringTable::ShouldDump(XAssetInfo* asset) return true; } +bool AssetDumperStringTable::CanDumpAsRaw() +{ + return true; +} + std::string AssetDumperStringTable::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return asset->m_name; } -void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +void AssetDumperStringTable::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) { const auto* stringTable = asset->Asset(); CsvWriter csv(stream); diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.h index 91d561d4..4efd369c 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.h @@ -1,15 +1,17 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" namespace T6 { - class AssetDumperStringTable final : public AbstractFileDumper + class AssetDumperStringTable final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp index 602a130d..d75320a1 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp @@ -76,17 +76,7 @@ namespace T6 }; } -bool AssetDumperTracer::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -std::string AssetDumperTracer::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) -{ - return "tracer/" + asset->m_name; -} - -void AssetDumperTracer::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +InfoString AssetDumperTracer::CreateInfoString(XAssetInfo* asset) { InfoStringFromTracerConverter converter(asset->Asset(), tracer_fields, std::extent::value, [asset](const scr_string_t scrStr) -> std::string { @@ -97,7 +87,41 @@ void AssetDumperTracer::DumpAsset(AssetDumpingContext& context, XAssetInfom_zone->m_script_strings[scrStr]; }); - const auto infoString = converter.Convert(); + return converter.Convert(); +} + +bool AssetDumperTracer::ShouldDump(XAssetInfo* asset) +{ + return true; +} + +bool AssetDumperTracer::CanDumpAsRaw() +{ + return true; +} + +bool AssetDumperTracer::CanDumpAsGdtEntry() +{ + return true; +} + +std::string AssetDumperTracer::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) +{ + return "tracer/" + asset->m_name; +} + +GdtEntry AssetDumperTracer::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) +{ + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, GDF_NAME); + infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry); + + return gdtEntry; +} + +void AssetDumperTracer::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +{ + const auto infoString = CreateInfoString(asset); const auto stringValue = infoString.ToString("TRACER"); stream.write(stringValue.c_str(), stringValue.size()); } \ No newline at end of file diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.h index 72e15096..34839337 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.h @@ -1,17 +1,26 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" +#include "Utils/InfoString.h" namespace T6 { - class AssetDumperTracer final : public AbstractFileDumper + class AssetDumperTracer final : public AbstractAssetDumper { + static constexpr const char* FILE_TYPE_STR = "TRACER"; + static constexpr const char* GDF_NAME = "tracer.gdf"; static cspField_t tracer_fields[]; + static InfoString CreateInfoString(XAssetInfo* asset); + protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + bool CanDumpAsGdtEntry() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.cpp index 11318ada..edefb2bc 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.cpp @@ -671,28 +671,52 @@ namespace T6 }; } +InfoString AssetDumperVehicle::CreateInfoString(XAssetInfo* asset) +{ + InfoStringFromVehicleConverter converter(asset->Asset(), vehicle_fields, std::extent::value, [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]; + }); + + return converter.Convert(); +} + bool AssetDumperVehicle::ShouldDump(XAssetInfo* asset) { return true; } +bool AssetDumperVehicle::CanDumpAsRaw() +{ + return true; +} + +bool AssetDumperVehicle::CanDumpAsGdtEntry() +{ + return true; +} + std::string AssetDumperVehicle::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return "vehicles/" + asset->m_name; } -void AssetDumperVehicle::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +GdtEntry AssetDumperVehicle::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) { - InfoStringFromVehicleConverter converter(asset->Asset(), vehicle_fields, std::extent::value, [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 ""; + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, GDF_NAME); + infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry); - return asset->m_zone->m_script_strings[scrStr]; - }); + return gdtEntry; +} - const auto infoString = converter.Convert(); - const auto stringValue = infoString.ToString("VEHICLEFILE"); +void AssetDumperVehicle::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +{ + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(FILE_TYPE_STR); stream.write(stringValue.c_str(), stringValue.size()); } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.h index f27fd20b..279771c9 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.h @@ -1,17 +1,26 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" +#include "Utils/InfoString.h" namespace T6 { - class AssetDumperVehicle final : public AbstractFileDumper + class AssetDumperVehicle final : public AbstractAssetDumper { + static constexpr const char* FILE_TYPE_STR = "VEHICLEFILE"; + static constexpr const char* GDF_NAME = "vehicle.gdf"; static cspField_t vehicle_fields[]; + static InfoString CreateInfoString(XAssetInfo* asset); + protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + bool CanDumpAsGdtEntry() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp index b6f05c05..23596948 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp @@ -1502,7 +1502,7 @@ namespace T6 }; } -void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFullDef* fullDef) const +void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFullDef* fullDef) { fullDef->weapVariantDef = *weapon; @@ -1623,34 +1623,56 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull } } +InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo* asset) +{ + auto* fullDef = new WeaponFullDef; + memset(fullDef, 0, sizeof(WeaponFullDef)); + CopyToFullDef(asset->Asset(), fullDef); + + InfoStringFromWeaponConverter converter(fullDef, weapon_fields, std::extent::value, [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]; + }); + + return converter.Convert(); +} + bool AssetDumperWeapon::ShouldDump(XAssetInfo* asset) { return true; } +bool AssetDumperWeapon::CanDumpAsRaw() +{ + return true; +} + +bool AssetDumperWeapon::CanDumpAsGdtEntry() +{ + return true; +} + std::string AssetDumperWeapon::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return "weapons/" + asset->m_name; } -void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +GdtEntry AssetDumperWeapon::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) { - auto* fullDef = new WeaponFullDef; - memset(fullDef, 0, sizeof(WeaponFullDef)); - CopyToFullDef(asset->Asset(), fullDef); + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, GDF_NAME); + infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry); - InfoStringFromWeaponConverter converter(fullDef, weapon_fields, std::extent::value, [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("WEAPONFILE"); - stream.write(stringValue.c_str(), stringValue.size()); - - delete fullDef; + return gdtEntry; +} + +void AssetDumperWeapon::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +{ + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(FILE_TYPE_STR); + stream.write(stringValue.c_str(), stringValue.size()); } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.h index 64c6a9bb..1b043f4f 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.h @@ -1,19 +1,27 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" +#include "Utils/InfoString.h" namespace T6 { - class AssetDumperWeapon final : public AbstractFileDumper + class AssetDumperWeapon final : public AbstractAssetDumper { + static constexpr const char* FILE_TYPE_STR = "WEAPONFILE"; + static constexpr const char* GDF_NAME = "weapon.gdf"; static cspField_t weapon_fields[]; - void CopyToFullDef(const WeaponVariantDef* weapon, WeaponFullDef* fullDef) const; + static void CopyToFullDef(const WeaponVariantDef* weapon, WeaponFullDef* fullDef); + static InfoString CreateInfoString(XAssetInfo* asset); protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + bool CanDumpAsGdtEntry() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; } diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp index bad3866f..3daecdd2 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp @@ -9,151 +9,151 @@ 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 }, + {"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 @@ -174,46 +174,52 @@ namespace T6 }; } +InfoString AssetDumperZBarrier::CreateInfoString(XAssetInfo* asset) +{ + InfoStringFromZBarrierConverter converter(asset->Asset(), zbarrier_fields, std::extent::value, [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]; + }); + + return converter.Convert(); +} + bool AssetDumperZBarrier::ShouldDump(XAssetInfo* asset) { return true; } +bool AssetDumperZBarrier::CanDumpAsRaw() +{ + return true; +} + +bool AssetDumperZBarrier::CanDumpAsGdtEntry() +{ + return true; +} + std::string AssetDumperZBarrier::GetFileNameForAsset(Zone* zone, XAssetInfo* asset) { return "zbarrier/" + asset->m_name; } -void AssetDumperZBarrier::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +GdtEntry AssetDumperZBarrier::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) { - InfoStringFromZBarrierConverter converter(asset->Asset(), zbarrier_fields, std::extent::value, [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 ""; + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, GDF_NAME); + infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry); - return asset->m_zone->m_script_strings[scrStr]; - }); - - const auto infoString = converter.Convert(); - const auto stringValue = infoString.ToString("ZBARRIER"); - stream.write(stringValue.c_str(), stringValue.size()); + return gdtEntry; } -//void AssetDumperZBarrier::CheckFields() -//{ -// assert(std::extent::value == std::extent::value); -// -// for(auto i = 0u; i < std::extent::value; 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 +void AssetDumperZBarrier::DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) +{ + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(FILE_TYPE_STR); + stream.write(stringValue.c_str(), stringValue.size()); +} diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.h index 81fb2aa2..a8a2505f 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.h @@ -1,17 +1,26 @@ #pragma once -#include "Dumping/AbstractFileDumper.h" +#include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" +#include "Utils/InfoString.h" namespace T6 { - class AssetDumperZBarrier final : public AbstractFileDumper + class AssetDumperZBarrier final : public AbstractAssetDumper { + static constexpr const char* FILE_TYPE_STR = "ZBARRIER"; + static constexpr const char* GDF_NAME = "zbarrier.gdf"; static cspField_t zbarrier_fields[]; + static InfoString CreateInfoString(XAssetInfo* asset); + protected: bool ShouldDump(XAssetInfo* asset) override; + bool CanDumpAsRaw() override; + bool CanDumpAsGdtEntry() override; + std::string GetFileNameForAsset(Zone* zone, XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; + GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo* asset) override; + void DumpRaw(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) override; }; }