Skip to content

Commit

Permalink
UPBGE: Load scripts and actions before converting scene during libload.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
panzergame committed Aug 23, 2018
1 parent fcbde82 commit 7f35889
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions source/gameengine/Converter/BL_Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<KX_Scene *> scenes;
for (Scene *bscene = (Scene *)main_newlib->scene.first; bscene; bscene = (Scene *)bscene->id.next) {
Expand Down Expand Up @@ -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)) {
Expand Down

1 comment on commit 7f35889

@youle31
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Please sign in to comment.