Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/library.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/library.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen/library.js @@ -10,6 +10,13 @@ */ const MAX_HEIGHT_RANGE = 0xFFFF / HEIGHT_UNITS_PER_METRE; // Engine limit, Roughly 700 meters const MIN_HEIGHT = - SEA_LEVEL; + +/** + * Length of one tile of the terrain grid in metres. + * Useful to transform footprint sizes of templates to the coordinate system used by getMapSize. + */ +const TERRAIN_TILE_SIZE = RMS.GetTerrainTileSize(); + const MAX_HEIGHT = MAX_HEIGHT_RANGE - SEA_LEVEL; // Default angle for buildings const BUILDING_ORIENTATION = - PI / 4; Index: ps/trunk/source/graphics/MapGenerator.h =================================================================== --- ps/trunk/source/graphics/MapGenerator.h +++ ps/trunk/source/graphics/MapGenerator.h @@ -132,6 +132,7 @@ static bool TemplateExists(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName); static std::vector FindTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories); static std::vector FindActorTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories); + static int GetTerrainTileSize(ScriptInterface::CxPrivate* pCxPrivate); std::set m_LoadedLibraries; shared_ptr m_MapData; Index: ps/trunk/source/graphics/MapGenerator.cpp =================================================================== --- ps/trunk/source/graphics/MapGenerator.cpp +++ ps/trunk/source/graphics/MapGenerator.cpp @@ -19,6 +19,7 @@ #include "MapGenerator.h" +#include "graphics/Terrain.h" #include "lib/timer.h" #include "ps/CLogger.h" #include "ps/Profile.h" @@ -110,6 +111,7 @@ m_ScriptInterface->RegisterFunction("TemplateExists"); m_ScriptInterface->RegisterFunction, std::string, bool, CMapGeneratorWorker::FindTemplates>("FindTemplates"); m_ScriptInterface->RegisterFunction, std::string, bool, CMapGeneratorWorker::FindActorTemplates>("FindActorTemplates"); + m_ScriptInterface->RegisterFunction("GetTerrainTileSize"); // Parse settings JS::RootedValue settingsVal(cx); @@ -271,6 +273,12 @@ 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) { // Ignore libraries that are already loaded