Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
MapGenerator.cpp File Reference
#include "precompiled.h"
#include "MapGenerator.h"
#include "graphics/MapIO.h"
#include "graphics/Patch.h"
#include "graphics/Terrain.h"
#include "lib/status.h"
#include "lib/timer.h"
#include "lib/file/vfs/vfs_path.h"
#include "maths/MathUtil.h"
#include "ps/CLogger.h"
#include "ps/FileIo.h"
#include "ps/scripting/JSInterface_VFS.h"
#include "ps/TemplateLoader.h"
#include "scriptinterface/FunctionWrapper.h"
#include "scriptinterface/JSON.h"
#include "scriptinterface/Object.h"
#include "scriptinterface/ScriptContext.h"
#include "scriptinterface/ScriptConversions.h"
#include "scriptinterface/ScriptInterface.h"
#include "simulation2/helpers/MapEdgeTiles.h"
#include <boost/random/linear_congruential.hpp>
#include <set>
#include <string>
#include <vector>
Include dependency graph for MapGenerator.cpp:

Classes

class  anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks
 Provides callback's for the JavaScript. More...
 

Namespaces

namespace  anonymous_namespace{MapGenerator.cpp}
 

Macros

#define REGISTER_MAPGEN_FUNC(func)
 

Functions

bool IsQuitRequested ()
 
bool anonymous_namespace{MapGenerator.cpp}::MapGenerationInterruptCallback (JSContext *cx)
 
Script::StructuredClone RunMapGenerationScript (std::atomic< int > &progress, ScriptInterface &scriptInterface, const VfsPath &script, const std::string &settings, const u16 flags)
 Generate the map. More...
 

Variables

constexpr const char * anonymous_namespace{MapGenerator.cpp}::GENERATOR_NAME {"GenerateMap"}
 

Macro Definition Documentation

◆ REGISTER_MAPGEN_FUNC

#define REGISTER_MAPGEN_FUNC (   func)
Value:
ScriptFunction::Register<&CMapGenerationCallbacks::func, \
ScriptInterface::ObjectFromCBData<CMapGenerationCallbacks>>(rq, #func, flags);
static void Register(const ScriptRequest &rq, const char *name, const u16 flags=JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT)
Register a function on the native scope (usually 'Engine').
Definition: FunctionWrapper.h:439

Function Documentation

◆ IsQuitRequested()

bool IsQuitRequested ( )

◆ RunMapGenerationScript()

Script::StructuredClone RunMapGenerationScript ( std::atomic< int > &  progress,
ScriptInterface scriptInterface,
const VfsPath script,
const std::string &  settings,
const u16  flags = JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT 
)

Generate the map.

This does take a long time.

Parameters
progressDestination to write the function progress to. You must not write to it while RunMapGenerationScript is running.
scriptThe VFS path for the script, e.g. "maps/random/latium.js".
settingsJSON string containing settings for the map generator.
flagsWith thous flags the engine functions get registered g_MapSettings also respects this flags.
Returns
If there is an error nullptr is returned. Otherwise random map data, according to this format: https://trac.wildfiregames.com/wiki/Random_Map_Generator_Internals#Dataformat