mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Pass the size in meters of a terrain grid tile from Terrain.h to the rmgen JS code to avoid hardcoding thereof.
Refs #4034, D900 Differential Revision: https://code.wildfiregames.com/D1059 Reviewed By: s0600204 This was SVN commit r20504.
This commit is contained in:
parent
4734997098
commit
7a17a3152c
3 changed files with 16 additions and 0 deletions
|
|
@ -10,6 +10,13 @@ const FALLBACK_CIV = "athen";
|
|||
*/
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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 @@ bool CMapGeneratorWorker::Run()
|
|||
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::FindActorTemplates>("FindActorTemplates");
|
||||
m_ScriptInterface->RegisterFunction<int, CMapGeneratorWorker::GetTerrainTileSize>("GetTerrainTileSize");
|
||||
|
||||
// Parse settings
|
||||
JS::RootedValue settingsVal(cx);
|
||||
|
|
@ -271,6 +273,12 @@ std::vector<std::string> CMapGeneratorWorker::FindActorTemplates(ScriptInterface
|
|||
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
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ private:
|
|||
static bool TemplateExists(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName);
|
||||
static std::vector<std::string> FindTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories);
|
||||
static std::vector<std::string> FindActorTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories);
|
||||
static int GetTerrainTileSize(ScriptInterface::CxPrivate* pCxPrivate);
|
||||
|
||||
std::set<std::wstring> m_LoadedLibraries;
|
||||
shared_ptr<ScriptInterface::StructuredClone> m_MapData;
|
||||
|
|
|
|||
Loading…
Reference in a new issue