fix bug which caused Lua hot-reload not to report syntax errors

This commit is contained in:
Lion Kortlepel 2022-07-20 14:56:58 +02:00
parent 2ed92c4aa1
commit f21d3d0389
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B
2 changed files with 8 additions and 3 deletions

View File

@ -11,6 +11,7 @@
- FIXED a fatal exception on LuaEngine startup if Resources/Server is a symlink - FIXED a fatal exception on LuaEngine startup if Resources/Server is a symlink
- FIXED onInit not being called on hot-reload - FIXED onInit not being called on hot-reload
- FIXED incorrect timing calculation of Lua EventTimer loop - FIXED incorrect timing calculation of Lua EventTimer loop
- FIXED bug which caused hot-reload not to report syntax errors
# v3.0.2 # v3.0.2

View File

@ -48,9 +48,13 @@ void TPluginMonitor::operator()() {
TLuaChunk Chunk(Contents, Pair.first, fs::path(Pair.first).parent_path().string()); TLuaChunk Chunk(Contents, Pair.first, fs::path(Pair.first).parent_path().string());
auto StateID = mEngine->GetStateIDForPlugin(fs::path(Pair.first).parent_path()); auto StateID = mEngine->GetStateIDForPlugin(fs::path(Pair.first).parent_path());
auto Res = mEngine->EnqueueScript(StateID, Chunk); auto Res = mEngine->EnqueueScript(StateID, Chunk);
mEngine->AddResultToCheck(Res); Res->WaitUntilReady();
if (Res->Error) {
beammp_lua_errorf("Error while hot-reloading \"{}\": {}", Pair.first, Res->ErrorMessage);
} else {
mEngine->ReportErrors(mEngine->TriggerLocalEvent(StateID, "onInit")); mEngine->ReportErrors(mEngine->TriggerLocalEvent(StateID, "onInit"));
mEngine->ReportErrors(mEngine->TriggerEvent("onFileChanged", "", Pair.first)); mEngine->ReportErrors(mEngine->TriggerEvent("onFileChanged", "", Pair.first));
}
} else { } else {
// is in subfolder, dont reload, just trigger an event // is in subfolder, dont reload, just trigger an event
beammp_debugf("File \"{}\" changed, not reloading because it's in a subdirectory. Triggering 'onFileChanged' event instead", Pair.first); beammp_debugf("File \"{}\" changed, not reloading because it's in a subdirectory. Triggering 'onFileChanged' event instead", Pair.first);