diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2014-03-25 04:57:02 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2014-03-25 04:57:02 +0400 |
commit | b66a9543bbcf86646b46af1da7ed0c4d035c7f98 (patch) | |
tree | cd5d607571dd9983eea2759d9623acbcbe291942 /source/gameengine/Ketsji | |
parent | a2c002acb9e7771645c25203576e1bd09a84561a (diff) |
Fix T38929: BGE: Strange behaving from addObject after trying to add an nonexisting overlay scene
If bge.logic.addScene() could not find the scene to add it would add the
first scene again, which is just silly. Now, if no scene is found, a warning
is printed and nothing is added.
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 3aa5a9f4f0e..e6b22420d90 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1702,6 +1702,8 @@ KX_Scene* KX_KetsjiEngine::CreateScene(Scene *scene, bool libloading) KX_Scene* KX_KetsjiEngine::CreateScene(const STR_String& scenename) { Scene *scene = m_sceneconverter->GetBlenderSceneForName(scenename); + if (!scene) + return NULL; return CreateScene(scene); } @@ -1717,8 +1719,12 @@ void KX_KetsjiEngine::AddScheduledScenes() { STR_String scenename = *scenenameit; KX_Scene* tmpscene = CreateScene(scenename); - m_scenes.push_back(tmpscene); - PostProcessScene(tmpscene); + if (tmpscene) { + m_scenes.push_back(tmpscene); + PostProcessScene(tmpscene); + } else { + printf("warning: scene %s could not be found, not added!\n",scenename.ReadPtr()); + } } m_addingOverlayScenes.clear(); } @@ -1731,9 +1737,12 @@ void KX_KetsjiEngine::AddScheduledScenes() { STR_String scenename = *scenenameit; KX_Scene* tmpscene = CreateScene(scenename); - m_scenes.insert(m_scenes.begin(),tmpscene); - PostProcessScene(tmpscene); - + if (tmpscene) { + m_scenes.insert(m_scenes.begin(),tmpscene); + PostProcessScene(tmpscene); + } else { + printf("warning: scene %s could not be found, not added!\n",scenename.ReadPtr()); + } } m_addingBackgroundScenes.clear(); } |