MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Load

Method Load

Source/Engine/Content/Storage/FlaxStorage.cpp:307–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307bool FlaxStorage::Load()
308{
309 if (IsLoaded())
310 return false;
311 PROFILE_MEM(ContentFiles);
312 ScopeLock lock(_loadLocker);
313 if (IsLoaded())
314 return false;
315 ASSERT(GetEntriesCount() == 0);
316
317 // Open file
318 auto stream = OpenFile();
319 if (stream == nullptr)
320 return true;
321
322 // Magic Code
323 uint32 magicCode;
324 stream->ReadUint32(&magicCode);
325 if (magicCode != MagicCode)
326 {
327 LOG(Warning, "Invalid asset magic code in {0}", ToString());
328 return true;
329 }
330
331 // Version
332 uint32 version;
333 stream->ReadUint32(&version);
334 switch (version)
335 {
336 case 9:
337 {
338 // Custom storage data
339 CustomData customData;
340 stream->Read(customData);
341
342#if USE_EDITOR
343 // Block loading packaged games content
344 if (customData.ContentKey != 0)
345#else
346 // Block load content from unknown sources
347 if (customData.ContentKey != Globals::ContentKey)
348#endif
349 {
350 LOG(Warning, "Invalid asset {0}.", ToString());
351 return true;
352 }
353
354 // Entries
355 int32 assetsCount;
356 stream->ReadInt32(&assetsCount);
357 for (int32 i = 0; i < assetsCount; i++)
358 {
359 SerializedEntryV9 se;
360 stream->ReadBytes(&se, sizeof(se));
361 Entry e(se.ID, se.TypeName.Data, se.Address);
362 AddEntry(e);
363 }
364

Callers 1

GetStorageMethod · 0.45

Calls 10

OpenFileFunction · 0.85
TypeId2TypeNameFunction · 0.85
ReadCharMethod · 0.80
IsLoadedFunction · 0.70
LocationClass · 0.70
ToStringFunction · 0.50
ReadMethod · 0.45
ReadInt32Method · 0.45
ReadBytesMethod · 0.45
GetPositionMethod · 0.45

Tested by

no test coverage detected