MCPcopy Create free account
hub / github.com/defold/defold / Initialize

Function Initialize

engine/liveupdate/src/liveupdate.cpp:226–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224 // ******************************************************************
225
226 static dmExtension::Result Initialize(dmExtension::Params* params)
227 {
228 int32_t liveupdate_enabled = ConfigFileGetInt(params->m_ConfigFile, "liveupdate.enabled", 1);
229 if (!liveupdate_enabled)
230 {
231 dmLogError("Liveupdate disabled due to project setting %s=%d", "liveupdate.enabled", liveupdate_enabled);
232 return dmExtension::RESULT_OK;
233 }
234 g_LiveUpdate.m_IsEnabled = true;
235
236 // We initialize scripting first, as we might want to use file/http providers
237 JobSystemCreateParams job_thread_create_param = {0};
238 job_thread_create_param.m_ThreadNamePrefix = "liveupdate";
239 job_thread_create_param.m_ThreadCount = 1;
240
241 g_LiveUpdate.m_JobContext = JobSystemCreate(&job_thread_create_param);
242
243 dmResource::HFactory factory = (dmResource::HFactory)params->m_ResourceFactory;
244
245 if (g_LiveUpdate.m_JobContext) // Make the liveupdate module `nil` if it isn't available
246 {
247 if (params->m_L) // TODO: until unit tests have been updated with a Lua context
248 ScriptInit(params->m_L, factory);
249 }
250
251 g_LiveUpdate.m_ResourceMounts = dmResource::GetMountsContext(factory);
252 g_LiveUpdate.m_ResourceBaseArchive = dmResource::GetBaseArchive(factory);
253 g_LiveUpdate.m_MainContextHasExcludedResources = false;
254
255 if (g_LiveUpdate.m_ResourceBaseArchive)
256 {
257 dmResource::HManifest manifest;
258 dmResourceProvider::Result p_result = dmResourceProvider::GetManifest(g_LiveUpdate.m_ResourceBaseArchive, &manifest);
259 if (dmResourceProvider::RESULT_OK != p_result)
260 {
261 dmLogError("Could not get base archive manifest. Liveupdate disabled");
262 return dmExtension::RESULT_OK;
263 }
264
265 g_LiveUpdate.m_MainContextHasExcludedResources = dmResource::HasManifestExcludedEntries(manifest);
266 }
267
268 return dmExtension::RESULT_OK;
269 }
270
271 static dmExtension::Result Finalize(dmExtension::Params* params)
272 {

Callers

nothing calls this directly

Calls 7

ConfigFileGetIntFunction · 0.85
JobSystemCreateFunction · 0.85
ScriptInitFunction · 0.85
GetMountsContextFunction · 0.85
GetBaseArchiveFunction · 0.85
GetManifestFunction · 0.50

Tested by

no test coverage detected