Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/MapGenerator.h
Show All 17 Lines | |||||
#ifndef INCLUDED_MAPGENERATOR | #ifndef INCLUDED_MAPGENERATOR | ||||
#define INCLUDED_MAPGENERATOR | #define INCLUDED_MAPGENERATOR | ||||
#include "ps/FileIo.h" | #include "ps/FileIo.h" | ||||
#include "ps/Future.h" | #include "ps/Future.h" | ||||
#include "ps/TemplateLoader.h" | #include "ps/TemplateLoader.h" | ||||
#include "scriptinterface/StructuredClone.h" | #include "scriptinterface/StructuredClone.h" | ||||
#include <atomic> | |||||
#include <boost/random/linear_congruential.hpp> | #include <boost/random/linear_congruential.hpp> | ||||
#include <mutex> | #include <mutex> | ||||
#include <set> | #include <set> | ||||
#include <string> | #include <string> | ||||
class CMapGeneratorWorker; | class CMapGeneratorWorker; | ||||
/** | /** | ||||
Show All 18 Lines | public: | ||||
*/ | */ | ||||
void GenerateMap(const VfsPath& scriptFile, const std::string& settings); | void GenerateMap(const VfsPath& scriptFile, const std::string& settings); | ||||
/** | /** | ||||
* Get status of the map generator thread | * Get status of the map generator thread | ||||
* | * | ||||
* @return Progress percentage 1-100 if active, 0 when finished, or -1 on error | * @return Progress percentage 1-100 if active, 0 when finished, or -1 on error | ||||
*/ | */ | ||||
int GetProgress(); | int GetProgress() const; | ||||
/** | /** | ||||
* Get random map data, according to this format: | * Get random map data, according to this format: | ||||
* http://trac.wildfiregames.com/wiki/Random_Map_Generator_Internals#Dataformat | * http://trac.wildfiregames.com/wiki/Random_Map_Generator_Internals#Dataformat | ||||
* | * | ||||
* @return StructuredClone containing map data | * @return StructuredClone containing map data | ||||
*/ | */ | ||||
Script::StructuredClone GetResults(); | Script::StructuredClone GetResults(); | ||||
Show All 26 Lines | public: | ||||
*/ | */ | ||||
void Initialize(const VfsPath& scriptFile, const std::string& settings); | void Initialize(const VfsPath& scriptFile, const std::string& settings); | ||||
/** | /** | ||||
* Get status of the map generator thread | * Get status of the map generator thread | ||||
* | * | ||||
* @return Progress percentage 1-100 if active, 0 when finished, or -1 on error | * @return Progress percentage 1-100 if active, 0 when finished, or -1 on error | ||||
*/ | */ | ||||
int GetProgress(); | int GetProgress() const; | ||||
/** | /** | ||||
* Get random map data, according to this format: | * Get random map data, according to this format: | ||||
* http://trac.wildfiregames.com/wiki/Random_Map_Generator_Internals#Dataformat | * http://trac.wildfiregames.com/wiki/Random_Map_Generator_Internals#Dataformat | ||||
* | * | ||||
* @return StructuredClone containing map data | * @return StructuredClone containing map data | ||||
*/ | */ | ||||
Script::StructuredClone GetResults(); | Script::StructuredClone GetResults(); | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | private: | ||||
/** | /** | ||||
* Deterministic random number generator. | * Deterministic random number generator. | ||||
*/ | */ | ||||
boost::rand48 m_MapGenRNG; | boost::rand48 m_MapGenRNG; | ||||
/** | /** | ||||
* Current map generation progress. | * Current map generation progress. | ||||
*/ | */ | ||||
int m_Progress; | std::atomic<int> m_Progress; | ||||
/** | /** | ||||
* Provides the script context. | * Provides the script context. | ||||
*/ | */ | ||||
ScriptInterface* m_ScriptInterface; | ScriptInterface* m_ScriptInterface; | ||||
/** | /** | ||||
* Map generation script to run. | * Map generation script to run. | ||||
Show All 27 Lines |
Wildfire Games · Phabricator