Revert "[ZoneBuilder] Store inter-asset-related pointers"

This commit is contained in:
TheApadayo 2016-12-23 11:03:04 -05:00
parent 4c1859e871
commit d5e1c6a371
8 changed files with 18 additions and 53 deletions

View File

@ -126,13 +126,9 @@ namespace Assets
AssertSize(Game::cplane_t, 20); AssertSize(Game::cplane_t, 20);
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
builder->storePointer(asset->planes);
for (int i = 0; i < world->planeCount; ++i) buffer->saveArray(asset->planes, world->planeCount);
{
builder->storePointer(&asset->planes[i]);
buffer->save(&asset->planes[i]);
}
Utils::Stream::ClearPointer(&dest->planes); Utils::Stream::ClearPointer(&dest->planes);
} }
} }
@ -619,13 +615,9 @@ namespace Assets
else else
{ {
buffer->align(Utils::Stream::ALIGN_2); buffer->align(Utils::Stream::ALIGN_2);
builder->storePointer(aabbTree->smodelIndexes);
for (unsigned short k = 0; k < aabbTree->smodelIndexCount; ++k) buffer->saveArray(aabbTree->smodelIndexes, aabbTree->smodelIndexCount);
{
builder->storePointer(&aabbTree->smodelIndexes[k]);
buffer->save(&aabbTree->smodelIndexes[k]);
}
Utils::Stream::ClearPointer(&destAabbTree->smodelIndexes); Utils::Stream::ClearPointer(&destAabbTree->smodelIndexes);
} }
} }

View File

@ -40,7 +40,8 @@ namespace Assets
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
builder->storePointer(side->side); builder->storePointer(side->side);
buffer->save(side->side);
buffer->save(side->side, sizeof(Game::cplane_t));
Utils::Stream::ClearPointer(&destSide->side); Utils::Stream::ClearPointer(&destSide->side);
} }
} }
@ -67,13 +68,9 @@ namespace Assets
else else
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
builder->storePointer(brush->planes);
for (short i = 0; i < brush->brush.count; ++i) buffer->save(brush->planes, sizeof(Game::cplane_t));
{
builder->storePointer(&brush->planes[i]);
buffer->save(&brush->planes[i]);
}
Utils::Stream::ClearPointer(&destBrush->planes); Utils::Stream::ClearPointer(&destBrush->planes);
} }
} }

View File

@ -32,13 +32,9 @@ namespace Assets
else else
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
builder->storePointer(asset->cPlanes);
for (int i = 0; i < asset->numCPlanes; ++i) buffer->saveArray(asset->cPlanes, asset->numCPlanes);
{
builder->storePointer(&asset->cPlanes[i]);
buffer->save(&asset->cPlanes[i]);
}
Utils::Stream::ClearPointer(&dest->cPlanes); Utils::Stream::ClearPointer(&dest->cPlanes);
} }
@ -51,9 +47,8 @@ namespace Assets
AssertSize(Game::cStaticModel_t, 76); AssertSize(Game::cStaticModel_t, 76);
SaveLogEnter("cStaticModel_t"); SaveLogEnter("cStaticModel_t");
// xmodel is already stored
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
Utils::Stream::Offset mark = buffer->getOffset();
Game::cStaticModel_t* destStaticModelList = buffer->dest<Game::cStaticModel_t>(); Game::cStaticModel_t* destStaticModelList = buffer->dest<Game::cStaticModel_t>();
buffer->saveArray(asset->staticModelList, asset->numStaticModels); buffer->saveArray(asset->staticModelList, asset->numStaticModels);
@ -209,13 +204,9 @@ namespace Assets
else else
{ {
buffer->align(Utils::Stream::ALIGN_2); buffer->align(Utils::Stream::ALIGN_2);
builder->storePointer(node[i].data.brushes);
for (short j = 0; j < node[i].leafBrushCount; ++j) buffer->saveArray(node[i].data.brushes, node[i].leafBrushCount);
{
builder->storePointer(&node[i].data.brushes[j]);
buffer->save(&node[i].data.brushes[j]);
}
Utils::Stream::ClearPointer(&node[i].data.brushes); Utils::Stream::ClearPointer(&node[i].data.brushes);
} }
} }
@ -436,7 +427,7 @@ namespace Assets
if (asset->mapEnts) if (asset->mapEnts)
{ {
dest->mapEnts = builder->requireAsset(Game::XAssetType::ASSET_TYPE_MAP_ENTS, asset->mapEnts->name).mapEnts; dest->mapEnts = builder->requireAsset(Game::XAssetType::ASSET_TYPE_MAP_ENTS, asset->name).mapEnts;
} }
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)

View File

@ -374,14 +374,9 @@ namespace Components
return NULL; return NULL;
} }
void ZoneBuilder::Zone::storePointer(const void* pointer, Utils::Stream::Offset offset)
{
this->pointerMap[pointer] = offset.getPackedOffset();
}
void ZoneBuilder::Zone::storePointer(const void* pointer) void ZoneBuilder::Zone::storePointer(const void* pointer)
{ {
this->storePointer(pointer, this->buffer.getOffset()); this->pointerMap[pointer] = this->buffer.getPackedOffset();
} }
int ZoneBuilder::Zone::addScriptString(std::string str) int ZoneBuilder::Zone::addScriptString(std::string str)

View File

@ -20,7 +20,6 @@ namespace Components
bool hasPointer(const void* pointer); bool hasPointer(const void* pointer);
void storePointer(const void* pointer); void storePointer(const void* pointer);
void storePointer(const void* pointer, Utils::Stream::Offset offset);
template<typename T> template<typename T>
inline T* getPointer(const T* pointer) { return reinterpret_cast<T*>(this->safeGetPointer(pointer)); } inline T* getPointer(const T* pointer) { return reinterpret_cast<T*>(this->safeGetPointer(pointer)); }

View File

@ -1542,10 +1542,9 @@ namespace Game
struct cbrushWrapper_t struct cbrushWrapper_t
{ {
short count; short count;
short pad;
cbrushside_t* brushSide; cbrushside_t* brushSide;
char * brushEdge; char * brushEdge;
char pad2[24]; char pad[24];
}; };
#pragma pack(push, 4) #pragma pack(push, 4)

View File

@ -277,20 +277,14 @@ namespace Utils
return 0; return 0;
} }
Stream::Offset Stream::getOffset() DWORD Stream::getPackedOffset()
{ {
Game::XFILE_BLOCK_TYPES block = this->getCurrentBlock(); Game::XFILE_BLOCK_TYPES block = this->getCurrentBlock();
Stream::Offset offset; Stream::Offset offset;
offset.block = block; offset.block = block;
offset.offset = this->getBlockSize(block); offset.offset = this->getBlockSize(block);
return offset.getPackedOffset();
return offset;
}
DWORD Stream::getPackedOffset()
{
return this->getOffset().getPackedOffset();
} }
void Stream::toBuffer(std::string& outBuffer) void Stream::toBuffer(std::string& outBuffer)

View File

@ -177,7 +177,5 @@ namespace Utils
return lOffset.block; return lOffset.block;
}; };
}; };
Offset getOffset();
}; };
} }