Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/graphics/MapGenerator.cpp
Show All 13 Lines | |||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "MapGenerator.h" | #include "MapGenerator.h" | ||||
#include "graphics/Terrain.h" | |||||
#include "lib/timer.h" | #include "lib/timer.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
// TODO: what's a good default? perhaps based on map size | // TODO: what's a good default? perhaps based on map size | ||||
#define RMS_RUNTIME_SIZE 96 * 1024 * 1024 | #define RMS_RUNTIME_SIZE 96 * 1024 * 1024 | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | bool CMapGeneratorWorker::Run() | ||||
m_ScriptInterface->RegisterFunction<void, CMapGeneratorWorker::MaybeGC>("MaybeGC"); | m_ScriptInterface->RegisterFunction<void, CMapGeneratorWorker::MaybeGC>("MaybeGC"); | ||||
m_ScriptInterface->RegisterFunction<bool, std::wstring, CMapGeneratorWorker::FileExists>("FileExists"); | m_ScriptInterface->RegisterFunction<bool, std::wstring, CMapGeneratorWorker::FileExists>("FileExists"); | ||||
m_ScriptInterface->RegisterFunction<JS::Value, std::wstring, CMapGeneratorWorker::ReadJSONFile> ("ReadJSONFile"); | m_ScriptInterface->RegisterFunction<JS::Value, std::wstring, CMapGeneratorWorker::ReadJSONFile> ("ReadJSONFile"); | ||||
m_ScriptInterface->RegisterFunction<std::vector<std::string>, CMapGeneratorWorker::GetCivData>("GetCivData"); | m_ScriptInterface->RegisterFunction<std::vector<std::string>, CMapGeneratorWorker::GetCivData>("GetCivData"); | ||||
m_ScriptInterface->RegisterFunction<CParamNode, std::string, CMapGeneratorWorker::GetTemplate>("GetTemplate"); | m_ScriptInterface->RegisterFunction<CParamNode, std::string, CMapGeneratorWorker::GetTemplate>("GetTemplate"); | ||||
m_ScriptInterface->RegisterFunction<bool, std::string, CMapGeneratorWorker::TemplateExists>("TemplateExists"); | m_ScriptInterface->RegisterFunction<bool, std::string, CMapGeneratorWorker::TemplateExists>("TemplateExists"); | ||||
m_ScriptInterface->RegisterFunction<std::vector<std::string>, std::string, bool, CMapGeneratorWorker::FindTemplates>("FindTemplates"); | m_ScriptInterface->RegisterFunction<std::vector<std::string>, std::string, bool, CMapGeneratorWorker::FindTemplates>("FindTemplates"); | ||||
m_ScriptInterface->RegisterFunction<std::vector<std::string>, std::string, bool, CMapGeneratorWorker::FindActorTemplates>("FindActorTemplates"); | m_ScriptInterface->RegisterFunction<std::vector<std::string>, std::string, bool, CMapGeneratorWorker::FindActorTemplates>("FindActorTemplates"); | ||||
m_ScriptInterface->RegisterFunction<int, CMapGeneratorWorker::GetTerrainTileSize>("GetTerrainTileSize"); | |||||
// Parse settings | // Parse settings | ||||
JS::RootedValue settingsVal(cx); | JS::RootedValue settingsVal(cx); | ||||
if (!m_ScriptInterface->ParseJSON(m_Settings, &settingsVal) && settingsVal.isUndefined()) | if (!m_ScriptInterface->ParseJSON(m_Settings, &settingsVal) && settingsVal.isUndefined()) | ||||
{ | { | ||||
LOGERROR("CMapGeneratorWorker::Run: Failed to parse settings"); | LOGERROR("CMapGeneratorWorker::Run: Failed to parse settings"); | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
std::vector<std::string> CMapGeneratorWorker::FindActorTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories) | std::vector<std::string> CMapGeneratorWorker::FindActorTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories) | ||||
{ | { | ||||
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData); | CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData); | ||||
return self->m_TemplateLoader.FindTemplates(path, includeSubdirectories, ACTOR_TEMPLATES); | return self->m_TemplateLoader.FindTemplates(path, includeSubdirectories, ACTOR_TEMPLATES); | ||||
} | } | ||||
int CMapGeneratorWorker::GetTerrainTileSize(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | |||||
{ | |||||
return TERRAIN_TILE_SIZE; | |||||
} | |||||
bool CMapGeneratorWorker::LoadScripts(const std::wstring& libraryName) | bool CMapGeneratorWorker::LoadScripts(const std::wstring& libraryName) | ||||
{ | { | ||||
// Ignore libraries that are already loaded | // Ignore libraries that are already loaded | ||||
if (m_LoadedLibraries.find(libraryName) != m_LoadedLibraries.end()) | if (m_LoadedLibraries.find(libraryName) != m_LoadedLibraries.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_LoadedLibraries.insert(libraryName); | m_LoadedLibraries.insert(libraryName); | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator