From d5e1c6a371a07617898bedc91ac051fa69b1769d Mon Sep 17 00:00:00 2001 From: TheApadayo Date: Fri, 23 Dec 2016 11:03:04 -0500 Subject: [PATCH] Revert "[ZoneBuilder] Store inter-asset-related pointers" --- .../Modules/AssetInterfaces/IGfxWorld.cpp | 16 ++++---------- .../Modules/AssetInterfaces/IPhysCollmap.cpp | 11 ++++------ .../Modules/AssetInterfaces/IclipMap_t.cpp | 21 ++++++------------- src/Components/Modules/ZoneBuilder.cpp | 7 +------ src/Components/Modules/ZoneBuilder.hpp | 1 - src/Game/Structs.hpp | 3 +-- src/Utils/Stream.cpp | 10 ++------- src/Utils/Stream.hpp | 2 -- 8 files changed, 18 insertions(+), 53 deletions(-) diff --git a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp index 17a11e90..ad11c460 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp @@ -126,13 +126,9 @@ namespace Assets AssertSize(Game::cplane_t, 20); buffer->align(Utils::Stream::ALIGN_4); + builder->storePointer(asset->planes); - for (int i = 0; i < world->planeCount; ++i) - { - builder->storePointer(&asset->planes[i]); - buffer->save(&asset->planes[i]); - } - + buffer->saveArray(asset->planes, world->planeCount); Utils::Stream::ClearPointer(&dest->planes); } } @@ -619,13 +615,9 @@ namespace Assets else { buffer->align(Utils::Stream::ALIGN_2); + builder->storePointer(aabbTree->smodelIndexes); - for (unsigned short k = 0; k < aabbTree->smodelIndexCount; ++k) - { - builder->storePointer(&aabbTree->smodelIndexes[k]); - buffer->save(&aabbTree->smodelIndexes[k]); - } - + buffer->saveArray(aabbTree->smodelIndexes, aabbTree->smodelIndexCount); Utils::Stream::ClearPointer(&destAabbTree->smodelIndexes); } } diff --git a/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp b/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp index a3009a0f..2816050f 100644 --- a/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp +++ b/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp @@ -40,7 +40,8 @@ namespace Assets { buffer->align(Utils::Stream::ALIGN_4); builder->storePointer(side->side); - buffer->save(side->side); + + buffer->save(side->side, sizeof(Game::cplane_t)); Utils::Stream::ClearPointer(&destSide->side); } } @@ -67,13 +68,9 @@ namespace Assets else { buffer->align(Utils::Stream::ALIGN_4); + builder->storePointer(brush->planes); - for (short i = 0; i < brush->brush.count; ++i) - { - builder->storePointer(&brush->planes[i]); - buffer->save(&brush->planes[i]); - } - + buffer->save(brush->planes, sizeof(Game::cplane_t)); Utils::Stream::ClearPointer(&destBrush->planes); } } diff --git a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp index 8662f326..5e857645 100644 --- a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp +++ b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp @@ -32,13 +32,9 @@ namespace Assets else { buffer->align(Utils::Stream::ALIGN_4); + builder->storePointer(asset->cPlanes); - for (int i = 0; i < asset->numCPlanes; ++i) - { - builder->storePointer(&asset->cPlanes[i]); - buffer->save(&asset->cPlanes[i]); - } - + buffer->saveArray(asset->cPlanes, asset->numCPlanes); Utils::Stream::ClearPointer(&dest->cPlanes); } @@ -51,9 +47,8 @@ namespace Assets AssertSize(Game::cStaticModel_t, 76); SaveLogEnter("cStaticModel_t"); + // xmodel is already stored buffer->align(Utils::Stream::ALIGN_4); - - Utils::Stream::Offset mark = buffer->getOffset(); Game::cStaticModel_t* destStaticModelList = buffer->dest(); buffer->saveArray(asset->staticModelList, asset->numStaticModels); @@ -209,13 +204,9 @@ namespace Assets else { buffer->align(Utils::Stream::ALIGN_2); + builder->storePointer(node[i].data.brushes); - for (short j = 0; j < node[i].leafBrushCount; ++j) - { - builder->storePointer(&node[i].data.brushes[j]); - buffer->save(&node[i].data.brushes[j]); - } - + buffer->saveArray(node[i].data.brushes, node[i].leafBrushCount); Utils::Stream::ClearPointer(&node[i].data.brushes); } } @@ -436,7 +427,7 @@ namespace Assets 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) diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index 2c7be0c3..f62912b9 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -374,14 +374,9 @@ namespace Components 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) { - this->storePointer(pointer, this->buffer.getOffset()); + this->pointerMap[pointer] = this->buffer.getPackedOffset(); } int ZoneBuilder::Zone::addScriptString(std::string str) diff --git a/src/Components/Modules/ZoneBuilder.hpp b/src/Components/Modules/ZoneBuilder.hpp index bed43ef2..3f5b5b90 100644 --- a/src/Components/Modules/ZoneBuilder.hpp +++ b/src/Components/Modules/ZoneBuilder.hpp @@ -20,7 +20,6 @@ namespace Components bool hasPointer(const void* pointer); void storePointer(const void* pointer); - void storePointer(const void* pointer, Utils::Stream::Offset offset); template inline T* getPointer(const T* pointer) { return reinterpret_cast(this->safeGetPointer(pointer)); } diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index e7812a4a..50ca762f 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -1542,10 +1542,9 @@ namespace Game struct cbrushWrapper_t { short count; - short pad; cbrushside_t* brushSide; char * brushEdge; - char pad2[24]; + char pad[24]; }; #pragma pack(push, 4) diff --git a/src/Utils/Stream.cpp b/src/Utils/Stream.cpp index 79b08816..3dbce286 100644 --- a/src/Utils/Stream.cpp +++ b/src/Utils/Stream.cpp @@ -277,20 +277,14 @@ namespace Utils return 0; } - Stream::Offset Stream::getOffset() + DWORD Stream::getPackedOffset() { Game::XFILE_BLOCK_TYPES block = this->getCurrentBlock(); Stream::Offset offset; offset.block = block; offset.offset = this->getBlockSize(block); - - return offset; - } - - DWORD Stream::getPackedOffset() - { - return this->getOffset().getPackedOffset(); + return offset.getPackedOffset(); } void Stream::toBuffer(std::string& outBuffer) diff --git a/src/Utils/Stream.hpp b/src/Utils/Stream.hpp index b3449a5c..5e82686a 100644 --- a/src/Utils/Stream.hpp +++ b/src/Utils/Stream.hpp @@ -177,7 +177,5 @@ namespace Utils return lOffset.block; }; }; - - Offset getOffset(); }; }