summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2016-11-22 17:15:22 +0100
committerZeno- <kde.psych@gmail.com>2016-11-23 02:15:22 +1000
commit0d1c9598a0d2a4f21dc57de32efca2dc52b6b146 (patch)
treeea7280a8407472128ae90e1e4bb5ed3155392b19 /src/game.cpp
parentdbeb322f62bfdd431365622a6f5ddfae062c0d31 (diff)
downloadminetest-0d1c9598a0d2a4f21dc57de32efca2dc52b6b146.tar.gz
minetest-0d1c9598a0d2a4f21dc57de32efca2dc52b6b146.tar.bz2
minetest-0d1c9598a0d2a4f21dc57de32efca2dc52b6b146.zip
Make supplying empty formspec strings close the formspec (#4737)
This will only happen if the formname matches or if formname is "".
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 16287fe0d..671682348 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1205,6 +1205,7 @@ static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec,
(*cur_formspec)->setFormSource(fs_src);
(*cur_formspec)->setTextDest(txt_dest);
}
+
}
#ifdef __ANDROID__
@@ -1753,6 +1754,8 @@ private:
ChatBackend *chat_backend;
GUIFormSpecMenu *current_formspec;
+ //default: "". If other than "", empty show_formspec packets will only close the formspec when the formname matches
+ std::string cur_formname;
EventManager *eventmgr;
QuicktuneShortcutter *quicktune;
@@ -1841,6 +1844,7 @@ Game::Game() :
soundmaker(NULL),
chat_backend(NULL),
current_formspec(NULL),
+ cur_formname(""),
eventmgr(NULL),
quicktune(NULL),
gui_chat_console(NULL),
@@ -3005,6 +3009,7 @@ void Game::openInventory()
create_formspec_menu(&current_formspec, client, gamedef, texture_src,
device, &input->joystick, fs_src, txt_dst, client);
+ cur_formname = "";
InventoryLocation inventoryloc;
inventoryloc.setCurrentPlayer();
@@ -3484,14 +3489,21 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash)
player->hurt_tilt_strength = 0;
} else if (event.type == CE_SHOW_FORMSPEC) {
- FormspecFormSource *fs_src =
- new FormspecFormSource(*(event.show_formspec.formspec));
- TextDestPlayerInventory *txt_dst =
- new TextDestPlayerInventory(client, *(event.show_formspec.formname));
-
- create_formspec_menu(&current_formspec, client, gamedef,
- texture_src, device, &input->joystick,
- fs_src, txt_dst, client);
+ if (*(event.show_formspec.formspec) == "") {
+ if (current_formspec && ( *(event.show_formspec.formname) == "" || *(event.show_formspec.formname) == cur_formname) ){
+ current_formspec->quitMenu();
+ }
+ } else {
+ FormspecFormSource *fs_src =
+ new FormspecFormSource(*(event.show_formspec.formspec));
+ TextDestPlayerInventory *txt_dst =
+ new TextDestPlayerInventory(client, *(event.show_formspec.formname));
+
+ create_formspec_menu(&current_formspec, client, gamedef,
+ texture_src, device, &input->joystick,
+ fs_src, txt_dst, client);
+ cur_formname = *(event.show_formspec.formname);
+ }
delete(event.show_formspec.formspec);
delete(event.show_formspec.formname);
@@ -3955,6 +3967,7 @@ void Game::handlePointingAtNode(GameRunData *runData,
create_formspec_menu(&current_formspec, client, gamedef,
texture_src, device, &input->joystick, fs_src, txt_dst, client);
+ cur_formname = "";
current_formspec->setFormSpec(meta->getString("formspec"), inventoryloc);
} else {