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

Function LoadDebugInitScripts

engine/engine/src/engine.cpp:319–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317
318#if !defined(DM_RELEASE)
319 static bool LoadDebugInitScripts(HEngine engine)
320 {
321 const char* init_script = dmConfigFile::GetString(engine->m_Config, "bootstrap.debug_init_script", 0);
322 if (!init_script || init_script[0] == 0)
323 {
324 return true;
325 }
326
327 dmLogWarning("Using bootstrap.debug_init_script='%s'", init_script);
328
329 const uint32_t init_script_length = (uint32_t) strlen(init_script);
330 if (init_script_length >= 4096)
331 {
332 dmLogWarning("bootstrap.debug_init_script is too long (%u)", init_script_length);
333 return false;
334 }
335
336 char* init_script_buffer = (char*) dmAlloca(init_script_length + 1);
337 dmStrlCpy(init_script_buffer, init_script, init_script_length + 1);
338
339 char* iter = 0;
340 char* filename = dmStrTok(init_script_buffer, ",", &iter);
341 do
342 {
343 if (!filename || filename[0] == 0)
344 {
345 continue;
346 }
347
348 dmLuaDDF::LuaModule* lua_module = 0;
349 dmResource::Result r = dmGameObject::LoadLuaModule(engine->m_Factory, filename, &lua_module);
350 if (r != dmResource::RESULT_OK)
351 {
352 dmLogWarning("Failed to load script: %s (%d)", filename, r);
353 return false;
354 }
355
356 // Due to the fact that the same message can be loaded in two different ways, we have two separate call sites
357 // Here, we have an already resolved filename string.
358 if (engine->m_SharedScriptContext)
359 {
360 dmGameObject::LuaLoad(engine->m_Factory, engine->m_SharedScriptContext, lua_module);
361 }
362 else
363 {
364 dmGameObject::LuaLoad(engine->m_Factory, engine->m_GOScriptContext, lua_module);
365 dmGameObject::LuaLoad(engine->m_Factory, engine->m_GuiScriptContext, lua_module);
366 dmGameObject::LuaLoad(engine->m_Factory, engine->m_RenderScriptContext, lua_module);
367 }
368
369 dmDDF::FreeMessage(lua_module);
370
371 } while( (filename = dmStrTok(0, ",", &iter)) );
372
373 return true;
374 }
375#endif
376

Callers 1

engine.cppFile · 0.85

Calls 6

dmStrlCpyFunction · 0.85
dmStrTokFunction · 0.85
LoadLuaModuleFunction · 0.85
FreeMessageFunction · 0.85
GetStringFunction · 0.50
LuaLoadFunction · 0.50

Tested by

no test coverage detected