diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 055ae314..e4a83052 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -406,9 +406,9 @@ void Hud::add(const HudElement& element) { using namespace dynamic; gui->add(element.getNode()); - auto invview = std::dynamic_pointer_cast(element.getNode()); auto document = element.getDocument(); if (document) { + auto invview = std::dynamic_pointer_cast(element.getNode()); auto inventory = invview ? invview->getInventory() : nullptr; std::vector args; args.emplace_back(inventory ? inventory.get()->getId() : 0); diff --git a/src/graphics/render/WorldRenderer.cpp b/src/graphics/render/WorldRenderer.cpp index d9175be6..9dbe97c7 100644 --- a/src/graphics/render/WorldRenderer.cpp +++ b/src/graphics/render/WorldRenderer.cpp @@ -246,13 +246,13 @@ void WorldRenderer::renderBlockSelection() { void WorldRenderer::renderLines( Camera* camera, Shader* linesShader, const DrawContext& pctx ) { - auto ctx = pctx.sub(lineBatch.get()); linesShader->use(); linesShader->uniformMatrix("u_projview", camera->getProjView()); if (player->selection.vox.id != BLOCK_VOID) { renderBlockSelection(); } if (player->debug && showEntitiesDebug) { + auto ctx = pctx.sub(lineBatch.get()); bool culling = engine->getSettings().graphics.frustumCulling.get(); level->entities->renderDebug( *lineBatch, culling ? frustumCulling.get() : nullptr, ctx); diff --git a/src/logic/scripting/lua/libgui.cpp b/src/logic/scripting/lua/libgui.cpp index 7ae64d86..1829df06 100644 --- a/src/logic/scripting/lua/libgui.cpp +++ b/src/logic/scripting/lua/libgui.cpp @@ -324,8 +324,6 @@ static int l_gui_getattr(lua::State* L) { auto docname = lua::require_string(L, 1); auto element = lua::require_string(L, 2); auto attr = lua::require_string(L, 3); - auto docnode = getDocumentNode(L, docname, element); - auto node = docnode.node; static const std::unordered_map> getters { {"color", p_get_color}, @@ -367,6 +365,8 @@ static int l_gui_getattr(lua::State* L) { }; auto func = getters.find(attr); if (func != getters.end()) { + auto docnode = getDocumentNode(L, docname, element); + auto node = docnode.node; return func->second(node.get(), L); } return 0; diff --git a/src/logic/scripting/scripting.cpp b/src/logic/scripting/scripting.cpp index cb248f72..681cf3fa 100644 --- a/src/logic/scripting/scripting.cpp +++ b/src/logic/scripting/scripting.cpp @@ -240,8 +240,8 @@ void scripting::on_block_placed(Player* player, const Block* block, int x, int y } void scripting::on_block_broken(Player* player, const Block* block, int x, int y, int z) { - std::string name = block->name + ".broken"; if (block->rt.funcsset.onbroken) { + std::string name = block->name + ".broken"; lua::emit_event(lua::get_main_thread(), name, [x, y, z, player] (auto L) { lua::pushivec3_stack(L, x, y, z); lua::pushinteger(L, player ? player->getId() : -1);