mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
IW5 support initial commit
This commit is contained in:
@ -0,0 +1,27 @@
|
||||
#define NOMINMAX
|
||||
#include "AssetDumperAddonMapEnts.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
bool AssetDumperAddonMapEnts::ShouldDump(XAssetInfo<AddonMapEnts>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperAddonMapEnts::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperAddonMapEnts::GetFileNameForAsset(Zone* zone, XAssetInfo<AddonMapEnts>* asset)
|
||||
{
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperAddonMapEnts::DumpRaw(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* addonMapEnts = asset->Asset();
|
||||
stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0));
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetDumperAddonMapEnts final : public AbstractAssetDumper<AddonMapEnts>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<AddonMapEnts>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<AddonMapEnts>* asset) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
62
src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperGfxImage.cpp
Normal file
62
src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperGfxImage.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include "AssetDumperGfxImage.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "ObjWriting.h"
|
||||
#include "Image/IwiWriter8.h"
|
||||
#include "Image/DdsWriter.h"
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
AssetDumperGfxImage::AssetDumperGfxImage()
|
||||
{
|
||||
switch (ObjWriting::Configuration.ImageOutputFormat)
|
||||
{
|
||||
case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS:
|
||||
m_writer = std::make_unique<DdsWriter>();
|
||||
break;
|
||||
case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI:
|
||||
m_writer = std::make_unique<iwi8::IwiWriter>();
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
m_writer = nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool AssetDumperGfxImage::ShouldDump(XAssetInfo<GfxImage>* asset)
|
||||
{
|
||||
const auto* image = asset->Asset();
|
||||
return image->cardMemory.platform[0] > 0;
|
||||
}
|
||||
|
||||
bool AssetDumperGfxImage::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperGfxImage::GetFileNameForAsset(Zone* zone, XAssetInfo<GfxImage>* asset)
|
||||
{
|
||||
std::string cleanAssetName = asset->m_name;
|
||||
for (auto& c : cleanAssetName)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '*':
|
||||
c = '_';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return "images/" + cleanAssetName + m_writer->GetFileExtension();
|
||||
}
|
||||
|
||||
void AssetDumperGfxImage::DumpRaw(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* image = asset->Asset();
|
||||
m_writer->DumpImage(stream, image->texture.texture);
|
||||
}
|
24
src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperGfxImage.h
Normal file
24
src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperGfxImage.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Image/IImageWriter.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetDumperGfxImage final : public AbstractAssetDumper<GfxImage>
|
||||
{
|
||||
std::unique_ptr<IImageWriter> m_writer;
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<GfxImage>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<GfxImage>* asset) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream) override;
|
||||
|
||||
public:
|
||||
AssetDumperGfxImage();
|
||||
};
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
#include "AssetDumperLoadedSound.h"
|
||||
|
||||
#include "Sound/WavTypes.h"
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
bool AssetDumperLoadedSound::ShouldDump(XAssetInfo<LoadedSound>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperLoadedSound::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperLoadedSound::GetFileNameForAsset(Zone* zone, XAssetInfo<LoadedSound>* asset)
|
||||
{
|
||||
return "sound/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperLoadedSound::DumpWavPcm(AssetDumpingContext& context, const LoadedSound* asset, std::ostream& stream)
|
||||
{
|
||||
const auto riffMasterChunkSize = sizeof(WAV_CHUNK_ID_RIFF)
|
||||
+ sizeof(uint32_t)
|
||||
+ sizeof(WAV_WAVE_ID)
|
||||
+ sizeof(WavChunkHeader)
|
||||
+ sizeof(WavFormatChunkPcm)
|
||||
+ sizeof(WavChunkHeader)
|
||||
+ sizeof(asset->sound.info.data_len);
|
||||
|
||||
stream.write(reinterpret_cast<const char*>(&WAV_CHUNK_ID_RIFF), sizeof(WAV_CHUNK_ID_RIFF));
|
||||
stream.write(reinterpret_cast<const char*>(&riffMasterChunkSize), sizeof(riffMasterChunkSize));
|
||||
stream.write(reinterpret_cast<const char*>(&WAV_WAVE_ID), sizeof(WAV_WAVE_ID));
|
||||
|
||||
const WavChunkHeader formatChunkHeader
|
||||
{
|
||||
WAV_CHUNK_ID_FMT,
|
||||
sizeof(WavFormatChunkPcm)
|
||||
};
|
||||
stream.write(reinterpret_cast<const char*>(&formatChunkHeader), sizeof(formatChunkHeader));
|
||||
|
||||
WavFormatChunkPcm formatChunk
|
||||
{
|
||||
WavFormat::PCM,
|
||||
static_cast<uint16_t>(asset->sound.info.channels),
|
||||
asset->sound.info.rate,
|
||||
asset->sound.info.rate * asset->sound.info.channels * asset->sound.info.bits / 8,
|
||||
static_cast<uint16_t>(asset->sound.info.block_size),
|
||||
static_cast<uint16_t>(asset->sound.info.bits)
|
||||
};
|
||||
stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof(formatChunk));
|
||||
|
||||
const WavChunkHeader dataChunkHeader
|
||||
{
|
||||
WAV_CHUNK_ID_DATA,
|
||||
asset->sound.info.data_len
|
||||
};
|
||||
stream.write(reinterpret_cast<const char*>(&dataChunkHeader), sizeof(dataChunkHeader));
|
||||
stream.write(asset->sound.data, asset->sound.info.data_len);
|
||||
}
|
||||
|
||||
void AssetDumperLoadedSound::DumpRaw(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* loadedSound = asset->Asset();
|
||||
switch (static_cast<WavFormat>(loadedSound->sound.info.format))
|
||||
{
|
||||
case WavFormat::PCM:
|
||||
DumpWavPcm(context, loadedSound, stream);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Unknown format %i for loaded sound: %s\n", loadedSound->sound.info.format, loadedSound->name);
|
||||
break;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetDumperLoadedSound final : public AbstractAssetDumper<LoadedSound>
|
||||
{
|
||||
static void DumpWavPcm(AssetDumpingContext& context, const LoadedSound* asset, std::ostream& stream);
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<LoadedSound>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<LoadedSound>* asset) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
#include "AssetDumperLocalizeEntry.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
#include "Localize/LocalizeCommon.h"
|
||||
#include "Dumping/Localize/StringFileDumper.h"
|
||||
|
||||
using namespace IW5;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
|
||||
{
|
||||
if (pool->m_asset_lookup.empty())
|
||||
return;
|
||||
|
||||
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone->m_language);
|
||||
fs::path stringsPath(context.m_base_path);
|
||||
stringsPath.append(language);
|
||||
stringsPath.append("localizedstrings");
|
||||
|
||||
create_directories(stringsPath);
|
||||
|
||||
auto stringFilePath(stringsPath);
|
||||
stringFilePath.append(context.m_zone->m_name + ".str");
|
||||
|
||||
std::ofstream stringFile(stringFilePath, std::fstream::out | std::ofstream::binary);
|
||||
|
||||
if (stringFile.is_open())
|
||||
{
|
||||
StringFileDumper stringFileDumper(context.m_zone, stringFile);
|
||||
|
||||
stringFileDumper.SetLanguageName(language);
|
||||
|
||||
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
|
||||
stringFileDumper.SetConfigFile(R"(C:\trees\cod3\cod3\bin\StringEd.cfg)");
|
||||
|
||||
stringFileDumper.SetNotes("");
|
||||
|
||||
for (auto* localizeEntry : *pool)
|
||||
{
|
||||
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
|
||||
}
|
||||
|
||||
stringFileDumper.Finalize();
|
||||
|
||||
stringFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Could not create string file for dumping localized strings of zone '%s'\n", context.m_zone->m_name.c_str());
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetDumperLocalizeEntry final : public IAssetDumper<LocalizeEntry>
|
||||
{
|
||||
public:
|
||||
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
|
||||
};
|
||||
}
|
70
src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.cpp
Normal file
70
src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#include "AssetDumperRawFile.h"
|
||||
|
||||
#include <zlib.h>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
bool AssetDumperRawFile::ShouldDump(XAssetInfo<RawFile>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperRawFile::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperRawFile::GetFileNameForAsset(Zone* zone, XAssetInfo<RawFile>* asset)
|
||||
{
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperRawFile::DumpRaw(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* rawFile = asset->Asset();
|
||||
if (rawFile->compressedLen > 0)
|
||||
{
|
||||
z_stream_s zs{};
|
||||
|
||||
zs.zalloc = Z_NULL;
|
||||
zs.zfree = Z_NULL;
|
||||
zs.opaque = Z_NULL;
|
||||
zs.avail_in = 0;
|
||||
zs.next_in = Z_NULL;
|
||||
|
||||
int ret = inflateInit(&zs);
|
||||
|
||||
if (ret != Z_OK)
|
||||
{
|
||||
throw std::runtime_error("Initializing inflate failed");
|
||||
}
|
||||
|
||||
zs.next_in = reinterpret_cast<const Bytef*>(rawFile->data.compressedBuffer);
|
||||
zs.avail_in = rawFile->compressedLen;
|
||||
|
||||
Bytef buffer[0x1000];
|
||||
|
||||
while (zs.avail_in > 0)
|
||||
{
|
||||
zs.next_out = buffer;
|
||||
zs.avail_out = sizeof buffer;
|
||||
ret = inflate(&zs, Z_SYNC_FLUSH);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("Inflate failed for dumping rawfile '%s'\n", rawFile->name);
|
||||
inflateEnd(&zs);
|
||||
return;
|
||||
}
|
||||
|
||||
stream.write(reinterpret_cast<char*>(buffer), sizeof buffer - zs.avail_out);
|
||||
}
|
||||
|
||||
inflateEnd(&zs);
|
||||
}
|
||||
else if (rawFile->len > 0)
|
||||
{
|
||||
stream.write(rawFile->data.buffer, rawFile->len);
|
||||
}
|
||||
}
|
16
src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.h
Normal file
16
src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetDumperRawFile final : public AbstractAssetDumper<RawFile>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<RawFile>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<RawFile>* asset) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#include "AssetDumperStringTable.h"
|
||||
|
||||
#include "Csv/CsvStream.h"
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
bool AssetDumperStringTable::ShouldDump(XAssetInfo<StringTable>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperStringTable::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperStringTable::GetFileNameForAsset(Zone* zone, XAssetInfo<StringTable>* asset)
|
||||
{
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperStringTable::DumpRaw(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* stringTable = asset->Asset();
|
||||
CsvOutputStream csv(stream);
|
||||
|
||||
for (auto row = 0; row < stringTable->rowCount; row++)
|
||||
{
|
||||
for (auto column = 0; column < stringTable->columnCount; column++)
|
||||
{
|
||||
const auto* cell = &stringTable->values[column + row * stringTable->columnCount];
|
||||
csv.WriteColumn(cell->string);
|
||||
}
|
||||
|
||||
csv.NextRow();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetDumperStringTable final : public AbstractAssetDumper<StringTable>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<StringTable>* asset) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
@ -0,0 +1,159 @@
|
||||
#include "InfoStringFromStructConverter.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void InfoStringFromStructConverter::FillFromBaseField(const cspField_t& field)
|
||||
{
|
||||
switch (static_cast<csParseFieldType_t>(field.iFieldType))
|
||||
{
|
||||
case CSPFT_STRING:
|
||||
FillFromString(std::string(field.szName), field.iOffset);
|
||||
break;
|
||||
|
||||
case CSPFT_STRING_MAX_STRING_CHARS:
|
||||
FillFromStringBuffer(std::string(field.szName), field.iOffset, 1024);
|
||||
break;
|
||||
|
||||
case CSPFT_STRING_MAX_QPATH:
|
||||
FillFromStringBuffer(std::string(field.szName), field.iOffset, 64);
|
||||
break;
|
||||
|
||||
case CSPFT_STRING_MAX_OSPATH:
|
||||
FillFromStringBuffer(std::string(field.szName), field.iOffset, 256);
|
||||
break;
|
||||
|
||||
case CSPFT_INT:
|
||||
FillFromInt(std::string(field.szName), field.iOffset);
|
||||
break;
|
||||
|
||||
case CSPFT_QBOOLEAN:
|
||||
FillFromQBoolean(std::string(field.szName), field.iOffset);
|
||||
break;
|
||||
|
||||
case CSPFT_BOOL:
|
||||
FillFromBool(std::string(field.szName), field.iOffset);
|
||||
break;
|
||||
|
||||
case CSPFT_FLOAT:
|
||||
FillFromFloat(std::string(field.szName), field.iOffset);
|
||||
break;
|
||||
|
||||
case CSPFT_MPH_TO_INCHES_PER_SEC:
|
||||
{
|
||||
const auto* num = reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
|
||||
m_info_string.SetValueForKey(std::string(field.szName), std::to_string(*num / 17.6f));
|
||||
break;
|
||||
}
|
||||
|
||||
case CSPFT_MILLISECONDS:
|
||||
FillFromMilliseconds(std::string(field.szName), field.iOffset);
|
||||
break;
|
||||
|
||||
case CSPFT_FX:
|
||||
{
|
||||
const auto* fx = *reinterpret_cast<FxEffectDef**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
|
||||
|
||||
if (fx)
|
||||
m_info_string.SetValueForKey(std::string(field.szName), std::string(AssetName(fx->name)));
|
||||
else
|
||||
m_info_string.SetValueForKey(std::string(field.szName), "");
|
||||
break;
|
||||
}
|
||||
|
||||
case CSPFT_XMODEL:
|
||||
{
|
||||
const auto* model = *reinterpret_cast<XModel**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
|
||||
|
||||
if (model)
|
||||
m_info_string.SetValueForKey(std::string(field.szName), std::string(AssetName(model->name)));
|
||||
else
|
||||
m_info_string.SetValueForKey(std::string(field.szName), "");
|
||||
break;
|
||||
}
|
||||
|
||||
case CSPFT_MATERIAL:
|
||||
{
|
||||
const auto* material = *reinterpret_cast<Material**>(reinterpret_cast<uintptr_t>(m_structure) + field.
|
||||
iOffset);
|
||||
|
||||
if (material)
|
||||
m_info_string.SetValueForKey(std::string(field.szName), std::string(AssetName(material->info.name)));
|
||||
else
|
||||
m_info_string.SetValueForKey(std::string(field.szName), "");
|
||||
break;
|
||||
}
|
||||
|
||||
case CSPFT_PHYS_COLLMAP:
|
||||
{
|
||||
const auto* physCollMap = *reinterpret_cast<PhysCollmap**>(reinterpret_cast<uintptr_t>(m_structure) + field.
|
||||
iOffset);
|
||||
|
||||
if (physCollMap)
|
||||
m_info_string.SetValueForKey(std::string(field.szName), std::string(AssetName(physCollMap->name)));
|
||||
else
|
||||
m_info_string.SetValueForKey(std::string(field.szName), "");
|
||||
break;
|
||||
}
|
||||
|
||||
case CSPFT_SOUND:
|
||||
{
|
||||
const auto* sndAlias = reinterpret_cast<SndAliasCustom*>(reinterpret_cast<uintptr_t>(m_structure) + field.
|
||||
iOffset);
|
||||
|
||||
if (sndAlias->name)
|
||||
m_info_string.SetValueForKey(std::string(field.szName), std::string(sndAlias->name->soundName));
|
||||
else
|
||||
m_info_string.SetValueForKey(std::string(field.szName), "");
|
||||
break;
|
||||
}
|
||||
|
||||
case CSPFT_TRACER:
|
||||
{
|
||||
const auto* tracer = *reinterpret_cast<TracerDef**>(reinterpret_cast<uintptr_t>(m_structure) + field.
|
||||
iOffset);
|
||||
|
||||
if (tracer)
|
||||
m_info_string.SetValueForKey(std::string(field.szName), std::string(AssetName(tracer->name)));
|
||||
else
|
||||
m_info_string.SetValueForKey(std::string(field.szName), "");
|
||||
break;
|
||||
}
|
||||
|
||||
case CSPFT_NUM_BASE_FIELD_TYPES:
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InfoStringFromStructConverter::FillInfoString()
|
||||
{
|
||||
for (auto fieldIndex = 0u; fieldIndex < m_field_count; fieldIndex++)
|
||||
{
|
||||
const auto& field = m_fields[fieldIndex];
|
||||
assert(field.iFieldType >= 0);
|
||||
|
||||
if (field.iFieldType < CSPFT_NUM_BASE_FIELD_TYPES)
|
||||
FillFromBaseField(field);
|
||||
else
|
||||
FillFromExtensionField(field);
|
||||
}
|
||||
}
|
||||
|
||||
InfoStringFromStructConverter::InfoStringFromStructConverter(const void* structure, const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringFromStructConverterBase(structure),
|
||||
m_fields(fields),
|
||||
m_field_count(fieldCount)
|
||||
{
|
||||
}
|
||||
|
||||
InfoStringFromStructConverter::InfoStringFromStructConverter(const void* structure, const cspField_t* fields, const size_t fieldCount,
|
||||
std::function<std::string(scr_string_t)> scriptStringValueCallback)
|
||||
: InfoStringFromStructConverterBase(structure, std::move(scriptStringValueCallback)),
|
||||
m_fields(fields),
|
||||
m_field_count(fieldCount)
|
||||
{
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "InfoString/InfoStringFromStructConverterBase.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class InfoStringFromStructConverter : public InfoStringFromStructConverterBase
|
||||
{
|
||||
protected:
|
||||
const cspField_t* m_fields;
|
||||
size_t m_field_count;
|
||||
|
||||
virtual void FillFromExtensionField(const cspField_t& field) = 0;
|
||||
void FillFromBaseField(const cspField_t& field);
|
||||
void FillInfoString() override;
|
||||
|
||||
public:
|
||||
InfoStringFromStructConverter(const void* structure, const cspField_t* fields, size_t fieldCount);
|
||||
InfoStringFromStructConverter(const void* structure, const cspField_t* fields, size_t fieldCount, std::function<std::string(scr_string_t)> scriptStringValueCallback);
|
||||
};
|
||||
}
|
74
src/ObjWriting/Game/IW5/ZoneDumperIW5.cpp
Normal file
74
src/ObjWriting/Game/IW5/ZoneDumperIW5.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
#include "ZoneDumperIW5.h"
|
||||
|
||||
#include "Game/IW5/GameIW5.h"
|
||||
#include "Game/IW5/GameAssetPoolIW5.h"
|
||||
|
||||
#include "AssetDumpers/AssetDumperAddonMapEnts.h"
|
||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||
#include "AssetDumpers/AssetDumperLoadedSound.h"
|
||||
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
||||
#include "AssetDumpers/AssetDumperRawFile.h"
|
||||
#include "AssetDumpers/AssetDumperStringTable.h"
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const
|
||||
{
|
||||
return context.m_zone->m_game == &g_GameIW5;
|
||||
}
|
||||
|
||||
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
||||
{
|
||||
#define DUMP_ASSET_POOL(dumperType, poolName) \
|
||||
if(assetPools->poolName) \
|
||||
{ \
|
||||
dumperType dumper; \
|
||||
dumper.DumpPool(context, assetPools->poolName.get()); \
|
||||
}
|
||||
|
||||
const auto* assetPools = dynamic_cast<GameAssetPoolIW5*>(context.m_zone->m_pools.get());
|
||||
// DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset)
|
||||
// DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap)
|
||||
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts)
|
||||
// DUMP_ASSET_POOL(AssetDumperXModelSurfs, m_xmodel_surfs)
|
||||
// DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel)
|
||||
// DUMP_ASSET_POOL(AssetDumperMaterial, m_material)
|
||||
// DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader)
|
||||
// DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader)
|
||||
// DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl)
|
||||
// DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set)
|
||||
DUMP_ASSET_POOL(AssetDumperGfxImage, m_image)
|
||||
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound)
|
||||
// DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve)
|
||||
DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound)
|
||||
// DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world)
|
||||
// DUMP_ASSET_POOL(AssetDumperGlassWorld, m_glass_world)
|
||||
// DUMP_ASSET_POOL(AssetDumperPathData, m_path_data)
|
||||
// DUMP_ASSET_POOL(AssetDumperVehicleTrack, m_vehicle_track)
|
||||
// DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents)
|
||||
// DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world)
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world)
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def)
|
||||
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font)
|
||||
// DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list)
|
||||
// DUMP_ASSET_POOL(AssetDumpermenuDef_t, m_menu_def)
|
||||
DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize)
|
||||
// DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment)
|
||||
// DUMP_ASSET_POOL(AssetDumperWeaponCompleteDef, m_weapon)
|
||||
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx)
|
||||
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table)
|
||||
// DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table)
|
||||
DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file)
|
||||
// DUMP_ASSET_POOL(AssetDumperScriptFile, m_script_file)
|
||||
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table)
|
||||
// DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard)
|
||||
// DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set)
|
||||
// DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer)
|
||||
// DUMP_ASSET_POOL(AssetDumperVehicleDef, m_vehicle)
|
||||
DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents)
|
||||
|
||||
return true;
|
||||
|
||||
#undef DUMP_ASSET_POOL
|
||||
}
|
12
src/ObjWriting/Game/IW5/ZoneDumperIW5.h
Normal file
12
src/ObjWriting/Game/IW5/ZoneDumperIW5.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "Dumping/IZoneDumper.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class ZoneDumper final : public IZoneDumper
|
||||
{
|
||||
public:
|
||||
bool CanHandleZone(AssetDumpingContext& context) const override;
|
||||
bool DumpZone(AssetDumpingContext& context) const override;
|
||||
};
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
#include "Dumping/IZoneDumper.h"
|
||||
#include "Game/IW3/ZoneDumperIW3.h"
|
||||
#include "Game/IW4/ZoneDumperIW4.h"
|
||||
#include "Game/IW5/ZoneDumperIW5.h"
|
||||
#include "Game/T5/ZoneDumperT5.h"
|
||||
#include "Game/T6/ZoneDumperT6.h"
|
||||
|
||||
@ -11,6 +12,7 @@ const IZoneDumper* const ZONE_DUMPER[]
|
||||
{
|
||||
new IW3::ZoneDumper(),
|
||||
new IW4::ZoneDumper(),
|
||||
new IW5::ZoneDumper(),
|
||||
new T5::ZoneDumper(),
|
||||
new T6::ZoneDumper()
|
||||
};
|
||||
|
Reference in New Issue
Block a user