1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 14:24:33 +01:00

Allow scripting to be compile-disabled

This commit is contained in:
Ted John
2020-02-23 12:55:48 +00:00
parent 34078124cd
commit bac91cd563
17 changed files with 167 additions and 66 deletions

View File

@@ -55,8 +55,35 @@ void StdInOutConsole::Start()
std::future<void> StdInOutConsole::Eval(const std::string& s)
{
#ifdef __ENABLE_SCRIPTING__
auto& scriptEngine = GetContext()->GetScriptEngine();
return scriptEngine.Eval(s);
#else
// Push on-demand evaluations onto a queue so that it can be processed deterministically
// on the main thead at the right time.
std::promise<void> barrier;
auto future = barrier.get_future();
_evalQueue.emplace(std::move(barrier), s);
return future;
#endif
}
void StdInOutConsole::ProcessEvalQueue()
{
#ifndef __ENABLE_SCRIPTING__
while (_evalQueue.size() > 0)
{
auto item = std::move(_evalQueue.front());
_evalQueue.pop();
auto promise = std::move(std::get<0>(item));
auto command = std::move(std::get<1>(item));
Execute(command);
// Signal the promise so caller can continue
promise.set_value();
}
#endif
}
void StdInOutConsole::Clear()