Lua: Call onInit properly

This commit is contained in:
Lion Kortlepel
2021-09-17 02:26:49 +02:00
parent bac476ec34
commit 1880536276
+5 -5
View File
@@ -40,11 +40,11 @@ void TLuaEngine::operator()() {
// lua engine main thread // lua engine main thread
CollectAndInitPlugins(); CollectAndInitPlugins();
// now call all onInit's // now call all onInit's
for (const auto& Pair : mLuaStates) { auto Futures = TriggerEvent("onInit");
auto Res = EnqueueFunctionCall(Pair.first, "onInit", {}); WaitForAll(Futures);
Res->WaitUntilReady(); // FIXME this dumb, dont do this, this is smelly! for (const auto& Future : Futures) {
if (Res->Error && Res->ErrorMessage != TLuaEngine::BeamMPFnNotFoundError) { if (Future->Error) {
beammp_lua_error("Calling \"onInit\" on \"" + Pair.first + "\" failed: " + Res->ErrorMessage); beammp_lua_error("Calling \"onInit\" on \"" + Future->StateId + "\" failed: " + Future->ErrorMessage);
} }
} }
// this thread handles timers // this thread handles timers