| 54 | namespace xiv::exd |
| 55 | { |
| 56 | Exd::Exd( std::shared_ptr< Exh > i_exh, const std::vector< std::shared_ptr< dat::File>>& i_files ) |
| 57 | { |
| 58 | _exh = i_exh; |
| 59 | _files = i_files; |
| 60 | |
| 61 | |
| 62 | // Iterates over all the files |
| 63 | const uint32_t member_count = _exh->get_members().size(); |
| 64 | for( auto& file_ptr : _files ) |
| 65 | { |
| 66 | // Get a stream |
| 67 | std::vector< char > dataCpy = file_ptr->get_data_sections().front(); |
| 68 | std::istringstream iss( std::string( dataCpy.begin(), dataCpy.end() ) ); |
| 69 | |
| 70 | // Extract the header and skip to the record indices |
| 71 | auto exd_header = extract< ExdHeader >( iss ); |
| 72 | iss.seekg( 0x20 ); |
| 73 | |
| 74 | // Preallocate and extract the record_indices |
| 75 | const uint32_t record_count = exd_header.index_size / sizeof( ExdRecordIndex ); |
| 76 | std::vector< ExdRecordIndex > record_indices; |
| 77 | record_indices.reserve( record_count ); |
| 78 | for( uint32_t i = 0; i < record_count; ++i ) |
| 79 | { |
| 80 | auto recordIndex = extract< ExdRecordIndex >( iss ); |
| 81 | _idCache[ recordIndex.id ] = ExdCacheEntry{ file_ptr, recordIndex.offset }; |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | Exd::~Exd() |
| 87 | { |