[ModelSurfs] Skip releasing if buffer is empty
This commit is contained in:
parent
4a4e938b00
commit
3cadc64d13
@ -1,388 +1,388 @@
|
|||||||
#include <STDInclude.hpp>
|
#include <STDInclude.hpp>
|
||||||
|
|
||||||
namespace Assets
|
namespace Assets
|
||||||
{
|
{
|
||||||
void IFxEffectDef::load(Game::XAssetHeader* /*header*/, std::string name, Components::ZoneBuilder::Zone* /*builder*/)
|
void IFxEffectDef::load(Game::XAssetHeader* /*header*/, std::string name, Components::ZoneBuilder::Zone* /*builder*/)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
Components::FileSystem::File rawFx(fmt::sprintf("fx/%s.efx", name.data()));
|
Components::FileSystem::File rawFx(fmt::sprintf("fx/%s.efx", name.data()));
|
||||||
if (rawFx.exists())
|
if (rawFx.exists())
|
||||||
{
|
{
|
||||||
const char* session = rawFx.getBuffer().data();
|
const char* session = rawFx.getBuffer().data();
|
||||||
Game::Com_BeginParseSession("fx");
|
Game::Com_BeginParseSession("fx");
|
||||||
Game::Com_SetSpaceDelimited(0);
|
Game::Com_SetSpaceDelimited(0);
|
||||||
Game::Com_SetParseNegativeNumbers(1);
|
Game::Com_SetParseNegativeNumbers(1);
|
||||||
|
|
||||||
const char* format = Game::Com_Parse(&session);
|
const char* format = Game::Com_Parse(&session);
|
||||||
if (format != "iwfx"s)
|
if (format != "iwfx"s)
|
||||||
{
|
{
|
||||||
Game::Com_EndParseSession();
|
Game::Com_EndParseSession();
|
||||||
Components::Logger::Error("Effect needs to be updated from the legacy format.\n");
|
Components::Logger::Error("Effect needs to be updated from the legacy format.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int version = atoi(Game::Com_Parse(&session));
|
int version = atoi(Game::Com_Parse(&session));
|
||||||
if (version > 2)
|
if (version > 2)
|
||||||
{
|
{
|
||||||
Game::Com_EndParseSession();
|
Game::Com_EndParseSession();
|
||||||
Components::Logger::Error("Version %i is too high. I can only handle up to %i.\n", version, 2);
|
Components::Logger::Error("Version %i is too high. I can only handle up to %i.\n", version, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::FxEditorEffectDef efx;
|
Game::FxEditorEffectDef efx;
|
||||||
ZeroMemory(&efx, sizeof(efx));
|
ZeroMemory(&efx, sizeof(efx));
|
||||||
|
|
||||||
// for (int i = 0; i < FX_ELEM_FIELD_COUNT; ++i)
|
// for (int i = 0; i < FX_ELEM_FIELD_COUNT; ++i)
|
||||||
// {
|
// {
|
||||||
// Game::s_elemFields[i].handler(&session, efx.elems);
|
// Game::s_elemFields[i].handler(&session, efx.elems);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Game::Com_EndParseSession();
|
Game::Com_EndParseSession();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void IFxEffectDef::markFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder)
|
void IFxEffectDef::markFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
switch (elemType)
|
switch (elemType)
|
||||||
{
|
{
|
||||||
case 7:
|
case 7:
|
||||||
{
|
{
|
||||||
if (visuals->xmodel)
|
if (visuals->xmodel)
|
||||||
{
|
{
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
case 9:
|
case 9:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xA:
|
case 0xA:
|
||||||
{
|
{
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_SOUND, std::string(visuals->soundName), false);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_SOUND, std::string(visuals->soundName), false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC:
|
case 0xC:
|
||||||
{
|
{
|
||||||
if (visuals->effectDef)
|
if (visuals->effectDef)
|
||||||
{
|
{
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, visuals->effectDef, false);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, visuals->effectDef, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (visuals->material)
|
if (visuals->material)
|
||||||
{
|
{
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IFxEffectDef::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
void IFxEffectDef::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Game::FxEffectDef* asset = header.fx;
|
Game::FxEffectDef* asset = header.fx;
|
||||||
|
|
||||||
for (int i = 0; i < (asset->elemDefCountEmission + asset->elemDefCountLooping + asset->elemDefCountOneShot); ++i)
|
for (int i = 0; i < (asset->elemDefCountEmission + asset->elemDefCountLooping + asset->elemDefCountOneShot); ++i)
|
||||||
{
|
{
|
||||||
Game::FxElemDef* elemDef = &asset->elemDefs[i];
|
Game::FxElemDef* elemDef = &asset->elemDefs[i];
|
||||||
|
|
||||||
{
|
{
|
||||||
if (elemDef->elemType == 11)
|
if (elemDef->elemType == 11)
|
||||||
{
|
{
|
||||||
if (elemDef->visuals.markArray)
|
if (elemDef->visuals.markArray)
|
||||||
{
|
{
|
||||||
for (char j = 0; j < elemDef->visualCount; ++j)
|
for (char j = 0; j < elemDef->visualCount; ++j)
|
||||||
{
|
{
|
||||||
if (elemDef->visuals.markArray[j].data[0])
|
if (elemDef->visuals.markArray[j].data[0])
|
||||||
{
|
{
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, elemDef->visuals.markArray[j].data[0]);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, elemDef->visuals.markArray[j].data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elemDef->visuals.markArray[j].data[1])
|
if (elemDef->visuals.markArray[j].data[1])
|
||||||
{
|
{
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, elemDef->visuals.markArray[j].data[1]);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, elemDef->visuals.markArray[j].data[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (elemDef->visualCount > 1)
|
else if (elemDef->visualCount > 1)
|
||||||
{
|
{
|
||||||
if (elemDef->visuals.array)
|
if (elemDef->visuals.array)
|
||||||
{
|
{
|
||||||
for (char j = 0; j < elemDef->visualCount; ++j)
|
for (char j = 0; j < elemDef->visualCount; ++j)
|
||||||
{
|
{
|
||||||
this->markFxElemVisuals(&elemDef->visuals.array[j], elemDef->elemType, builder);
|
this->markFxElemVisuals(&elemDef->visuals.array[j], elemDef->elemType, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->markFxElemVisuals(&elemDef->visuals.instance, elemDef->elemType, builder);
|
this->markFxElemVisuals(&elemDef->visuals.instance, elemDef->elemType, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elemDef->effectOnImpact)
|
if (elemDef->effectOnImpact)
|
||||||
{
|
{
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, elemDef->effectOnImpact, false);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, elemDef->effectOnImpact, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elemDef->effectOnDeath)
|
if (elemDef->effectOnDeath)
|
||||||
{
|
{
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, elemDef->effectOnDeath, false);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, elemDef->effectOnDeath, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elemDef->effectEmitted)
|
if (elemDef->effectEmitted)
|
||||||
{
|
{
|
||||||
builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, elemDef->effectEmitted, false);
|
builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, elemDef->effectEmitted, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IFxEffectDef::saveFxElemVisuals(Game::FxElemVisuals* visuals, Game::FxElemVisuals* destVisuals, char elemType, Components::ZoneBuilder::Zone* builder)
|
void IFxEffectDef::saveFxElemVisuals(Game::FxElemVisuals* visuals, Game::FxElemVisuals* destVisuals, char elemType, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Utils::Stream* buffer = builder->getBuffer();
|
Utils::Stream* buffer = builder->getBuffer();
|
||||||
|
|
||||||
switch (elemType)
|
switch (elemType)
|
||||||
{
|
{
|
||||||
case 7:
|
case 7:
|
||||||
{
|
{
|
||||||
if (visuals->xmodel)
|
if (visuals->xmodel)
|
||||||
{
|
{
|
||||||
destVisuals->xmodel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel).model;
|
destVisuals->xmodel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, visuals->xmodel).model;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
case 9:
|
case 9:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xA:
|
case 0xA:
|
||||||
{
|
{
|
||||||
if (visuals->soundName)
|
if (visuals->soundName)
|
||||||
{
|
{
|
||||||
buffer->saveString(visuals->soundName);
|
buffer->saveString(visuals->soundName);
|
||||||
Utils::Stream::ClearPointer(&destVisuals->soundName);
|
Utils::Stream::ClearPointer(&destVisuals->soundName);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC:
|
case 0xC:
|
||||||
{
|
{
|
||||||
if (visuals->effectDef)
|
if (visuals->effectDef)
|
||||||
{
|
{
|
||||||
buffer->saveString(visuals->effectDef->name);
|
buffer->saveString(visuals->effectDef->name);
|
||||||
Utils::Stream::ClearPointer(&destVisuals->effectDef);
|
Utils::Stream::ClearPointer(&destVisuals->effectDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (visuals->material)
|
if (visuals->material)
|
||||||
{
|
{
|
||||||
destVisuals->material = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material).material;
|
destVisuals->material = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, visuals->material).material;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IFxEffectDef::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
void IFxEffectDef::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
AssertSize(Game::FxEffectDef, 32);
|
AssertSize(Game::FxEffectDef, 32);
|
||||||
|
|
||||||
Utils::Stream* buffer = builder->getBuffer();
|
Utils::Stream* buffer = builder->getBuffer();
|
||||||
Game::FxEffectDef* asset = header.fx;
|
Game::FxEffectDef* asset = header.fx;
|
||||||
Game::FxEffectDef* dest = buffer->dest<Game::FxEffectDef>();
|
Game::FxEffectDef* dest = buffer->dest<Game::FxEffectDef>();
|
||||||
buffer->save(asset);
|
buffer->save(asset);
|
||||||
|
|
||||||
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||||
|
|
||||||
if (asset->name)
|
if (asset->name)
|
||||||
{
|
{
|
||||||
buffer->saveString(builder->getAssetName(this->getType(), asset->name));
|
buffer->saveString(builder->getAssetName(this->getType(), asset->name));
|
||||||
Utils::Stream::ClearPointer(&dest->name);
|
Utils::Stream::ClearPointer(&dest->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asset->elemDefs)
|
if (asset->elemDefs)
|
||||||
{
|
{
|
||||||
AssertSize(Game::FxElemDef, 252);
|
AssertSize(Game::FxElemDef, 252);
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
|
||||||
Game::FxElemDef* destElemDefs = buffer->dest<Game::FxElemDef>();
|
Game::FxElemDef* destElemDefs = buffer->dest<Game::FxElemDef>();
|
||||||
buffer->saveArray(asset->elemDefs, asset->elemDefCountEmission + asset->elemDefCountLooping + asset->elemDefCountOneShot);
|
buffer->saveArray(asset->elemDefs, asset->elemDefCountEmission + asset->elemDefCountLooping + asset->elemDefCountOneShot);
|
||||||
|
|
||||||
for (int i = 0; i < (asset->elemDefCountEmission + asset->elemDefCountLooping + asset->elemDefCountOneShot); ++i)
|
for (int i = 0; i < (asset->elemDefCountEmission + asset->elemDefCountLooping + asset->elemDefCountOneShot); ++i)
|
||||||
{
|
{
|
||||||
Game::FxElemDef* destElemDef = &destElemDefs[i];
|
Game::FxElemDef* destElemDef = &destElemDefs[i];
|
||||||
Game::FxElemDef* elemDef = &asset->elemDefs[i];
|
Game::FxElemDef* elemDef = &asset->elemDefs[i];
|
||||||
|
|
||||||
if (elemDef->velSamples)
|
if (elemDef->velSamples)
|
||||||
{
|
{
|
||||||
AssertSize(Game::FxElemVelStateSample, 96);
|
AssertSize(Game::FxElemVelStateSample, 96);
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
|
||||||
buffer->saveArray(elemDef->velSamples, elemDef->velIntervalCount + 1);
|
buffer->saveArray(elemDef->velSamples, elemDef->velIntervalCount + 1);
|
||||||
|
|
||||||
Utils::Stream::ClearPointer(&destElemDef->velSamples);
|
Utils::Stream::ClearPointer(&destElemDef->velSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elemDef->visSamples)
|
if (elemDef->visSamples)
|
||||||
{
|
{
|
||||||
AssertSize(Game::FxElemVisStateSample, 48);
|
AssertSize(Game::FxElemVisStateSample, 48);
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
|
||||||
buffer->saveArray(elemDef->visSamples, elemDef->visStateIntervalCount + 1);
|
buffer->saveArray(elemDef->visSamples, elemDef->visStateIntervalCount + 1);
|
||||||
|
|
||||||
Utils::Stream::ClearPointer(&destElemDef->visSamples);
|
Utils::Stream::ClearPointer(&destElemDef->visSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save_FxElemDefVisuals
|
// Save_FxElemDefVisuals
|
||||||
{
|
{
|
||||||
if (elemDef->elemType == 11)
|
if (elemDef->elemType == 11)
|
||||||
{
|
{
|
||||||
if (elemDef->visuals.markArray)
|
if (elemDef->visuals.markArray)
|
||||||
{
|
{
|
||||||
AssertSize(Game::FxElemMarkVisuals, 8);
|
AssertSize(Game::FxElemMarkVisuals, 8);
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
|
||||||
Game::FxElemMarkVisuals* destMarkArray = buffer->dest<Game::FxElemMarkVisuals>();
|
Game::FxElemMarkVisuals* destMarkArray = buffer->dest<Game::FxElemMarkVisuals>();
|
||||||
buffer->saveArray(elemDef->visuals.markArray, elemDef->visualCount);
|
buffer->saveArray(elemDef->visuals.markArray, elemDef->visualCount);
|
||||||
|
|
||||||
for (char j = 0; j < elemDef->visualCount; ++j)
|
for (char j = 0; j < elemDef->visualCount; ++j)
|
||||||
{
|
{
|
||||||
if (elemDef->visuals.markArray[j].data[0])
|
if (elemDef->visuals.markArray[j].data[0])
|
||||||
{
|
{
|
||||||
destMarkArray[j].data[0] = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, elemDef->visuals.markArray[j].data[0]).material;
|
destMarkArray[j].data[0] = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, elemDef->visuals.markArray[j].data[0]).material;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elemDef->visuals.markArray[j].data[1])
|
if (elemDef->visuals.markArray[j].data[1])
|
||||||
{
|
{
|
||||||
destMarkArray[j].data[1] = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, elemDef->visuals.markArray[j].data[1]).material;
|
destMarkArray[j].data[1] = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, elemDef->visuals.markArray[j].data[1]).material;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Stream::ClearPointer(&destElemDef->visuals.markArray);
|
Utils::Stream::ClearPointer(&destElemDef->visuals.markArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(elemDef->visualCount > 1)
|
else if(elemDef->visualCount > 1)
|
||||||
{
|
{
|
||||||
if (elemDef->visuals.array)
|
if (elemDef->visuals.array)
|
||||||
{
|
{
|
||||||
AssertSize(Game::FxElemVisuals, 4);
|
AssertSize(Game::FxElemVisuals, 4);
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
|
||||||
Game::FxElemVisuals* destVisuals = buffer->dest<Game::FxElemVisuals>();
|
Game::FxElemVisuals* destVisuals = buffer->dest<Game::FxElemVisuals>();
|
||||||
buffer->saveArray(elemDef->visuals.array, elemDef->visualCount);
|
buffer->saveArray(elemDef->visuals.array, elemDef->visualCount);
|
||||||
|
|
||||||
for (char j = 0; j < elemDef->visualCount; ++j)
|
for (char j = 0; j < elemDef->visualCount; ++j)
|
||||||
{
|
{
|
||||||
this->saveFxElemVisuals(&elemDef->visuals.array[j], &destVisuals[j], elemDef->elemType, builder);
|
this->saveFxElemVisuals(&elemDef->visuals.array[j], &destVisuals[j], elemDef->elemType, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Stream::ClearPointer(&destElemDef->visuals.array);
|
Utils::Stream::ClearPointer(&destElemDef->visuals.array);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->saveFxElemVisuals(&elemDef->visuals.instance, &destElemDef->visuals.instance, elemDef->elemType, builder);
|
this->saveFxElemVisuals(&elemDef->visuals.instance, &destElemDef->visuals.instance, elemDef->elemType, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elemDef->effectOnImpact)
|
if (elemDef->effectOnImpact)
|
||||||
{
|
{
|
||||||
buffer->saveString(elemDef->effectOnImpact->name);
|
buffer->saveString(elemDef->effectOnImpact->name);
|
||||||
Utils::Stream::ClearPointer(&destElemDef->effectOnImpact);
|
Utils::Stream::ClearPointer(&destElemDef->effectOnImpact);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elemDef->effectOnDeath)
|
if (elemDef->effectOnDeath)
|
||||||
{
|
{
|
||||||
buffer->saveString(elemDef->effectOnDeath->name);
|
buffer->saveString(elemDef->effectOnDeath->name);
|
||||||
Utils::Stream::ClearPointer(&destElemDef->effectOnDeath);
|
Utils::Stream::ClearPointer(&destElemDef->effectOnDeath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elemDef->effectEmitted)
|
if (elemDef->effectEmitted)
|
||||||
{
|
{
|
||||||
buffer->saveString(elemDef->effectEmitted->name);
|
buffer->saveString(elemDef->effectEmitted->name);
|
||||||
Utils::Stream::ClearPointer(&destElemDef->effectEmitted);
|
Utils::Stream::ClearPointer(&destElemDef->effectEmitted);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save_FxElemExtendedDefPtr
|
// Save_FxElemExtendedDefPtr
|
||||||
{
|
{
|
||||||
AssertSize(Game::FxElemExtendedDef, 4);
|
AssertSize(Game::FxElemExtendedDef, 4);
|
||||||
|
|
||||||
if (elemDef->elemType == 3)
|
if (elemDef->elemType == 3)
|
||||||
{
|
{
|
||||||
// Save_FxTrailDef
|
// Save_FxTrailDef
|
||||||
{
|
{
|
||||||
if (elemDef->extendedDef.trailDef)
|
if (elemDef->extendedDef.trailDef)
|
||||||
{
|
{
|
||||||
AssertSize(Game::FxTrailDef, 36);
|
AssertSize(Game::FxTrailDef, 36);
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
|
||||||
Game::FxTrailDef* trailDef = elemDef->extendedDef.trailDef;
|
Game::FxTrailDef* trailDef = elemDef->extendedDef.trailDef;
|
||||||
Game::FxTrailDef* destTrailDef = buffer->dest<Game::FxTrailDef>();
|
Game::FxTrailDef* destTrailDef = buffer->dest<Game::FxTrailDef>();
|
||||||
buffer->save(trailDef);
|
buffer->save(trailDef);
|
||||||
|
|
||||||
if (trailDef->verts)
|
if (trailDef->verts)
|
||||||
{
|
{
|
||||||
AssertSize(Game::FxTrailVertex, 20);
|
AssertSize(Game::FxTrailVertex, 20);
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
|
||||||
buffer->saveArray(trailDef->verts, trailDef->vertCount);
|
buffer->saveArray(trailDef->verts, trailDef->vertCount);
|
||||||
Utils::Stream::ClearPointer(&destTrailDef->verts);
|
Utils::Stream::ClearPointer(&destTrailDef->verts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trailDef->inds)
|
if (trailDef->inds)
|
||||||
{
|
{
|
||||||
buffer->align(Utils::Stream::ALIGN_2);
|
buffer->align(Utils::Stream::ALIGN_2);
|
||||||
|
|
||||||
buffer->saveArray(trailDef->inds, trailDef->indCount);
|
buffer->saveArray(trailDef->inds, trailDef->indCount);
|
||||||
Utils::Stream::ClearPointer(&destTrailDef->inds);
|
Utils::Stream::ClearPointer(&destTrailDef->inds);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Stream::ClearPointer(&destElemDef->extendedDef.trailDef);
|
Utils::Stream::ClearPointer(&destElemDef->extendedDef.trailDef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (elemDef->elemType == 6)
|
else if (elemDef->elemType == 6)
|
||||||
{
|
{
|
||||||
if (elemDef->extendedDef.sparkFountain)
|
if (elemDef->extendedDef.sparkFountain)
|
||||||
{
|
{
|
||||||
AssertSize(Game::FxSparkFountain, 52);
|
AssertSize(Game::FxSparkFountain, 52);
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
|
||||||
buffer->save(elemDef->extendedDef.sparkFountain);
|
buffer->save(elemDef->extendedDef.sparkFountain);
|
||||||
Utils::Stream::ClearPointer(&destElemDef->extendedDef.sparkFountain);
|
Utils::Stream::ClearPointer(&destElemDef->extendedDef.sparkFountain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (elemDef->extendedDef.unknownBytes)
|
if (elemDef->extendedDef.unknownBytes)
|
||||||
{
|
{
|
||||||
buffer->save(elemDef->extendedDef.unknownBytes);
|
buffer->save(elemDef->extendedDef.unknownBytes);
|
||||||
Utils::Stream::ClearPointer(&destElemDef->extendedDef.unknownBytes);
|
Utils::Stream::ClearPointer(&destElemDef->extendedDef.unknownBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Stream::ClearPointer(&dest->elemDefs);
|
Utils::Stream::ClearPointer(&dest->elemDefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->popBlock();
|
buffer->popBlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
AssertSize(Game::G_GlassData, 128);
|
AssertSize(Game::G_GlassData, 128);
|
||||||
|
|
||||||
Game::G_GlassData* destGlass = buffer->dest<Game::G_GlassData>();
|
Game::G_GlassData* destGlass = buffer->dest<Game::G_GlassData>();
|
||||||
buffer->save(asset->data);
|
buffer->save(asset->data);
|
||||||
|
|
||||||
if (asset->data->glassPieces)
|
if (asset->data->glassPieces)
|
||||||
|
@ -54,10 +54,10 @@ namespace Assets
|
|||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
builder->storePointer(*childNodeTreePtr);
|
builder->storePointer(*childNodeTreePtr);
|
||||||
|
|
||||||
Game::pathnode_tree_t* destChildNodeTree = buffer->dest<Game::pathnode_tree_t>();
|
Game::pathnode_tree_t* destChildNodeTree = buffer->dest<Game::pathnode_tree_t>();
|
||||||
buffer->save(*childNodeTreePtr);
|
buffer->save(*childNodeTreePtr);
|
||||||
|
|
||||||
this->savepathnode_tree_info_t(*childNodeTreePtr, destChildNodeTree, builder);
|
this->savepathnode_tree_info_t(*childNodeTreePtr, destChildNodeTree, builder);
|
||||||
Utils::Stream::ClearPointer(destChildNodeTreePtr);
|
Utils::Stream::ClearPointer(destChildNodeTreePtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,12 +88,12 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
builder->storePointer(*trackSegmentPtr);
|
builder->storePointer(*trackSegmentPtr);
|
||||||
|
|
||||||
Game::VehicleTrackSegment* destTrackSegment = buffer->dest<Game::VehicleTrackSegment>();
|
Game::VehicleTrackSegment* destTrackSegment = buffer->dest<Game::VehicleTrackSegment>();
|
||||||
buffer->save(*trackSegmentPtr);
|
buffer->save(*trackSegmentPtr);
|
||||||
|
|
||||||
this->saveVehicleTrackSegment(*trackSegmentPtr, destTrackSegment, builder);
|
this->saveVehicleTrackSegment(*trackSegmentPtr, destTrackSegment, builder);
|
||||||
|
|
||||||
Utils::Stream::ClearPointer(destTrackSegmentPtr);
|
Utils::Stream::ClearPointer(destTrackSegmentPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,15 +108,15 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
buffer->saveString(trackSegment->name);
|
buffer->saveString(trackSegment->name);
|
||||||
Utils::Stream::ClearPointer(&destTrackSegment->name);
|
Utils::Stream::ClearPointer(&destTrackSegment->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trackSegment->trackSectors)
|
if (trackSegment->trackSectors)
|
||||||
{
|
{
|
||||||
AssertSize(Game::VehicleTrackSector, 60);
|
AssertSize(Game::VehicleTrackSector, 60);
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
|
||||||
Game::VehicleTrackSector* destTrackSectors = buffer->dest<Game::VehicleTrackSector>();
|
Game::VehicleTrackSector* destTrackSectors = buffer->dest<Game::VehicleTrackSector>();
|
||||||
buffer->saveArray(trackSegment->trackSectors, trackSegment->trackSectorCount);
|
buffer->saveArray(trackSegment->trackSectors, trackSegment->trackSectorCount);
|
||||||
|
|
||||||
for (int i = 0; i < trackSegment->trackSectorCount; ++i)
|
for (int i = 0; i < trackSegment->trackSectorCount; ++i)
|
||||||
{
|
{
|
||||||
@ -130,21 +130,21 @@ namespace Assets
|
|||||||
buffer->saveArray(trackSector->trackObstacles, trackSector->trackObstacleCount);
|
buffer->saveArray(trackSector->trackObstacles, trackSector->trackObstacleCount);
|
||||||
Utils::Stream::ClearPointer(&destTrackSector->trackObstacles);
|
Utils::Stream::ClearPointer(&destTrackSector->trackObstacles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trackSegment->trackSegments1)
|
||||||
|
{
|
||||||
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
this->saveVehicleTrackSegment_ptrArray(trackSegment->trackSegments1, trackSegment->trackSegmentCount1, builder);
|
||||||
|
Utils::Stream::ClearPointer(&destTrackSegment->trackSegments1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trackSegment->trackSegments1)
|
if (trackSegment->trackSegments2)
|
||||||
{
|
{
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
this->saveVehicleTrackSegment_ptrArray(trackSegment->trackSegments1, trackSegment->trackSegmentCount1, builder);
|
this->saveVehicleTrackSegment_ptrArray(trackSegment->trackSegments2, trackSegment->trackSegmentCount2, builder);
|
||||||
Utils::Stream::ClearPointer(&destTrackSegment->trackSegments1);
|
Utils::Stream::ClearPointer(&destTrackSegment->trackSegments2);
|
||||||
}
|
|
||||||
|
|
||||||
if (trackSegment->trackSegments2)
|
|
||||||
{
|
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
|
||||||
this->saveVehicleTrackSegment_ptrArray(trackSegment->trackSegments2, trackSegment->trackSegmentCount2, builder);
|
|
||||||
Utils::Stream::ClearPointer(&destTrackSegment->trackSegments2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,18 +273,18 @@ namespace Assets
|
|||||||
|
|
||||||
for (int i = 0; i < asset->vehicleTrack.trackSegmentCount; ++i)
|
for (int i = 0; i < asset->vehicleTrack.trackSegmentCount; ++i)
|
||||||
{
|
{
|
||||||
builder->storePointer(&asset->vehicleTrack.trackSegments[i]);
|
builder->storePointer(&asset->vehicleTrack.trackSegments[i]);
|
||||||
buffer->save(&asset->vehicleTrack.trackSegments[i]);
|
buffer->save(&asset->vehicleTrack.trackSegments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < asset->vehicleTrack.trackSegmentCount; ++i)
|
for (int i = 0; i < asset->vehicleTrack.trackSegmentCount; ++i)
|
||||||
{
|
{
|
||||||
Game::VehicleTrackSegment* destTrackSegment = &destTrackSegments[i];
|
Game::VehicleTrackSegment* destTrackSegment = &destTrackSegments[i];
|
||||||
Game::VehicleTrackSegment* trackSegment = &asset->vehicleTrack.trackSegments[i];
|
Game::VehicleTrackSegment* trackSegment = &asset->vehicleTrack.trackSegments[i];
|
||||||
|
|
||||||
this->saveVehicleTrackSegment(trackSegment, destTrackSegment, builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
this->saveVehicleTrackSegment(trackSegment, destTrackSegment, builder);
|
||||||
|
}
|
||||||
|
|
||||||
Utils::Stream::ClearPointer(&dest->vehicleTrack.trackSegments);
|
Utils::Stream::ClearPointer(&dest->vehicleTrack.trackSegments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ namespace Assets
|
|||||||
AssertSize(Game::G_GlassData, 128);
|
AssertSize(Game::G_GlassData, 128);
|
||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
|
|
||||||
Game::G_GlassData* destGlass = buffer->dest<Game::G_GlassData>();
|
Game::G_GlassData* destGlass = buffer->dest<Game::G_GlassData>();
|
||||||
buffer->save(asset->data);
|
buffer->save(asset->data);
|
||||||
|
|
||||||
if (asset->data->glassPieces)
|
if (asset->data->glassPieces)
|
||||||
|
@ -4,71 +4,71 @@
|
|||||||
|
|
||||||
namespace Assets
|
namespace Assets
|
||||||
{
|
{
|
||||||
void IXModel::loadXSurfaceCollisionTree(Game::XSurfaceCollisionTree* entry, Utils::Stream::Reader* reader)
|
void IXModel::loadXSurfaceCollisionTree(Game::XSurfaceCollisionTree* entry, Utils::Stream::Reader* reader)
|
||||||
{
|
{
|
||||||
if (entry->nodes)
|
if (entry->nodes)
|
||||||
{
|
{
|
||||||
entry->nodes = reader->readArray<Game::XSurfaceCollisionNode>(entry->nodeCount);
|
entry->nodes = reader->readArray<Game::XSurfaceCollisionNode>(entry->nodeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->leafs)
|
if (entry->leafs)
|
||||||
{
|
{
|
||||||
entry->leafs = reader->readArray<Game::XSurfaceCollisionLeaf>(entry->leafCount);
|
entry->leafs = reader->readArray<Game::XSurfaceCollisionLeaf>(entry->leafCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IXModel::loadXSurface(Game::XSurface* surf, Utils::Stream::Reader* reader)
|
void IXModel::loadXSurface(Game::XSurface* surf, Utils::Stream::Reader* reader)
|
||||||
{
|
{
|
||||||
if (surf->vertInfo.vertsBlend)
|
if (surf->vertInfo.vertsBlend)
|
||||||
{
|
{
|
||||||
surf->vertInfo.vertsBlend = reader->readArray<unsigned short>(surf->vertInfo.vertCount[0] + (surf->vertInfo.vertCount[1] * 3) + (surf->vertInfo.vertCount[2] * 5) + (surf->vertInfo.vertCount[3] * 7));
|
surf->vertInfo.vertsBlend = reader->readArray<unsigned short>(surf->vertInfo.vertCount[0] + (surf->vertInfo.vertCount[1] * 3) + (surf->vertInfo.vertCount[2] * 5) + (surf->vertInfo.vertCount[3] * 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access vertex block
|
// Access vertex block
|
||||||
if (surf->verts0)
|
if (surf->verts0)
|
||||||
{
|
{
|
||||||
surf->verts0 = reader->readArray<Game::GfxPackedVertex>(surf->vertCount);
|
surf->verts0 = reader->readArray<Game::GfxPackedVertex>(surf->vertCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save_XRigidVertListArray
|
// Save_XRigidVertListArray
|
||||||
if (surf->vertList)
|
if (surf->vertList)
|
||||||
{
|
{
|
||||||
surf->vertList = reader->readArray<Game::XRigidVertList>(surf->vertListCount);
|
surf->vertList = reader->readArray<Game::XRigidVertList>(surf->vertListCount);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < surf->vertListCount; ++i)
|
for (unsigned int i = 0; i < surf->vertListCount; ++i)
|
||||||
{
|
{
|
||||||
Game::XRigidVertList* rigidVertList = &surf->vertList[i];
|
Game::XRigidVertList* rigidVertList = &surf->vertList[i];
|
||||||
|
|
||||||
if (rigidVertList->collisionTree)
|
if (rigidVertList->collisionTree)
|
||||||
{
|
{
|
||||||
rigidVertList->collisionTree = reader->readObject<Game::XSurfaceCollisionTree>();
|
rigidVertList->collisionTree = reader->readObject<Game::XSurfaceCollisionTree>();
|
||||||
this->loadXSurfaceCollisionTree(rigidVertList->collisionTree, reader);
|
this->loadXSurfaceCollisionTree(rigidVertList->collisionTree, reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access index block
|
// Access index block
|
||||||
if (surf->triIndices)
|
if (surf->triIndices)
|
||||||
{
|
{
|
||||||
surf->triIndices = reader->readArray<unsigned short>(surf->triCount * 3);
|
surf->triIndices = reader->readArray<unsigned short>(surf->triCount * 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IXModel::loadXModelSurfs(Game::XModelSurfs* asset, Utils::Stream::Reader* reader)
|
void IXModel::loadXModelSurfs(Game::XModelSurfs* asset, Utils::Stream::Reader* reader)
|
||||||
{
|
{
|
||||||
if (asset->name)
|
if (asset->name)
|
||||||
{
|
{
|
||||||
asset->name = reader->readCString();
|
asset->name = reader->readCString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asset->surfaces)
|
if (asset->surfaces)
|
||||||
{
|
{
|
||||||
asset->surfaces = reader->readArray<Game::XSurface>(asset->numSurfaces);
|
asset->surfaces = reader->readArray<Game::XSurface>(asset->numSurfaces);
|
||||||
|
|
||||||
for (int i = 0; i < asset->numSurfaces; ++i)
|
for (int i = 0; i < asset->numSurfaces; ++i)
|
||||||
{
|
{
|
||||||
this->loadXSurface(&asset->surfaces[i], reader);
|
this->loadXSurface(&asset->surfaces[i], reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,14 +192,14 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
asset->physPreset = reader.readObject<Game::PhysPreset>();
|
asset->physPreset = reader.readObject<Game::PhysPreset>();
|
||||||
|
|
||||||
if (asset->physPreset->name)
|
if (asset->physPreset->name)
|
||||||
{
|
{
|
||||||
asset->physPreset->name = reader.readCString();
|
asset->physPreset->name = reader.readCString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asset->physPreset->sndAliasPrefix)
|
if (asset->physPreset->sndAliasPrefix)
|
||||||
{
|
{
|
||||||
asset->physPreset->sndAliasPrefix = reader.readCString();
|
asset->physPreset->sndAliasPrefix = reader.readCString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is an experiment, ak74 fails though
|
// This is an experiment, ak74 fails though
|
||||||
|
@ -601,24 +601,24 @@ namespace Assets
|
|||||||
|
|
||||||
clipMap->name = reader.readCString();
|
clipMap->name = reader.readCString();
|
||||||
|
|
||||||
clipMap->numCPlanes = reader.read<int>();
|
clipMap->numCPlanes = reader.read<int>();
|
||||||
clipMap->numStaticModels = reader.read<int>();
|
clipMap->numStaticModels = reader.read<int>();
|
||||||
clipMap->numMaterials = reader.read<int>();
|
clipMap->numMaterials = reader.read<int>();
|
||||||
clipMap->numCBrushSides = reader.read<int>();
|
clipMap->numCBrushSides = reader.read<int>();
|
||||||
clipMap->numCBrushEdges = reader.read<int>();
|
clipMap->numCBrushEdges = reader.read<int>();
|
||||||
clipMap->numCNodes = reader.read<int>();
|
clipMap->numCNodes = reader.read<int>();
|
||||||
clipMap->numCLeaf = reader.read<int>();
|
clipMap->numCLeaf = reader.read<int>();
|
||||||
clipMap->numCLeafBrushNodes = reader.read<int>();
|
clipMap->numCLeafBrushNodes = reader.read<int>();
|
||||||
clipMap->numLeafBrushes = reader.read<int>();
|
clipMap->numLeafBrushes = reader.read<int>();
|
||||||
clipMap->numLeafSurfaces = reader.read<int>();
|
clipMap->numLeafSurfaces = reader.read<int>();
|
||||||
clipMap->numVerts = reader.read<int>();
|
clipMap->numVerts = reader.read<int>();
|
||||||
clipMap->numTriIndices = reader.read<int>();
|
clipMap->numTriIndices = reader.read<int>();
|
||||||
clipMap->numCollisionBorders = reader.read<int>();
|
clipMap->numCollisionBorders = reader.read<int>();
|
||||||
clipMap->numCollisionPartitions = reader.read<int>();
|
clipMap->numCollisionPartitions = reader.read<int>();
|
||||||
clipMap->numCollisionAABBTrees = reader.read<int>();
|
clipMap->numCollisionAABBTrees = reader.read<int>();
|
||||||
clipMap->numCModels = reader.read<int>();
|
clipMap->numCModels = reader.read<int>();
|
||||||
clipMap->numCBrushes = reader.read<short>();
|
clipMap->numCBrushes = reader.read<short>();
|
||||||
clipMap->dynEntCount[0] = reader.read<unsigned __int16>();
|
clipMap->dynEntCount[0] = reader.read<unsigned __int16>();
|
||||||
clipMap->dynEntCount[1] = reader.read<unsigned __int16>();
|
clipMap->dynEntCount[1] = reader.read<unsigned __int16>();
|
||||||
|
|
||||||
if (clipMap->numCPlanes)
|
if (clipMap->numCPlanes)
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace Assets
|
namespace Assets
|
||||||
{
|
{
|
||||||
void Isnd_alias_list_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
void Isnd_alias_list_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Game::snd_alias_list_t* asset = header.sound;
|
Game::snd_alias_list_t* asset = header.sound;
|
||||||
|
|
||||||
for (int i = 0; i < asset->count; ++i)
|
for (int i = 0; i < asset->count; ++i)
|
||||||
{
|
{
|
||||||
Game::snd_alias_t* alias = &asset->head[i];
|
Game::snd_alias_t* alias = &asset->head[i];
|
||||||
|
|
||||||
if (alias->soundFile && alias->soundFile->type == Game::snd_alias_type_t::SAT_LOADED)
|
if (alias->soundFile && alias->soundFile->type == Game::snd_alias_type_t::SAT_LOADED)
|
||||||
@ -52,12 +52,12 @@ namespace Assets
|
|||||||
buffer->align(Utils::Stream::ALIGN_4);
|
buffer->align(Utils::Stream::ALIGN_4);
|
||||||
builder->storePointer(asset->head);
|
builder->storePointer(asset->head);
|
||||||
|
|
||||||
Game::snd_alias_t* destHead = buffer->dest<Game::snd_alias_t>();
|
Game::snd_alias_t* destHead = buffer->dest<Game::snd_alias_t>();
|
||||||
buffer->saveArray(asset->head, asset->count);
|
buffer->saveArray(asset->head, asset->count);
|
||||||
|
|
||||||
for (int i = 0; i < asset->count; ++i)
|
for (int i = 0; i < asset->count; ++i)
|
||||||
{
|
{
|
||||||
Game::snd_alias_t* destAlias = &destHead[i];
|
Game::snd_alias_t* destAlias = &destHead[i];
|
||||||
Game::snd_alias_t* alias = &asset->head[i];
|
Game::snd_alias_t* alias = &asset->head[i];
|
||||||
|
|
||||||
if (alias->name)
|
if (alias->name)
|
||||||
|
@ -37,7 +37,7 @@ namespace Components
|
|||||||
|
|
||||||
if (Dvar::Var("com_logFilter").get<bool>())
|
if (Dvar::Var("com_logFilter").get<bool>())
|
||||||
{
|
{
|
||||||
Utils::Hook::Nop(0x647466, 5); // 'dvar set' lines
|
Utils::Hook::Nop(0x647466, 5); // 'dvar set' lines
|
||||||
Utils::Hook::Nop(0x5DF4F2, 5); // 'sending splash open' lines
|
Utils::Hook::Nop(0x5DF4F2, 5); // 'sending splash open' lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,18 +413,18 @@ namespace Components
|
|||||||
Utils::Hook::Call<void(Game::XZoneInfo*, unsigned int)>(0x5BBAC0)(zoneInfo, zoneCount);
|
Utils::Hook::Call<void(Game::XZoneInfo*, unsigned int)>(0x5BBAC0)(zoneInfo, zoneCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void FastFiles::LogStreamRead(int len)
|
void FastFiles::LogStreamRead(int len)
|
||||||
{
|
{
|
||||||
*Game::g_streamPos += len;
|
*Game::g_streamPos += len;
|
||||||
|
|
||||||
if (FastFiles::StreamRead)
|
if (FastFiles::StreamRead)
|
||||||
{
|
{
|
||||||
std::string data = Utils::String::VA("%d\n", len);
|
std::string data = Utils::String::VA("%d\n", len);
|
||||||
if (*Game::g_streamPosIndex == 2) data = Utils::String::VA("(%d)\n", len);
|
if (*Game::g_streamPosIndex == 2) data = Utils::String::VA("(%d)\n", len);
|
||||||
Utils::IO::WriteFile("userraw/logs/iw4_reads.log", data, true);
|
Utils::IO::WriteFile("userraw/logs/iw4_reads.log", data, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FastFiles::FastFiles()
|
FastFiles::FastFiles()
|
||||||
@ -518,15 +518,15 @@ namespace Components
|
|||||||
Game::DB_LoadXAssets(&info, 1, true);
|
Game::DB_LoadXAssets(&info, 1, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// ZoneBuilder debugging
|
// ZoneBuilder debugging
|
||||||
Utils::IO::WriteFile("userraw/logs/iw4_reads.log", "", false);
|
Utils::IO::WriteFile("userraw/logs/iw4_reads.log", "", false);
|
||||||
Utils::Hook(0x4A8FA0, FastFiles::LogStreamRead, HOOK_JUMP).install()->quick();
|
Utils::Hook(0x4A8FA0, FastFiles::LogStreamRead, HOOK_JUMP).install()->quick();
|
||||||
Utils::Hook(0x4BCB62, []()
|
Utils::Hook(0x4BCB62, []()
|
||||||
{
|
{
|
||||||
FastFiles::StreamRead = true;
|
FastFiles::StreamRead = true;
|
||||||
Utils::Hook::Call<void(bool)>(0x4B8DB0)(true); // currently set to Load_GfxWorld
|
Utils::Hook::Call<void(bool)>(0x4B8DB0)(true); // currently set to Load_GfxWorld
|
||||||
FastFiles::StreamRead = false;
|
FastFiles::StreamRead = false;
|
||||||
}, HOOK_CALL).install()->quick();
|
}, HOOK_CALL).install()->quick();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -189,23 +189,26 @@ namespace Components
|
|||||||
{
|
{
|
||||||
hasCustomSurface = true;
|
hasCustomSurface = true;
|
||||||
|
|
||||||
auto buffer = ModelSurfs::BufferMap.find(surface->triIndices);
|
if (!ModelSurfs::BufferMap.empty())
|
||||||
if (buffer != ModelSurfs::BufferMap.end())
|
|
||||||
{
|
{
|
||||||
buffer->second->Release();
|
auto buffer = ModelSurfs::BufferMap.find(surface->triIndices);
|
||||||
ModelSurfs::BufferMap.erase(buffer);
|
if (buffer != ModelSurfs::BufferMap.end())
|
||||||
}
|
{
|
||||||
|
buffer->second->Release();
|
||||||
|
ModelSurfs::BufferMap.erase(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
buffer = ModelSurfs::BufferMap.find(surface->verts0);
|
buffer = ModelSurfs::BufferMap.find(surface->verts0);
|
||||||
if (buffer != ModelSurfs::BufferMap.end())
|
if (buffer != ModelSurfs::BufferMap.end())
|
||||||
{
|
{
|
||||||
buffer->second->Release();
|
buffer->second->Release();
|
||||||
ModelSurfs::BufferMap.erase(buffer);
|
ModelSurfs::BufferMap.erase(buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasCustomSurface)
|
if (hasCustomSurface && !ModelSurfs::AllocMap.empty())
|
||||||
{
|
{
|
||||||
auto allocData = ModelSurfs::AllocMap.find(header.surfaces->name);
|
auto allocData = ModelSurfs::AllocMap.find(header.surfaces->name);
|
||||||
if (allocData != ModelSurfs::AllocMap.end())
|
if (allocData != ModelSurfs::AllocMap.end())
|
||||||
|
@ -59,16 +59,16 @@ namespace Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Stream::Reader::readPointer()
|
void* Stream::Reader::readPointer()
|
||||||
{
|
{
|
||||||
void* pointer = this->read<void*>();
|
void* pointer = this->read<void*>();
|
||||||
if (!this->hasPointer(pointer))
|
if (!this->hasPointer(pointer))
|
||||||
{
|
{
|
||||||
this->pointerMap[pointer] = 0;
|
this->pointerMap[pointer] = 0;
|
||||||
}
|
}
|
||||||
return pointer;
|
return pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stream::Reader::mapPointer(void* oldPointer, void* newPointer)
|
void Stream::Reader::mapPointer(void* oldPointer, void* newPointer)
|
||||||
{
|
{
|
||||||
if (this->hasPointer(oldPointer))
|
if (this->hasPointer(oldPointer))
|
||||||
@ -77,9 +77,9 @@ namespace Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Stream::Reader::hasPointer(void* pointer)
|
bool Stream::Reader::hasPointer(void* pointer)
|
||||||
{
|
{
|
||||||
return this->pointerMap.find(pointer) != this->pointerMap.end();
|
return this->pointerMap.find(pointer) != this->pointerMap.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream::Stream() : criticalSectionState(0)
|
Stream::Stream() : criticalSectionState(0)
|
||||||
|
@ -6,186 +6,186 @@
|
|||||||
#else
|
#else
|
||||||
#define SaveLogEnter(x) builder->getBuffer()->enterStruct(x)
|
#define SaveLogEnter(x) builder->getBuffer()->enterStruct(x)
|
||||||
#define SaveLogExit() builder->getBuffer()->leaveStruct()
|
#define SaveLogExit() builder->getBuffer()->leaveStruct()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils
|
||||||
{
|
{
|
||||||
class Stream
|
class Stream
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int criticalSectionState;
|
int criticalSectionState;
|
||||||
unsigned int blockSize[Game::MAX_XFILE_COUNT];
|
unsigned int blockSize[Game::MAX_XFILE_COUNT];
|
||||||
std::vector<Game::XFILE_BLOCK_TYPES> streamStack;
|
std::vector<Game::XFILE_BLOCK_TYPES> streamStack;
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Reader
|
class Reader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Reader(Utils::Memory::Allocator* _allocator, std::string _buffer) : buffer(_buffer), allocator(_allocator), position(0) {}
|
Reader(Utils::Memory::Allocator* _allocator, std::string _buffer) : buffer(_buffer), allocator(_allocator), position(0) {}
|
||||||
|
|
||||||
std::string readString();
|
std::string readString();
|
||||||
const char* readCString();
|
const char* readCString();
|
||||||
|
|
||||||
char readByte();
|
char readByte();
|
||||||
|
|
||||||
void* read(size_t size, size_t count = 1);
|
void* read(size_t size, size_t count = 1);
|
||||||
template <typename T> inline T* readObject()
|
template <typename T> inline T* readObject()
|
||||||
{
|
{
|
||||||
return readArray<T>(1);
|
return readArray<T>(1);
|
||||||
}
|
}
|
||||||
template <typename T> inline T* readArray(size_t count = 1)
|
template <typename T> inline T* readArray(size_t count = 1)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<T*>(this->read(sizeof(T), count));
|
return reinterpret_cast<T*>(this->read(sizeof(T), count));
|
||||||
}
|
}
|
||||||
template <typename T> T read()
|
template <typename T> T read()
|
||||||
{
|
{
|
||||||
T obj;
|
T obj;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < sizeof(T); ++i)
|
for (unsigned int i = 0; i < sizeof(T); ++i)
|
||||||
{
|
{
|
||||||
reinterpret_cast<char*>(&obj)[i] = this->readByte();
|
reinterpret_cast<char*>(&obj)[i] = this->readByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool end();
|
bool end();
|
||||||
void seek(unsigned int position);
|
void seek(unsigned int position);
|
||||||
|
|
||||||
void* readPointer();
|
void* readPointer();
|
||||||
void mapPointer(void* oldPointer, void* newPointer);
|
void mapPointer(void* oldPointer, void* newPointer);
|
||||||
bool hasPointer(void* pointer);
|
bool hasPointer(void* pointer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int position;
|
unsigned int position;
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
std::map<void*, void*> pointerMap;
|
std::map<void*, void*> pointerMap;
|
||||||
Utils::Memory::Allocator* allocator;
|
Utils::Memory::Allocator* allocator;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Alignment
|
enum Alignment
|
||||||
{
|
{
|
||||||
ALIGN_2,
|
ALIGN_2,
|
||||||
ALIGN_4,
|
ALIGN_4,
|
||||||
ALIGN_8,
|
ALIGN_8,
|
||||||
ALIGN_16,
|
ALIGN_16,
|
||||||
ALIGN_32,
|
ALIGN_32,
|
||||||
ALIGN_64,
|
ALIGN_64,
|
||||||
ALIGN_128,
|
ALIGN_128,
|
||||||
ALIGN_256,
|
ALIGN_256,
|
||||||
ALIGN_512,
|
ALIGN_512,
|
||||||
ALIGN_1024,
|
ALIGN_1024,
|
||||||
ALIGN_2048,
|
ALIGN_2048,
|
||||||
};
|
};
|
||||||
|
|
||||||
Stream();
|
Stream();
|
||||||
Stream(size_t size);
|
Stream(size_t size);
|
||||||
~Stream();
|
~Stream();
|
||||||
|
|
||||||
size_t length();
|
size_t length();
|
||||||
size_t capacity();
|
size_t capacity();
|
||||||
|
|
||||||
char* save(const void * _str, size_t size, size_t count = 1);
|
char* save(const void * _str, size_t size, size_t count = 1);
|
||||||
char* save(Game::XFILE_BLOCK_TYPES stream, const void * _str, size_t size, size_t count);
|
char* save(Game::XFILE_BLOCK_TYPES stream, const void * _str, size_t size, size_t count);
|
||||||
char* save(Game::XFILE_BLOCK_TYPES stream, int value, size_t count);
|
char* save(Game::XFILE_BLOCK_TYPES stream, int value, size_t count);
|
||||||
template <typename T> inline char* save(T* object)
|
template <typename T> inline char* save(T* object)
|
||||||
{
|
{
|
||||||
return saveArray<T>(object, 1);
|
return saveArray<T>(object, 1);
|
||||||
}
|
}
|
||||||
template <typename T> inline char* saveArray(T* array, size_t count)
|
template <typename T> inline char* saveArray(T* array, size_t count)
|
||||||
{
|
{
|
||||||
return save(array, sizeof(T), count);
|
return save(array, sizeof(T), count);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* saveString(std::string string);
|
char* saveString(std::string string);
|
||||||
char* saveString(const char* string);
|
char* saveString(const char* string);
|
||||||
char* saveString(const char* string, size_t len);
|
char* saveString(const char* string, size_t len);
|
||||||
char* saveByte(unsigned char byte, size_t count = 1);
|
char* saveByte(unsigned char byte, size_t count = 1);
|
||||||
char* saveNull(size_t count = 1);
|
char* saveNull(size_t count = 1);
|
||||||
char* saveMax(size_t count = 1);
|
char* saveMax(size_t count = 1);
|
||||||
|
|
||||||
char* saveText(std::string string);
|
char* saveText(std::string string);
|
||||||
|
|
||||||
void align(Alignment align);
|
void align(Alignment align);
|
||||||
bool pushBlock(Game::XFILE_BLOCK_TYPES stream);
|
bool pushBlock(Game::XFILE_BLOCK_TYPES stream);
|
||||||
bool popBlock();
|
bool popBlock();
|
||||||
bool isValidBlock(Game::XFILE_BLOCK_TYPES stream);
|
bool isValidBlock(Game::XFILE_BLOCK_TYPES stream);
|
||||||
void increaseBlockSize(Game::XFILE_BLOCK_TYPES stream, unsigned int size);
|
void increaseBlockSize(Game::XFILE_BLOCK_TYPES stream, unsigned int size);
|
||||||
void increaseBlockSize(unsigned int size);
|
void increaseBlockSize(unsigned int size);
|
||||||
Game::XFILE_BLOCK_TYPES getCurrentBlock();
|
Game::XFILE_BLOCK_TYPES getCurrentBlock();
|
||||||
unsigned int getBlockSize(Game::XFILE_BLOCK_TYPES stream);
|
unsigned int getBlockSize(Game::XFILE_BLOCK_TYPES stream);
|
||||||
|
|
||||||
DWORD getPackedOffset();
|
DWORD getPackedOffset();
|
||||||
|
|
||||||
char* data();
|
char* data();
|
||||||
char* at();
|
char* at();
|
||||||
template <typename T> T* dest()
|
template <typename T> T* dest()
|
||||||
{
|
{
|
||||||
return reinterpret_cast<T*>(this->at());
|
return reinterpret_cast<T*>(this->at());
|
||||||
}
|
}
|
||||||
template <typename T> static inline void ClearPointer(T** object)
|
template <typename T> static inline void ClearPointer(T** object)
|
||||||
{
|
{
|
||||||
*object = reinterpret_cast<T*>(-1);
|
*object = reinterpret_cast<T*>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toBuffer(std::string& outBuffer);
|
void toBuffer(std::string& outBuffer);
|
||||||
std::string toBuffer();
|
std::string toBuffer();
|
||||||
|
|
||||||
// Enter/Leave critical sections in which reallocations are not allowed.
|
// Enter/Leave critical sections in which reallocations are not allowed.
|
||||||
// If buffer reallocation is detected, the operation has to be terminated
|
// If buffer reallocation is detected, the operation has to be terminated
|
||||||
// and more memory has to be allocated next time. This will have to be done
|
// and more memory has to be allocated next time. This will have to be done
|
||||||
// by editing the code though.
|
// by editing the code though.
|
||||||
void enterCriticalSection();
|
void enterCriticalSection();
|
||||||
void leaveCriticalSection();
|
void leaveCriticalSection();
|
||||||
bool isCriticalSection();
|
bool isCriticalSection();
|
||||||
|
|
||||||
// for recording zb writes
|
// for recording zb writes
|
||||||
#ifdef WRITE_LOGS
|
#ifdef WRITE_LOGS
|
||||||
int structLevel;
|
int structLevel;
|
||||||
void enterStruct(const char* structName);
|
void enterStruct(const char* structName);
|
||||||
void leaveStruct();
|
void leaveStruct();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This represents packed offset in streams:
|
// This represents packed offset in streams:
|
||||||
// - lowest 28 bits store the value/offset
|
// - lowest 28 bits store the value/offset
|
||||||
// - highest 4 bits store the stream block
|
// - highest 4 bits store the stream block
|
||||||
class Offset
|
class Offset
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32_t offset : 28;
|
uint32_t offset : 28;
|
||||||
Game::XFILE_BLOCK_TYPES block : 4;
|
Game::XFILE_BLOCK_TYPES block : 4;
|
||||||
};
|
};
|
||||||
uint32_t packed;
|
uint32_t packed;
|
||||||
void* pointer;
|
void* pointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
Offset() : packed(0) {};
|
Offset() : packed(0) {};
|
||||||
Offset(Game::XFILE_BLOCK_TYPES _block, uint32_t _offset) : offset(_offset), block(_block) {};
|
Offset(Game::XFILE_BLOCK_TYPES _block, uint32_t _offset) : offset(_offset), block(_block) {};
|
||||||
|
|
||||||
// The game needs it to be incremented
|
// The game needs it to be incremented
|
||||||
uint32_t getPackedOffset()
|
uint32_t getPackedOffset()
|
||||||
{
|
{
|
||||||
return this->packed + 1;
|
return this->packed + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t getUnpackedOffset()
|
uint32_t getUnpackedOffset()
|
||||||
{
|
{
|
||||||
Offset lOffset = *this;
|
Offset lOffset = *this;
|
||||||
lOffset.packed--;
|
lOffset.packed--;
|
||||||
return lOffset.offset;
|
return lOffset.offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
int getUnpackedBlock()
|
int getUnpackedBlock()
|
||||||
{
|
{
|
||||||
Offset lOffset = *this;
|
Offset lOffset = *this;
|
||||||
lOffset.packed--;
|
lOffset.packed--;
|
||||||
return lOffset.block;
|
return lOffset.block;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -3,25 +3,25 @@
|
|||||||
#include "base128.h"
|
#include "base128.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VA_BUFFER_COUNT 32
|
#define VA_BUFFER_COUNT 32
|
||||||
#define VA_BUFFER_SIZE 65536
|
#define VA_BUFFER_SIZE 65536
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils
|
||||||
{
|
{
|
||||||
namespace String
|
namespace String
|
||||||
{
|
{
|
||||||
const char *VA(const char *fmt, ...)
|
const char *VA(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
static char g_vaBuffer[VA_BUFFER_COUNT][VA_BUFFER_SIZE];
|
static char g_vaBuffer[VA_BUFFER_COUNT][VA_BUFFER_SIZE];
|
||||||
static int g_vaNextBufferIndex = 0;
|
static int g_vaNextBufferIndex = 0;
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
char* dest = g_vaBuffer[g_vaNextBufferIndex];
|
char* dest = g_vaBuffer[g_vaNextBufferIndex];
|
||||||
vsnprintf_s(g_vaBuffer[g_vaNextBufferIndex], VA_BUFFER_SIZE, fmt, ap);
|
vsnprintf_s(g_vaBuffer[g_vaNextBufferIndex], VA_BUFFER_SIZE, fmt, ap);
|
||||||
g_vaNextBufferIndex = (g_vaNextBufferIndex + 1) % VA_BUFFER_COUNT;
|
g_vaNextBufferIndex = (g_vaNextBufferIndex + 1) % VA_BUFFER_COUNT;
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToLower(std::string input)
|
std::string ToLower(std::string input)
|
||||||
|
Loading…
Reference in New Issue
Block a user