[ITracer] Add tracer writing support

This commit is contained in:
TheApadayo 2019-01-15 21:48:34 -05:00
parent 8d4fa4c7ac
commit 59ef8edbe2
6 changed files with 67 additions and 12 deletions

View File

@ -576,8 +576,9 @@ namespace Components
AssetHandler::RegisterInterface(new Assets::ISndCurve()); AssetHandler::RegisterInterface(new Assets::ISndCurve());
AssetHandler::RegisterInterface(new Assets::IMaterial()); AssetHandler::RegisterInterface(new Assets::IMaterial());
AssetHandler::RegisterInterface(new Assets::IMenuList()); AssetHandler::RegisterInterface(new Assets::IMenuList());
AssetHandler::RegisterInterface(new Assets::ImenuDef_t());
AssetHandler::RegisterInterface(new Assets::IclipMap_t()); AssetHandler::RegisterInterface(new Assets::IclipMap_t());
AssetHandler::RegisterInterface(new Assets::ImenuDef_t());
AssetHandler::RegisterInterface(new Assets::ITracerDef());
AssetHandler::RegisterInterface(new Assets::IPhysPreset()); AssetHandler::RegisterInterface(new Assets::IPhysPreset());
AssetHandler::RegisterInterface(new Assets::IXAnimParts()); AssetHandler::RegisterInterface(new Assets::IXAnimParts());
AssetHandler::RegisterInterface(new Assets::IFxEffectDef()); AssetHandler::RegisterInterface(new Assets::IFxEffectDef());

View File

@ -91,8 +91,9 @@ namespace Components
#include "AssetInterfaces/IMaterial.hpp" #include "AssetInterfaces/IMaterial.hpp"
#include "AssetInterfaces/ISndCurve.hpp" #include "AssetInterfaces/ISndCurve.hpp"
#include "AssetInterfaces/IMenuList.hpp" #include "AssetInterfaces/IMenuList.hpp"
#include "AssetInterfaces/ImenuDef_t.hpp"
#include "AssetInterfaces/IclipMap_t.hpp" #include "AssetInterfaces/IclipMap_t.hpp"
#include "AssetInterfaces/ImenuDef_t.hpp"
#include "AssetInterfaces/ITracerDef.hpp"
#include "AssetInterfaces/IPhysPreset.hpp" #include "AssetInterfaces/IPhysPreset.hpp"
#include "AssetInterfaces/IXAnimParts.hpp" #include "AssetInterfaces/IXAnimParts.hpp"
#include "AssetInterfaces/IFxEffectDef.hpp" #include "AssetInterfaces/IFxEffectDef.hpp"

View File

@ -0,0 +1,44 @@
#include "STDInclude.hpp"
namespace Assets
{
void ITracerDef::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{
return; // don't load from filesystem right now
}
void ITracerDef::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{
Game::TracerDef* asset = header.tracerDef;
if (asset->material)
{
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->material);
}
}
void ITracerDef::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{
AssertSize(Game::TracerDef, 0x70);
Utils::Stream* buffer = builder->getBuffer();
Game::TracerDef* asset = header.tracerDef;
Game::TracerDef* dest = buffer->dest<Game::TracerDef>();
buffer->save(asset);
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
if (asset->name)
{
buffer->saveString(builder->getAssetName(this->getType(), asset->name));
Utils::Stream::ClearPointer(&dest->name);
}
if (asset->material)
{
dest->material = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->material).material;
}
buffer->popBlock();
}
}

View File

@ -0,0 +1,14 @@
#pragma once
namespace Assets
{
class ITracerDef : public Components::AssetHandler::IAsset
{
public:
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_TRACER; };
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
};
}

View File

@ -1,7 +1,5 @@
#include "STDInclude.hpp" #include "STDInclude.hpp"
#define IW4X_MODEL_VERSION 5
namespace Assets namespace Assets
{ {
void IWeapon::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) void IWeapon::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
@ -12,12 +10,8 @@ namespace Assets
// let the function see temporary assets when calling DB_FindXAssetHeader during the loading function // let the function see temporary assets when calling DB_FindXAssetHeader during the loading function
// otherwise it fails to link things properly // otherwise it fails to link things properly
Components::AssetHandler::ExposeTemporaryAssets(true); Components::AssetHandler::ExposeTemporaryAssets(true);
IWeapon::CurrentBuilder = builder;
header->data = Game::BG_LoadWeaponDef_LoadObj(name.data()); header->data = Game::BG_LoadWeaponDef_LoadObj(name.data());
Components::AssetHandler::ExposeTemporaryAssets(false); Components::AssetHandler::ExposeTemporaryAssets(false);
IWeapon::CurrentBuilder = nullptr;
} }
} }
@ -116,8 +110,7 @@ namespace Assets
if (asset->weapDef->tracerType) if (asset->weapDef->tracerType)
{ {
//builder->loadAsset(Game::XAssetType::ASSET_TYPE_TRACER, asset->weapDef->tracerType); builder->loadAsset(Game::XAssetType::ASSET_TYPE_TRACER, asset->weapDef->tracerType);
asset->weapDef->tracerType = NULL;
} }
// don't write effects for now // don't write effects for now
@ -271,6 +264,7 @@ namespace Assets
Game::snd_alias_list_t ** allSoundsDest = &dest->pickupSound; Game::snd_alias_list_t ** allSoundsDest = &dest->pickupSound;
for (int i = 0; i < 47; i++) { for (int i = 0; i < 47; i++) {
if (!allSounds[i]) continue; if (!allSounds[i]) continue;
buffer->align(Utils::Stream::ALIGN_4);
buffer->saveMax(sizeof(Game::snd_alias_list_t*)); buffer->saveMax(sizeof(Game::snd_alias_list_t*));
buffer->saveString(allSounds[i]->aliasName); buffer->saveString(allSounds[i]->aliasName);
Utils::Stream::ClearPointer(&allSoundsDest[i]); Utils::Stream::ClearPointer(&allSoundsDest[i]);
@ -314,6 +308,7 @@ namespace Assets
if (def->worldModel) if (def->worldModel)
{ {
buffer->align(Utils::Stream::ALIGN_4);
Game::XModel** pointerTable = buffer->dest<Game::XModel*>(); Game::XModel** pointerTable = buffer->dest<Game::XModel*>();
buffer->saveMax(16 * sizeof(Game::XModel*)); buffer->saveMax(16 * sizeof(Game::XModel*));
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)

View File

@ -1110,7 +1110,7 @@ namespace Components
Command::Add("verifyzone", [](Command::Params* params) Command::Add("verifyzone", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->length() < 2) return;
/*
Utils::Hook(0x4AE9C2, [] { Utils::Hook(0x4AE9C2, [] {
Game::WeaponCompleteDef** varPtr = (Game::WeaponCompleteDef**)0x112A9F4; Game::WeaponCompleteDef** varPtr = (Game::WeaponCompleteDef**)0x112A9F4;
Game::WeaponCompleteDef* var = *varPtr; Game::WeaponCompleteDef* var = *varPtr;
@ -1125,7 +1125,7 @@ namespace Components
OutputDebugStringA(""); OutputDebugStringA("");
Utils::Hook::Call<void()>(0x4D1D60)(); // DB_PopStreamPos Utils::Hook::Call<void()>(0x4D1D60)(); // DB_PopStreamPos
}, HOOK_JUMP).install()->quick(); }, HOOK_JUMP).install()->quick();
*/
std::string zone = params->get(1); std::string zone = params->get(1);