Skip to content

Commit 7463a73

Browse files
committed
Fixed unfound scene file lookup in packfiles
1 parent bc9cee5 commit 7463a73

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

engine/core/scene/SceneFile.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,33 @@ bool SceneFile::Deserialise(std::vector<Entity*>& entities)
102102
};
103103

104104
// TODO: Implement proper write-mode handling for scene system
105+
String ScenePath = MakeScenePath(sceneName);
105106
if (!SceneSystem::GetBaseDirectory().IsEmpty())
106107
{
107108
bool result = FileSystem::ForEachFileInDir(
108-
MakeScenePath(sceneName),
109+
ScenePath,
109110
[&deserialiseEntityString](const std::filesystem::path& path) {
110111
if (path.extension() != ENTITY_FILE_EXT) return;
111112
String entityData = FileSystem::Read(path.c_str());
112113
deserialiseEntityString(entityData, path);
113114
});
114115
if (!result)
115116
{
116-
CC_LOG_ERROR("Failed to read scene file at path \"{}\"", MakeScenePath(sceneName))
117+
CC_LOG_ERROR("Failed to read scene file at path \"{}\"", ScenePath)
117118
return false;
118119
}
119120
}
120121
else
121122
{
122123
PackFile* packFile = ResourceSystem::GetInstance().GetPackFile();
123-
SceneData* sceneData = packFile->FindData<SceneData>(MakeScenePath(sceneName));
124+
125+
SceneData* sceneData = packFile->FindData<SceneData>(ScenePath);
126+
if (!sceneData)
127+
{
128+
CC_LOG_WARNING("Failed to find scene \"{}\" in pack file", ScenePath)
129+
return false;
130+
}
131+
124132
String sceneString(sceneData->data);
125133
for (const String& entityData : sceneString.Split('|'))
126134
{

0 commit comments

Comments
 (0)