MCPcopy Create free account
hub / github.com/carbonengine/trinity / DoLoad

Method DoLoad

trinity/Resources/TriGrannyRes.cpp:200–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200BlueAsyncRes::LoadingResult TriGrannyRes::DoLoad()
201{
202 CCP_STATS_ZONE( __FUNCTION__ );
203
204 if( m_path.size() >= 4 && m_path.compare( m_path.size() - 4, 4, L".cmf" ) == 0 )
205 {
206 m_useCMF = true;
207
208 m_cmfContents = Tr2CmfContents( *m_dataStream, CW2A( m_path.c_str() ) );
209 if( !m_cmfContents )
210 {
211 return LR_FAILED;
212 }
213 m_memoryUsage = m_dataStream->GetSize();
214 }
215#if WITH_GRANNY
216 else
217 {
218 m_useCMF = false;
219
220 HandleGrannyDeprecation( m_path );
221
222 if( !m_dataStream->LockData( &m_data, 0 ) )
223 {
224 return LR_FAILED;
225 }
226
227 m_dataSize = m_dataStream->GetSize();
228
229 {
230 if( m_grannyFile )
231 {
232 GrannyFreeFile( m_grannyFile );
233 m_grannyFile = NULL;
234 }
235
236 CCP_STATS_ZONE( "TriGrannyRes::DoLoad reading Granny file" );
237
238 m_grannyFile = ProtectedGrannyReadEntireFileFromMemory( m_path.c_str(), (uint32_t)m_dataSize, m_data );
239 }
240
241 if( !m_grannyFile )
242 {
243 return LR_FAILED;
244 }
245
246 granny_file_info* fi = GrannyGetFileInfo( m_grannyFile );
247 if( !fi )
248 {
249 CCP_LOGERR( "TriGrannyRes::GetGrannyMesh: Granny file has no file info" );
250 return LR_FAILED;
251 }
252
253 m_memoryUsage = 0;
254 granny_grn_section* sections = GrannyGetGRNSectionArray( m_grannyFile->Header );
255 for( int i = 0; i < m_grannyFile->SectionCount; ++i )
256 {
257 m_memoryUsage += sections[i].ExpandedDataSize;

Callers

nothing calls this directly

Calls 5

Tr2CmfContentsClass · 0.85
HandleGrannyDeprecationFunction · 0.85
sizeMethod · 0.80
GetSizeMethod · 0.45

Tested by

no test coverage detected