diff options
author | sapier <Sapier at GMX dot net> | 2013-04-07 16:34:35 +0200 |
---|---|---|
committer | Kahrl <kahrl@gmx.net> | 2013-05-26 01:45:46 +0200 |
commit | efc75db76458dc473043043ca72c18701436dec8 (patch) | |
tree | a52905409d4d18733595eaf2ef468d63325c0226 /src | |
parent | f62ddf9022588f6c93fe6cdf2244640dd96dc186 (diff) | |
download | minetest-efc75db76458dc473043043ca72c18701436dec8.tar.gz minetest-efc75db76458dc473043043ca72c18701436dec8.tar.bz2 minetest-efc75db76458dc473043043ca72c18701436dec8.zip |
Bugfix: Update formname on showing new formspec while already one shown
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp index 4f0d1b663..ffc69d739 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -134,6 +134,10 @@ struct TextDestPlayerInventory : public TextDest m_client->sendInventoryFields(m_formname, fields); } + void setFormName(std::string formname) { + m_formname = formname; + } + Client *m_client; std::string m_formname; }; @@ -920,6 +924,7 @@ void the_game( ) { FormspecFormSource* current_formspec = 0; + TextDestPlayerInventory* current_textdest = 0; video::IVideoDriver* driver = device->getVideoDriver(); scene::ISceneManager* smgr = device->getSceneManager(); @@ -2236,19 +2241,23 @@ void the_game( if (current_formspec == 0) { /* Create menu */ + /* Note: FormspecFormSource and TextDestPlayerInventory + * are deleted by guiFormSpecMenu */ current_formspec = new FormspecFormSource(*(event.show_formspec.formspec),¤t_formspec); - + current_textdest = new TextDestPlayerInventory(&client,*(event.show_formspec.formname)); GUIFormSpecMenu *menu = new GUIFormSpecMenu(device, guiroot, -1, &g_menumgr, &client, gamedef); menu->setFormSource(current_formspec); - menu->setTextDest(new TextDestPlayerInventory(&client,*(event.show_formspec.formname))); + menu->setTextDest(current_textdest); menu->drop(); } else { + assert(current_textdest != 0); /* update menu */ + current_textdest->setFormName(*(event.show_formspec.formname)); current_formspec->setForm(*(event.show_formspec.formspec)); } delete(event.show_formspec.formspec); |