| 50 | } |
| 51 | |
| 52 | const void* Tr2CmfContents::GetSection( uint32_t index ) |
| 53 | { |
| 54 | if( index >= m_sections.size() ) |
| 55 | { |
| 56 | CCP_ASSERT_M( false, "Tr2CmfContents::GetSection: index out of range!" ); |
| 57 | return nullptr; |
| 58 | } |
| 59 | auto& section = m_sections[index]; |
| 60 | if( section.section.compression == cmf::SectionCompression::None ) |
| 61 | { |
| 62 | return m_sections[index].data.get(); |
| 63 | } |
| 64 | // May happen if the buffer has been unloaded from memory |
| 65 | if( !section.data ) |
| 66 | { |
| 67 | return nullptr; |
| 68 | } |
| 69 | |
| 70 | CCP_STATS_ZONE( __FUNCTION__ ); |
| 71 | |
| 72 | auto decompressed = std::make_unique<uint8_t[]>( section.section.uncompressedSize ); |
| 73 | cmf::Decompress( decompressed.get(), section.section, section.data.get() ); |
| 74 | std::swap( decompressed, section.data ); |
| 75 | section.section.compression = cmf::SectionCompression::None; |
| 76 | return section.data.get(); |
| 77 | } |
| 78 | |
| 79 | const void* Tr2CmfContents::GetViewData( const cmf::BufferView& view ) |
| 80 | { |
no test coverage detected