Skip to content

Commit e7e58ed

Browse files
committed
Fixed scene loading to log error and accept non lexically normal file paths
1 parent 2de1836 commit e7e58ed

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

Sources/OvCore/src/OvCore/SceneSystem/SceneManager.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
*/
66

77
#include <tinyxml2.h>
8-
#include <OvWindowing/Dialogs/MessageBox.h>
98

10-
#include "OvCore/SceneSystem/SceneManager.h"
11-
#include "OvCore/ECS/Components/CDirectionalLight.h"
12-
#include "OvCore/ECS/Components/CAmbientSphereLight.h"
13-
#include "OvCore/ECS/Components/CCamera.h"
9+
#include <OvCore/SceneSystem/SceneManager.h>
10+
#include <OvCore/ECS/Components/CDirectionalLight.h>
11+
#include <OvCore/ECS/Components/CAmbientSphereLight.h>
12+
#include <OvCore/ECS/Components/CCamera.h>
13+
#include <OvDebug/Logger.h>
14+
#include <OvTools/Utils/PathParser.h>
15+
#include <OvWindowing/Dialogs/MessageBox.h>
1416

1517
OvCore::SceneSystem::SceneManager::SceneManager(const std::string& p_sceneRootFolder) : m_sceneRootFolder(p_sceneRootFolder)
1618
{
@@ -68,10 +70,14 @@ bool OvCore::SceneSystem::SceneManager::LoadScene(const std::string& p_path, boo
6870
std::filesystem::current_path() :
6971
std::filesystem::path{ m_sceneRootFolder };
7072

71-
path /= p_path;
73+
path /= OvTools::Utils::PathParser::MakeNonWindowsStyle(p_path);
7274

7375
tinyxml2::XMLDocument doc;
74-
doc.LoadFile(path.string().c_str());
76+
if (doc.LoadFile(path.string().c_str()) != tinyxml2::XMLError::XML_SUCCESS)
77+
{
78+
OVLOG_ERROR(std::format("Failed to load scene: {}", path.string()));
79+
return false;
80+
}
7581

7682
if (LoadSceneFromMemory(doc))
7783
{

0 commit comments

Comments
 (0)