Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/MapGenerator.cpp
Show All 33 Lines | |||||
#include "scriptinterface/ScriptRuntime.h" | #include "scriptinterface/ScriptRuntime.h" | ||||
#include "scriptinterface/ScriptConversions.h" | #include "scriptinterface/ScriptConversions.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "simulation2/helpers/MapEdgeTiles.h" | #include "simulation2/helpers/MapEdgeTiles.h" | ||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
// TODO: what's a good default? perhaps based on map size | // TODO: Maybe this should be optimized depending on the map size. | ||||
#define RMS_RUNTIME_SIZE 96 * 1024 * 1024 | constexpr int RMS_RUNTIME_SIZE = 96 * 1024 * 1024; | ||||
Stan: make it constexpr maybe? Instead of just changing the comment. | |||||
extern bool IsQuitRequested(); | extern bool IsQuitRequested(); | ||||
static bool | static bool | ||||
MapGeneratorInterruptCallback(JSContext* UNUSED(cx)) | MapGeneratorInterruptCallback(JSContext* UNUSED(cx)) | ||||
{ | { | ||||
// This may not use SDL_IsQuitRequested(), because it runs in a thread separate to SDL, see SDL_PumpEvents | // This may not use SDL_IsQuitRequested(), because it runs in a thread separate to SDL, see SDL_PumpEvents | ||||
if (IsQuitRequested()) | if (IsQuitRequested()) | ||||
Show All 32 Lines | void CMapGeneratorWorker::Initialize(const VfsPath& scriptFile, const std::string& settings) | ||||
m_WorkerThread = std::thread(RunThread, this); | m_WorkerThread = std::thread(RunThread, this); | ||||
} | } | ||||
void* CMapGeneratorWorker::RunThread(CMapGeneratorWorker* self) | void* CMapGeneratorWorker::RunThread(CMapGeneratorWorker* self) | ||||
{ | { | ||||
debug_SetThreadName("MapGenerator"); | debug_SetThreadName("MapGenerator"); | ||||
g_Profiler2.RegisterCurrentThread("MapGenerator"); | g_Profiler2.RegisterCurrentThread("MapGenerator"); | ||||
shared_ptr<ScriptRuntime> mapgenRuntime = ScriptInterface::CreateRuntime(g_ScriptRuntime, RMS_RUNTIME_SIZE); | shared_ptr<ScriptRuntime> mapgenRuntime = ScriptRuntime::CreateRuntime(RMS_RUNTIME_SIZE); | ||||
// Enable the script to be aborted | // Enable the script to be aborted | ||||
JS_SetInterruptCallback(mapgenRuntime->m_rt, MapGeneratorInterruptCallback); | JS_SetInterruptCallback(mapgenRuntime->m_rt, MapGeneratorInterruptCallback); | ||||
self->m_ScriptInterface = new ScriptInterface("Engine", "MapGenerator", mapgenRuntime); | self->m_ScriptInterface = new ScriptInterface("Engine", "MapGenerator", mapgenRuntime); | ||||
// Run map generation scripts | // Run map generation scripts | ||||
if (!self->Run() || self->m_Progress > 0) | if (!self->Run() || self->m_Progress > 0) | ||||
▲ Show 20 Lines • Show All 340 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
make it constexpr maybe? Instead of just changing the comment.