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

Method DoLoad

trinity/Resources/Tr2EffectRes.cpp:138–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138BlueAsyncRes::LoadingResult Tr2EffectRes::DoLoad()
139{
140 CCP_STATS_ZONE( __FUNCTION__ );
141
142 m_version = 0;
143 m_data.clear();
144 m_stringTable = nullptr;
145 m_stringTableSize = 0;
146 m_offsets = nullptr;
147 m_offsetCount = 0;
148 m_permutations.clear();
149
150 uint8_t* data = nullptr;
151 if( !m_dataStream->LockData( reinterpret_cast<void**>( &data ), 0 ) )
152 {
153 return LR_FAILED;
154 }
155
156 if( data == nullptr )
157 {
158 return LR_FAILED;
159 }
160
161 auto dataSize = m_dataStream->GetSize();
162
163
164 m_data.resize( "Tr2EffectRes::m_data", size_t( dataSize ) );
165
166 if( m_data.empty() )
167 {
168 m_dataStream->UnlockData();
169 return LR_FAILED;
170 }
171
172 memcpy( m_data.get(), data, size_t( dataSize ) );
173 m_dataStream->UnlockData();
174
175 const uint8_t* buffer = reinterpret_cast<const uint8_t*>( m_data.get() );
176 const uint8_t* bufferEnd = buffer + dataSize;
177
178#define SKIP( storeType ) \
179 if( buffer + sizeof( storeType ) > bufferEnd ) \
180 { \
181 CCP_LOGERR( "Unexpected end of file while reading effect \"%S\"", GetPath() ); \
182 return LR_FAILED; \
183 } \
184 buffer += sizeof( storeType );
185
186#define READ( storeType, valueType, value ) \
187 if( buffer + sizeof( storeType ) > bufferEnd ) \
188 { \
189 CCP_LOGERR( "Unexpected end of file while reading effect \"%S\"", GetPath() ); \
190 return LR_FAILED; \
191 } \
192 value = valueType( *reinterpret_cast<const storeType*>( buffer ) ); \
193 buffer += sizeof( storeType );
194
195#define READ_STRING( value ) \

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.80
getMethod · 0.80
GetSizeMethod · 0.45

Tested by

no test coverage detected