Skip to content

Commit ade70fe

Browse files
committedAug 19, 2013
Allow SIGINT to kill mainmenu again
1 parent 4242782 commit ade70fe

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed
 

‎src/guiEngine.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
7979
gui::IGUIElement* parent,
8080
IMenuManager *menumgr,
8181
scene::ISceneManager* smgr,
82-
MainMenuData* data) :
82+
MainMenuData* data,
83+
bool& kill) :
8384
m_device(dev),
8485
m_parent(parent),
8586
m_menumanager(menumgr),
@@ -89,6 +90,7 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
8990
m_formspecgui(0),
9091
m_buttonhandler(0),
9192
m_menu(0),
93+
m_kill(kill),
9294
m_startgame(false),
9395
m_script(0),
9496
m_scriptdir(""),
@@ -219,7 +221,7 @@ void GUIEngine::run()
219221

220222
cloudInit();
221223

222-
while(m_device->run() && (!m_startgame)) {
224+
while(m_device->run() && (!m_startgame) && (!m_kill)) {
223225
driver->beginScene(true, true, video::SColor(255,140,186,250));
224226

225227
if (m_clouds_enabled)

‎src/guiEngine.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ class GUIEngine {
109109
gui::IGUIElement* parent,
110110
IMenuManager *menumgr,
111111
scene::ISceneManager* smgr,
112-
MainMenuData* data);
112+
MainMenuData* data,
113+
bool& kill);
113114

114115
/** default destructor */
115116
virtual ~GUIEngine();
@@ -159,6 +160,9 @@ class GUIEngine {
159160
/** the formspec menu */
160161
GUIFormSpecMenu* m_menu;
161162

163+
/** reference to kill variable managed by SIGINT handler */
164+
bool& m_kill;
165+
162166
/** variable used to abort menu and return back to main game handling */
163167
bool m_startgame;
164168

‎src/guiMainMenu.h

-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ struct MainMenuData
4949
int selected_world;
5050
bool simple_singleplayer_mode;
5151

52-
// Actions
53-
bool kill;
54-
5552
//error handling
5653
std::string errormessage;
5754
MainMenuData():

‎src/main.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,6 @@ int main(int argc, char *argv[])
15191519

15201520
// Initialize menu data
15211521
MainMenuData menudata;
1522-
menudata.kill = kill;
15231522
menudata.address = address;
15241523
menudata.name = playername;
15251524
menudata.port = itos(port);
@@ -1565,13 +1564,11 @@ int main(int argc, char *argv[])
15651564
}
15661565
infostream<<"Waited for other menus"<<std::endl;
15671566

1568-
GUIEngine* temp = new GUIEngine(device, guiroot, &g_menumgr,smgr,&menudata);
1567+
GUIEngine* temp = new GUIEngine(device, guiroot, &g_menumgr,smgr,&menudata,kill);
15691568

15701569
delete temp;
15711570
//once finished you'll never end up here
15721571
smgr->clear();
1573-
kill = menudata.kill;
1574-
15751572
}
15761573

15771574
if(menudata.errormessage != ""){

‎src/script/lua_api/l_mainmenu.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,7 @@ int ModApiMainMenu::l_close(lua_State *L)
131131
GUIEngine* engine = getGuiEngine(L);
132132
assert(engine != 0);
133133

134-
engine->m_data->kill = true;
135-
136-
//close menu next time
137-
engine->m_startgame = true;
138-
engine->m_menu->quitMenu();
134+
engine->m_kill = true;
139135
return 0;
140136
}
141137

0 commit comments

Comments
 (0)
Please sign in to comment.