Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/MapGenerator.h
Show All 22 Lines | |||||
#include "ps/TemplateLoader.h" | #include "ps/TemplateLoader.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include <boost/random/linear_congruential.hpp> | #include <boost/random/linear_congruential.hpp> | ||||
#include <mutex> | #include <mutex> | ||||
#include <set> | #include <set> | ||||
#include <string> | #include <string> | ||||
#include <thread> | |||||
class CMapGeneratorWorker; | class CMapGeneratorWorker; | ||||
/** | /** | ||||
* Random map generator interface. Initialized by CMapReader and then checked | * Random map generator interface. Initialized by CMapReader and then checked | ||||
* periodically during loading, until it's finished (progress value is 0). | * periodically during loading, until it's finished (progress value is 0). | ||||
* | * | ||||
* The actual work is performed by CMapGeneratorWorker in a separate thread. | * The actual work is performed by CMapGeneratorWorker in a separate thread. | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | private: | ||||
/** | /** | ||||
* Returns all template names of actors. | * Returns all template names of actors. | ||||
*/ | */ | ||||
static std::vector<std::string> FindActorTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories); | static std::vector<std::string> FindActorTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories); | ||||
/** | /** | ||||
* Perform map generation in an independent thread. | * Perform map generation in an independent thread. | ||||
*/ | */ | ||||
static void* RunThread(void* data); | static void* RunThread(CMapGeneratorWorker* self); | ||||
/** | /** | ||||
* Perform the map generation. | * Perform the map generation. | ||||
*/ | */ | ||||
bool Run(); | bool Run(); | ||||
/** | /** | ||||
* Currently loaded script librarynames. | * Currently loaded script librarynames. | ||||
Show All 33 Lines | private: | ||||
/** | /** | ||||
* Backend to loading template data. | * Backend to loading template data. | ||||
*/ | */ | ||||
CTemplateLoader m_TemplateLoader; | CTemplateLoader m_TemplateLoader; | ||||
/** | /** | ||||
* Holds the mapgeneration thread identifier. | * Holds the mapgeneration thread identifier. | ||||
*/ | */ | ||||
pthread_t m_WorkerThread; | std::thread m_WorkerThread; | ||||
/** | /** | ||||
* Avoids thread synchronization issues. | * Avoids thread synchronization issues. | ||||
*/ | */ | ||||
std::mutex m_WorkerMutex; | std::mutex m_WorkerMutex; | ||||
}; | }; | ||||
#endif //INCLUDED_MAPGENERATOR | #endif //INCLUDED_MAPGENERATOR |
Wildfire Games · Phabricator