aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorROllerozxa <temporaryemail4meh+github@gmail.com>2021-12-13 17:43:29 +0100
committerGitHub <noreply@github.com>2021-12-13 17:43:29 +0100
commitfcf86ded8f8f5f0b0da9a59e4e9035838bf19d01 (patch)
treeecc32c21de1e7aa3b85b3cea328a3e24a70a2e9e /src
parent84efe279bb5fd5cce3f1d042b3aac412376fda1b (diff)
downloadminetest-fcf86ded8f8f5f0b0da9a59e4e9035838bf19d01.tar.gz
minetest-fcf86ded8f8f5f0b0da9a59e4e9035838bf19d01.tar.bz2
minetest-fcf86ded8f8f5f0b0da9a59e4e9035838bf19d01.zip
Disable inventory if player's inventory formspec is blank (#11827)
Diffstat (limited to 'src')
-rw-r--r--src/client/game.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 739409761..853a52ecf 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -2060,15 +2060,22 @@ void Game::openInventory()
InventoryLocation inventoryloc;
inventoryloc.setCurrentPlayer();
- if (!client->modsLoaded()
- || !client->getScript()->on_inventory_open(fs_src->m_client->getInventory(inventoryloc))) {
- TextDest *txt_dst = new TextDestPlayerInventory(client);
- auto *&formspec = m_game_ui->updateFormspec("");
- GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(),
- &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound);
+ if (client->modsLoaded() && client->getScript()->on_inventory_open(fs_src->m_client->getInventory(inventoryloc))) {
+ delete fs_src;
+ return;
+ }
- formspec->setFormSpec(fs_src->getForm(), inventoryloc);
+ if (fs_src->getForm().empty()) {
+ delete fs_src;
+ return;
}
+
+ TextDest *txt_dst = new TextDestPlayerInventory(client);
+ auto *&formspec = m_game_ui->updateFormspec("");
+ GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(),
+ &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound);
+
+ formspec->setFormSpec(fs_src->getForm(), inventoryloc);
}