| 2 | #include "RelocFile.h" |
| 3 | |
| 4 | std::shared_ptr<Ship::IResource> |
| 5 | ResourceFactoryBinaryRelocFileV0::ReadResource(std::shared_ptr<Ship::File> file, |
| 6 | std::shared_ptr<Ship::ResourceInitData> initData) { |
| 7 | if (!FileHasValidFormatAndReader(file, initData)) { |
| 8 | return nullptr; |
| 9 | } |
| 10 | |
| 11 | auto relocFile = std::make_shared<RelocFile>(initData); |
| 12 | auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader); |
| 13 | |
| 14 | relocFile->FileId = reader->ReadUInt32(); |
| 15 | relocFile->RelocInternOffset = reader->ReadUInt16(); |
| 16 | relocFile->RelocExternOffset = reader->ReadUInt16(); |
| 17 | |
| 18 | uint32_t numExternIds = reader->ReadUInt32(); |
| 19 | relocFile->ExternFileIds.reserve(numExternIds); |
| 20 | for (uint32_t i = 0; i < numExternIds; i++) { |
| 21 | relocFile->ExternFileIds.push_back(reader->ReadUInt16()); |
| 22 | } |
| 23 | |
| 24 | uint32_t dataSize = reader->ReadUInt32(); |
| 25 | relocFile->Data.resize(dataSize); |
| 26 | reader->Read(reinterpret_cast<char*>(relocFile->Data.data()), static_cast<int32_t>(dataSize)); |
| 27 | |
| 28 | return relocFile; |
| 29 | } |
nothing calls this directly
no outgoing calls
no test coverage detected