From 7f358894b1a3bf3dd26cb8195f195ea878fb8777 Mon Sep 17 00:00:00 2001 From: Porteries Tristan Date: Thu, 23 Aug 2018 19:29:48 +0200 Subject: [PATCH] UPBGE: Load scripts and actions before converting scene during libload. Previously the scripts where loaded after the scene was converted and caused the python component conversion to failed because the script wasn't reachable at the import. This is fixed by moving the call to addImportMain before the scene conversion. Similar behaviour is applied for the actions. --- source/gameengine/Converter/BL_Converter.cpp | 37 ++++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/source/gameengine/Converter/BL_Converter.cpp b/source/gameengine/Converter/BL_Converter.cpp index 080028bc01f8..3f28ae59dff8 100644 --- a/source/gameengine/Converter/BL_Converter.cpp +++ b/source/gameengine/Converter/BL_Converter.cpp @@ -435,6 +435,24 @@ KX_LibLoadStatus *BL_Converter::LinkBlendFile(BlendHandle *blendlib, const char else if (idcode == ID_SCE) { // Merge all new linked in scene into the existing one +#ifdef WITH_PYTHON + // Handle any text datablocks + if (options & LIB_LOAD_LOAD_SCRIPTS) { + addImportMain(main_newlib); + } +#endif + // Now handle all the actions + if (options & LIB_LOAD_LOAD_ACTIONS) { + ID *action; + + for (action = (ID *)main_newlib->action.first; action; action = (ID *)action->next) { + if (options & LIB_LOAD_VERBOSE) { + CM_Debug("action name: " << action->name + 2); + } + scene_merge->GetLogicManager()->RegisterActionName(action->name + 2, action); + } + } + if (options & LIB_LOAD_ASYNC) { std::vector scenes; for (Scene *bscene = (Scene *)main_newlib->scene.first; bscene; bscene = (Scene *)bscene->id.next) { @@ -465,25 +483,6 @@ KX_LibLoadStatus *BL_Converter::LinkBlendFile(BlendHandle *blendlib, const char MergeScene(scene_merge, sceneConverter); } } - -#ifdef WITH_PYTHON - // Handle any text datablocks - if (options & LIB_LOAD_LOAD_SCRIPTS) { - addImportMain(main_newlib); - } -#endif - - // Now handle all the actions - if (options & LIB_LOAD_LOAD_ACTIONS) { - ID *action; - - for (action = (ID *)main_newlib->action.first; action; action = (ID *)action->next) { - if (options & LIB_LOAD_VERBOSE) { - CM_Debug("action name: " << action->name + 2); - } - scene_merge->GetLogicManager()->RegisterActionName(action->name + 2, action); - } - } } if (!(options & LIB_LOAD_ASYNC)) {