fix hud libraries not removing after on_hud_close & fix segfault on illegal access to hud functions

This commit is contained in:
MihailRis
2025-02-11 16:16:15 +03:00
parent b1740bf7eb
commit 0eeea9dde6
5 changed files with 63 additions and 49 deletions
+8 -1
View File
@@ -65,15 +65,22 @@ void scripting::on_frontend_render() {
}
void scripting::on_frontend_close() {
auto L = lua::get_main_state();
for (auto& pack : engine->getAllContentPacks()) {
lua::emit_event(
lua::get_main_state(),
L,
pack.id + ":.hudclose",
[&](lua::State* L) {
return lua::pushinteger(L, hud->getPlayer()->getId());
}
);
}
lua::pushnil(L);
lua::setglobal(L, "hud");
lua::pushnil(L);
lua::setglobal(L, "gfx");
scripting::renderer = nullptr;
scripting::hud = nullptr;
}