From e93831319f8183f28f428b90d222884ad03a3557 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Thu, 22 Dec 2016 00:06:08 +0100 Subject: [PATCH] [ZoneBuilder] IGfxWorld and IclipMap_t fixes --- src/Components/Modules/AssetHandler.cpp | 5 ---- .../Modules/AssetInterfaces/IGfxWorld.cpp | 26 +++++++--------- .../Modules/AssetInterfaces/IclipMap_t.cpp | 30 +++++++++---------- src/Game/Structs.hpp | 2 +- 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index a6f1e41e..501d4657 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -240,7 +240,6 @@ namespace Components void AssetHandler::OffsetToAlias(Utils::Stream::Offset* offset) { - // Same here, reinterpret the value, as we're operating inside the game's environment void* pointer = (*Game::g_streamBlocks)[offset->getUnpackedBlock()].data + offset->getUnpackedOffset(); if (AssetHandler::Relocations.find(pointer) != AssetHandler::Relocations.end()) @@ -249,10 +248,6 @@ namespace Components } offset->pointer = *reinterpret_cast(pointer); - -#ifdef DEBUG - Game::XAssetHeader zob{ offset->pointer }; -#endif } void AssetHandler::ZoneSave(Game::XAsset asset, ZoneBuilder::Zone* builder) diff --git a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp index e6ad6c38..d8fea78d 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp @@ -146,7 +146,7 @@ namespace Assets if (asset->sceneEntCellBits) { buffer->align(Utils::Stream::ALIGN_4); - buffer->save(asset->sceneEntCellBits, 2048, asset->cellCount); + buffer->save(asset->sceneEntCellBits, 1, asset->cellCount << 11); Utils::Stream::ClearPointer(&dest->sceneEntCellBits); } @@ -166,12 +166,12 @@ namespace Assets Game::GfxImage** imageDest = buffer->dest(); buffer->saveArray(asset->reflectionImages, asset->reflectionProbeCount); - for (unsigned int i = 0; i < asset->reflectionProbeCount; i++) + for (unsigned int i = 0; i < asset->reflectionProbeCount; ++i) { imageDest[i] = builder->requireAsset(Game::XAssetType::ASSET_TYPE_IMAGE, asset->reflectionImages[i]->name).image; } - Utils::Stream::ClearPointer(asset->reflectionImages); + Utils::Stream::ClearPointer(&dest->reflectionImages); } if (asset->reflectionProbes) @@ -205,7 +205,7 @@ namespace Assets Game::GfxLightmapArray* lightmapArrayDestTable = buffer->dest(); buffer->saveArray(asset->lightmaps, asset->lightmapCount); - for (int i = 0; i < asset->lightmapCount; i++) + for (int i = 0; i < asset->lightmapCount; ++i) { Game::GfxLightmapArray* lightmapArrayDest = &lightmapArrayDestTable[i]; Game::GfxLightmapArray* lightmapArray = &asset->lightmaps[i]; @@ -221,7 +221,7 @@ namespace Assets } } - Utils::Stream::ClearPointer(asset->reflectionImages); + Utils::Stream::ClearPointer(&dest->lightmaps); } buffer->pushBlock(Game::XFILE_BLOCK_RUNTIME); @@ -256,13 +256,12 @@ namespace Assets { if (asset->vd.vertices) { + AssertSize(Game::GfxWorldVertex, 44); + buffer->align(Utils::Stream::ALIGN_4); buffer->saveArray(asset->vd.vertices, asset->vertexCount); Utils::Stream::ClearPointer(&dest->vd.vertices); } - - // this one has no if statement on purpouse - buffer->save(&asset->vd.worldVb, 1, 4); } // saveGfxWorldVertexLayerData @@ -274,8 +273,6 @@ namespace Assets buffer->saveArray(asset->vld.data, asset->vertexLayerDataSize); Utils::Stream::ClearPointer(&dest->vld.data); } - - buffer->save(&asset->vld.layerVb, 1, 4); } if (asset->indices) @@ -295,7 +292,7 @@ namespace Assets if (asset->rowDataStart) { buffer->align(Utils::Stream::ALIGN_2); - buffer->saveArray(asset->rowDataStart, (asset->maxs[asset->rowAxis] - asset->mins[asset->rowAxis]) + 2); + buffer->saveArray(asset->rowDataStart, (asset->maxs[asset->rowAxis] - asset->mins[asset->rowAxis]) + 1); Utils::Stream::ClearPointer(&dest->rowDataStart); } @@ -553,7 +550,7 @@ namespace Assets this->saveGfxWorldDpvsPlanes(asset, &asset->dpvsPlanes, &dest->dpvsPlanes, builder); - uint32_t cellCount = asset->dpvsPlanes.cellCount; + int cellCount = asset->dpvsPlanes.cellCount; if (asset->aabbTreeCounts) { @@ -572,7 +569,7 @@ namespace Assets Game::GfxCellTree* destCellTreeTable = buffer->dest(); buffer->saveArray(asset->aabbTrees, cellCount); - for (unsigned int i = 0; i < cellCount; ++i) + for (int i = 0; i < cellCount; ++i) { Game::GfxCellTree* destCellTree = &destCellTreeTable[i]; Game::GfxCellTree* cellTree = &asset->aabbTrees[i]; @@ -614,7 +611,6 @@ namespace Assets Utils::Stream::ClearPointer(&destCellTree->aabbTree); } - } Utils::Stream::ClearPointer(&dest->aabbTrees); @@ -628,7 +624,7 @@ namespace Assets Game::GfxCell* destCellTable = buffer->dest(); buffer->saveArray(asset->cells, cellCount); - for (unsigned int i = 0; i < cellCount; ++i) + for (int i = 0; i < cellCount; ++i) { Game::GfxCell* destCell = &destCellTable[i]; Game::GfxCell* cell = &asset->cells[i]; diff --git a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp index bb37082a..87ab4e34 100644 --- a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp +++ b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp @@ -29,9 +29,9 @@ namespace Assets } else { + buffer->align(Utils::Stream::ALIGN_4); builder->storePointer(asset->cPlanes); - - buffer->align(Utils::Stream::ALIGN_4); + buffer->saveArray(asset->cPlanes, asset->numCPlanes); Utils::Stream::ClearPointer(&dest->cPlanes); } @@ -93,9 +93,9 @@ namespace Assets } else { + buffer->align(Utils::Stream::ALIGN_4); builder->storePointer(sides[i].side); - - buffer->align(Utils::Stream::ALIGN_4); + buffer->save(sides[i].side); Utils::Stream::ClearPointer(&sides[i].side); } @@ -130,9 +130,9 @@ namespace Assets } else { + buffer->align(Utils::Stream::ALIGN_4); builder->storePointer(nodes[i].plane); - - buffer->align(Utils::Stream::ALIGN_4); + buffer->save(nodes[i].plane); Utils::Stream::ClearPointer(&nodes[i].plane); } @@ -178,9 +178,9 @@ namespace Assets } else { + buffer->align(Utils::Stream::ALIGN_2); builder->storePointer(node[i].data.brushes); - - buffer->align(Utils::Stream::ALIGN_2); + buffer->saveArray(node[i].data.brushes, node[i].leafBrushCount); Utils::Stream::ClearPointer(&node[i].data.brushes); } @@ -254,9 +254,9 @@ namespace Assets } else { + buffer->align(Utils::Stream::ALIGN_4); builder->storePointer(border[i].borders); - - buffer->align(Utils::Stream::ALIGN_4); + buffer->save(border[i].borders); Utils::Stream::ClearPointer(&border[i].borders); } @@ -302,11 +302,11 @@ namespace Assets } else { - builder->storePointer(brushes[i].brushSide); - AssertSize(Game::cbrushside_t, 8); - buffer->align(Utils::Stream::ALIGN_4); + buffer->align(Utils::Stream::ALIGN_4); + builder->storePointer(brushes[i].brushSide); + Game::cbrushside_t* side = buffer->dest(); buffer->save(brushes[i].brushSide); @@ -318,9 +318,9 @@ namespace Assets } else { + buffer->align(Utils::Stream::ALIGN_4); builder->storePointer(brushes[i].brushSide->side); - - buffer->align(Utils::Stream::ALIGN_4); + buffer->save(brushes[i].brushSide->side); Utils::Stream::ClearPointer(&side->side); } diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 0ff944fd..b8611108 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -2948,7 +2948,7 @@ namespace Game { GfxPortalWritable writable; DpvsPlane plane; - float(*vertices)[3]; + vec3_t* vertices; char unknown[2]; char vertexCount; float hullAxis[2][3];