Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpAIManager.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 244 Lines • ▼ Show 20 Lines | bool LoadScripts(const std::wstring& moduleName) | ||||
// Ignore modules that are already loaded | // Ignore modules that are already loaded | ||||
if (m_LoadedModules.find(moduleName) != m_LoadedModules.end()) | if (m_LoadedModules.find(moduleName) != m_LoadedModules.end()) | ||||
return true; | return true; | ||||
// Mark this as loaded, to prevent it recursively loading itself | // Mark this as loaded, to prevent it recursively loading itself | ||||
m_LoadedModules.insert(moduleName); | m_LoadedModules.insert(moduleName); | ||||
// Load and execute *.js | // Load and execute *.js | ||||
// Sort them, so that modders can extend code from previously loaded files. | |||||
VfsPaths pathnames; | VfsPaths pathnames; | ||||
if (vfs::GetPathnames(g_VFS, L"simulation/ai/" + moduleName + L"/", L"*.js", pathnames) < 0) | if (vfs::GetPathnames(g_VFS, L"simulation/ai/" + moduleName + L"/", L"*.js", pathnames, true) < 0) | ||||
{ | { | ||||
LOGERROR("Failed to load AI scripts for module %s", utf8_from_wstring(moduleName)); | LOGERROR("Failed to load AI scripts for module %s", utf8_from_wstring(moduleName)); | ||||
return false; | return false; | ||||
} | } | ||||
for (const VfsPath& path : pathnames) | for (const VfsPath& path : pathnames) | ||||
{ | { | ||||
if (!m_ScriptInterface->LoadGlobalScriptFile(path)) | if (!m_ScriptInterface->LoadGlobalScriptFile(path)) | ||||
▲ Show 20 Lines • Show All 918 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator