Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/Simulation2.cpp
Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | |||||
bool CSimulation2Impl::LoadScripts(CComponentManager& componentManager, std::set<VfsPath>* loadedScripts, const VfsPath& path) | bool CSimulation2Impl::LoadScripts(CComponentManager& componentManager, std::set<VfsPath>* loadedScripts, const VfsPath& path) | ||||
{ | { | ||||
VfsPaths pathnames; | VfsPaths pathnames; | ||||
if (vfs::GetPathnames(g_VFS, path, L"*.js", pathnames) < 0) | if (vfs::GetPathnames(g_VFS, path, L"*.js", pathnames) < 0) | ||||
return false; | return false; | ||||
bool ok = true; | bool ok = true; | ||||
for (const VfsPath& path : pathnames) | for (const VfsPath& scriptPath : pathnames) | ||||
{ | { | ||||
if (loadedScripts) | if (loadedScripts) | ||||
loadedScripts->insert(path); | loadedScripts->insert(scriptPath); | ||||
LOGMESSAGE("Loading simulation script '%s'", path.string8()); | LOGMESSAGE("Loading simulation script '%s'", scriptPath.string8()); | ||||
if (!componentManager.LoadScript(path)) | if (!componentManager.LoadScript(scriptPath)) | ||||
ok = false; | ok = false; | ||||
} | } | ||||
return ok; | return ok; | ||||
} | } | ||||
bool CSimulation2Impl::LoadTriggerScripts(CComponentManager& componentManager, JS::HandleValue mapSettings, std::set<VfsPath>* loadedScripts) | bool CSimulation2Impl::LoadTriggerScripts(CComponentManager& componentManager, JS::HandleValue mapSettings, std::set<VfsPath>* loadedScripts) | ||||
{ | { | ||||
bool ok = true; | bool ok = true; | ||||
▲ Show 20 Lines • Show All 701 Lines • ▼ Show 20 Lines | if (ret != INFO::OK) | ||||
return std::vector<std::string>(); | return std::vector<std::string>(); | ||||
} | } | ||||
std::vector<std::string> data; | std::vector<std::string> data; | ||||
for (const VfsPath& p : pathnames) | for (const VfsPath& p : pathnames) | ||||
{ | { | ||||
// Load JSON file | // Load JSON file | ||||
CVFSFile file; | CVFSFile file; | ||||
PSRETURN ret = file.Load(g_VFS, p); | PSRETURN loadStatus = file.Load(g_VFS, p); | ||||
if (ret != PSRETURN_OK) | if (loadStatus != PSRETURN_OK) | ||||
{ | { | ||||
LOGERROR("GetJSONData: Failed to load file '%s': %s", p.string8(), GetErrorString(ret)); | LOGERROR("GetJSONData: Failed to load file '%s': %s", p.string8(), GetErrorString(loadStatus)); | ||||
continue; | continue; | ||||
} | } | ||||
data.push_back(file.DecodeUTF8()); // assume it's UTF-8 | data.push_back(file.DecodeUTF8()); // assume it's UTF-8 | ||||
} | } | ||||
return data; | return data; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator