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

Method LoadProduct

Source/Engine/Engine/Base/GameBase.cpp:48–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48int32 GameBase::LoadProduct()
49{
50 // Startup and project root paths are the same in build game
51 Globals::ProjectFolder = Globals::StartupFolder;
52
53 // Load build game header file
54 {
55 int32 tmp;
56 Array<byte> data;
57 FileReadStream* stream = nullptr;
58
59#if 1
60 // Open file
61 stream = FileReadStream::Open(Globals::ProjectFolder / TEXT("Content/head"));
62 if (stream == nullptr)
63 goto LOAD_GAME_HEAD_FAILED;
64
65 // Check header
66 stream->ReadInt32(&tmp);
67 if (tmp != ('x' + 'D') * 131)
68 goto LOAD_GAME_HEAD_FAILED;
69
70 // Don't allow to load game packaged by the other engine version
71 stream->ReadInt32(&tmp);
72 if (tmp != FLAXENGINE_VERSION_BUILD)
73 goto LOAD_GAME_HEAD_FAILED;
74
75 // Load game primary data
76 stream->Read(data);
77 if (data.Count() != 808 + sizeof(Guid))
78 goto LOAD_GAME_HEAD_FAILED;
79 Encryption::DecryptBytes(data.Get(), data.Count());
80 Globals::ProductName = (const Char*)data.Get();
81 Globals::CompanyName = (const Char*)(data.Get() + 400);
82 GameBaseImpl::HeaderFlags = (GameHeaderFlags)*(int32*)(data.Get() + 800);
83 Globals::ContentKey = *(int32*)(data.Get() + 804);
84 GameBaseImpl::SplashScreenId = *(Guid*)(data.Get() + 808);
85
86 goto LOAD_GAME_HEAD_DONE;
87
88 LOAD_GAME_HEAD_FAILED:
89 Platform::Fatal(TEXT("Cannot load game."));
90 return -3;
91
92 LOAD_GAME_HEAD_DONE:
93 Delete(stream);
94#else
95 // Mock the settings to debug executable without content
96 Globals::ProductName = TEXT("Flax");
97 Globals::CompanyName = TEXT("Flax");
98 GameBaseImpl::HeaderFlags = GameHeaderFlags::ShowSplashScreen;
99 GameBaseImpl::SplashScreenId = Guid::Empty;
100 Globals::ContentKey = 0;
101#endif
102 }
103
104 return 0;
105}

Callers

nothing calls this directly

Calls 5

DeleteFunction · 0.85
ReadInt32Method · 0.45
ReadMethod · 0.45
CountMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected