mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Merge pull request #49 from diamante0018/iw5/dump-scriptfile
feat: dump scriptfiles to gsc bin (gsc-tool) format
This commit is contained in:
commit
f7eb5182c5
@ -10,25 +10,6 @@ bool AssetDumperRawFile::ShouldDump(XAssetInfo<RawFile>* asset)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AssetDumperRawFile::GetAssetFileName(XAssetInfo<GfxImage>* asset)
|
|
||||||
{
|
|
||||||
std::string cleanAssetName = asset->m_name;
|
|
||||||
for (auto& c : cleanAssetName)
|
|
||||||
{
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case '*':
|
|
||||||
c = '_';
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cleanAssetName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset)
|
void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset)
|
||||||
{
|
{
|
||||||
const auto* rawFile = asset->Asset();
|
const auto* rawFile = asset->Asset();
|
||||||
@ -68,7 +49,7 @@ void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawF
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
printf("Inflate failed for dumping rawfile '%s'\n", rawFile->name);
|
std::cerr << "Inflate failed when attempting to dump rawfile " << rawFile->name << std::endl;
|
||||||
inflateEnd(&zs);
|
inflateEnd(&zs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@ namespace IW5
|
|||||||
{
|
{
|
||||||
class AssetDumperRawFile final : public AbstractAssetDumper<RawFile>
|
class AssetDumperRawFile final : public AbstractAssetDumper<RawFile>
|
||||||
{
|
{
|
||||||
static std::string GetAssetFileName(XAssetInfo<GfxImage>* asset);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool ShouldDump(XAssetInfo<RawFile>* asset) override;
|
bool ShouldDump(XAssetInfo<RawFile>* asset) override;
|
||||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset) override;
|
void DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset) override;
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
#include "AssetDumperScriptFile.h"
|
||||||
|
|
||||||
|
using namespace IW5;
|
||||||
|
|
||||||
|
bool AssetDumperScriptFile::ShouldDump(XAssetInfo<ScriptFile>* asset)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// See https://github.com/xensik/gsc-tool#file-format for an in-depth explanation about the .gscbin format
|
||||||
|
void AssetDumperScriptFile::DumpAsset(AssetDumpingContext& context, XAssetInfo<ScriptFile>* asset)
|
||||||
|
{
|
||||||
|
auto* scriptFile = asset->Asset();
|
||||||
|
const auto assetFile = context.OpenAssetFile(asset->m_name + ".gscbin");
|
||||||
|
|
||||||
|
if (!assetFile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto& stream = *assetFile;
|
||||||
|
|
||||||
|
// Dump the name and the numeric fields
|
||||||
|
stream.write(asset->m_name.c_str(), asset->m_name.size() + 1);
|
||||||
|
stream.write(reinterpret_cast<char*>(&scriptFile->compressedLen), sizeof(scriptFile->compressedLen));
|
||||||
|
stream.write(reinterpret_cast<char*>(&scriptFile->len), sizeof(scriptFile->len));
|
||||||
|
stream.write(reinterpret_cast<char*>(&scriptFile->bytecodeLen), sizeof(scriptFile->bytecodeLen));
|
||||||
|
|
||||||
|
// Dump the buffers
|
||||||
|
stream.write(scriptFile->buffer, scriptFile->compressedLen);
|
||||||
|
stream.write(reinterpret_cast<char*>(scriptFile->bytecode), scriptFile->bytecodeLen);
|
||||||
|
}
|
14
src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperScriptFile.h
Normal file
14
src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperScriptFile.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Dumping/AbstractAssetDumper.h"
|
||||||
|
#include "Game/IW5/IW5.h"
|
||||||
|
|
||||||
|
namespace IW5
|
||||||
|
{
|
||||||
|
class AssetDumperScriptFile final : public AbstractAssetDumper<ScriptFile>
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
bool ShouldDump(XAssetInfo<ScriptFile>* asset) override;
|
||||||
|
void DumpAsset(AssetDumpingContext& context, XAssetInfo<ScriptFile>* asset) override;
|
||||||
|
};
|
||||||
|
} // namespace IW5
|
@ -7,6 +7,7 @@
|
|||||||
#include "AssetDumpers/AssetDumperMenuDef.h"
|
#include "AssetDumpers/AssetDumperMenuDef.h"
|
||||||
#include "AssetDumpers/AssetDumperMenuList.h"
|
#include "AssetDumpers/AssetDumperMenuList.h"
|
||||||
#include "AssetDumpers/AssetDumperRawFile.h"
|
#include "AssetDumpers/AssetDumperRawFile.h"
|
||||||
|
#include "AssetDumpers/AssetDumperScriptFile.h"
|
||||||
#include "AssetDumpers/AssetDumperStringTable.h"
|
#include "AssetDumpers/AssetDumperStringTable.h"
|
||||||
#include "AssetDumpers/AssetDumperXModel.h"
|
#include "AssetDumpers/AssetDumperXModel.h"
|
||||||
#include "Game/IW5/GameAssetPoolIW5.h"
|
#include "Game/IW5/GameAssetPoolIW5.h"
|
||||||
@ -63,7 +64,7 @@ bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
|||||||
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX)
|
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX)
|
||||||
// DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table, ASSET_TYPE_SURFACE_FX)
|
// DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table, ASSET_TYPE_SURFACE_FX)
|
||||||
DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE)
|
DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE)
|
||||||
// DUMP_ASSET_POOL(AssetDumperScriptFile, m_script_file, ASSET_TYPE_SCRIPTFILE)
|
DUMP_ASSET_POOL(AssetDumperScriptFile, m_script_file, ASSET_TYPE_SCRIPTFILE)
|
||||||
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
|
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
|
||||||
// DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD)
|
// DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD)
|
||||||
// DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
|
// DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user