Skip to content

Commit efc75db

Browse files
sapierkahrl
sapier
authored andcommittedMay 25, 2013
Bugfix: Update formname on showing new formspec while already one shown
1 parent f62ddf9 commit efc75db

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

‎src/game.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ struct TextDestPlayerInventory : public TextDest
134134
m_client->sendInventoryFields(m_formname, fields);
135135
}
136136

137+
void setFormName(std::string formname) {
138+
m_formname = formname;
139+
}
140+
137141
Client *m_client;
138142
std::string m_formname;
139143
};
@@ -920,6 +924,7 @@ void the_game(
920924
)
921925
{
922926
FormspecFormSource* current_formspec = 0;
927+
TextDestPlayerInventory* current_textdest = 0;
923928
video::IVideoDriver* driver = device->getVideoDriver();
924929
scene::ISceneManager* smgr = device->getSceneManager();
925930

@@ -2236,19 +2241,23 @@ void the_game(
22362241
if (current_formspec == 0)
22372242
{
22382243
/* Create menu */
2244+
/* Note: FormspecFormSource and TextDestPlayerInventory
2245+
* are deleted by guiFormSpecMenu */
22392246
current_formspec = new FormspecFormSource(*(event.show_formspec.formspec),&current_formspec);
2240-
2247+
current_textdest = new TextDestPlayerInventory(&client,*(event.show_formspec.formname));
22412248
GUIFormSpecMenu *menu =
22422249
new GUIFormSpecMenu(device, guiroot, -1,
22432250
&g_menumgr,
22442251
&client, gamedef);
22452252
menu->setFormSource(current_formspec);
2246-
menu->setTextDest(new TextDestPlayerInventory(&client,*(event.show_formspec.formname)));
2253+
menu->setTextDest(current_textdest);
22472254
menu->drop();
22482255
}
22492256
else
22502257
{
2258+
assert(current_textdest != 0);
22512259
/* update menu */
2260+
current_textdest->setFormName(*(event.show_formspec.formname));
22522261
current_formspec->setForm(*(event.show_formspec.formspec));
22532262
}
22542263
delete(event.show_formspec.formspec);

0 commit comments

Comments
 (0)
Please sign in to comment.