diff --git a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp index 06e85c78..b63f1d7e 100644 --- a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp +++ b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp @@ -586,6 +586,17 @@ namespace Assets return; } + Game::clipMap_t* orgClipMap = nullptr; + Game::DB_EnumXAssets(Game::XAssetType::ASSET_TYPE_MAP_ENTS, [](Game::XAssetHeader header, void* clipMap) + { + if (!*reinterpret_cast(clipMap)) + { + *reinterpret_cast(clipMap) = header.clipMap; + } + }, &orgClipMap, false); + + if (orgClipMap) std::memcpy(clipMap, orgClipMap, sizeof Game::clipMap_t); + Utils::Stream::Reader reader(builder->getAllocator(), clipFile.getBuffer()); __int64 magic = reader.read<__int64>(); @@ -880,6 +891,11 @@ namespace Assets Utils::Stream::ClearPointer(&clipMap->dynEntCollList[i]); } + if(!reader.end()) + { + Components::Logger::Error("Clipmap data left!"); + } + header->clipMap = clipMap; } } diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index b5f07ed8..8c219da1 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -2476,7 +2476,6 @@ namespace Game char edgeCount[2][3]; }; - struct cLeaf_t { unsigned __int16 firstCollAabbIndex; diff --git a/src/Utils/Stream.cpp b/src/Utils/Stream.cpp index 0cb9b2f0..08446e64 100644 --- a/src/Utils/Stream.cpp +++ b/src/Utils/Stream.cpp @@ -26,7 +26,7 @@ namespace Utils return this->buffer[this->position++]; } - return 0; + throw std::runtime_error("Reading past the buffer"); } void* Stream::Reader::read(size_t size, size_t count) @@ -43,7 +43,7 @@ namespace Utils return _buffer; } - return nullptr; + throw std::runtime_error("Reading past the buffer"); } bool Stream::Reader::end()