Allow SIGINT to kill mainmenu again
authorKahrl <kahrl@gmx.net>
Mon, 19 Aug 2013 12:55:38 +0000 (14:55 +0200)
committerKahrl <kahrl@gmx.net>
Mon, 19 Aug 2013 13:49:36 +0000 (15:49 +0200)
src/guiEngine.cpp
src/guiEngine.h
src/guiMainMenu.h
src/main.cpp
src/script/lua_api/l_mainmenu.cpp

index f89ad873130486c54377a3962aafa974bc7c0c8d..f00cd039c59c3634d0f1d2af235996b179bdf15a 100644 (file)
@@ -79,7 +79,8 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
                                                gui::IGUIElement* parent,
                                                IMenuManager *menumgr,
                                                scene::ISceneManager* smgr,
-                                               MainMenuData* data) :
+                                               MainMenuData* data,
+                                               bool& kill) :
        m_device(dev),
        m_parent(parent),
        m_menumanager(menumgr),
@@ -89,6 +90,7 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
        m_formspecgui(0),
        m_buttonhandler(0),
        m_menu(0),
+       m_kill(kill),
        m_startgame(false),
        m_script(0),
        m_scriptdir(""),
@@ -219,7 +221,7 @@ void GUIEngine::run()
 
        cloudInit();
 
-       while(m_device->run() && (!m_startgame)) {
+       while(m_device->run() && (!m_startgame) && (!m_kill)) {
                driver->beginScene(true, true, video::SColor(255,140,186,250));
 
                if (m_clouds_enabled)
index 3987b52c73dc50df9e6446e86b6f54f3153ccdb6..6b7d3b6ed11ef24eaac418cbdc06c3985d8cbb75 100644 (file)
@@ -109,7 +109,8 @@ public:
                                gui::IGUIElement* parent,
                                IMenuManager *menumgr,
                                scene::ISceneManager* smgr,
-                               MainMenuData* data);
+                               MainMenuData* data,
+                               bool& kill);
 
        /** default destructor */
        virtual ~GUIEngine();
@@ -159,6 +160,9 @@ private:
        /** the formspec menu */
        GUIFormSpecMenu*                m_menu;
 
+       /** reference to kill variable managed by SIGINT handler */
+       bool&                                   m_kill;
+
        /** variable used to abort menu and return back to main game handling */
        bool                                    m_startgame;
 
index 5eaca23fa43cf500622b1072e078b0f75865b3fc..34362dba6495333422ff91d76e68e0c7092c9947 100644 (file)
@@ -49,9 +49,6 @@ struct MainMenuData
        int selected_world;
        bool simple_singleplayer_mode;
 
-       // Actions
-       bool kill;
-
        //error handling
        std::string errormessage;
        MainMenuData():
index 05a7dd1630e1f4ebc1d3b1fbd708c14006a19fc2..41acfe7b276ea621939a7d47d5abe3dc91df3809 100644 (file)
@@ -1519,7 +1519,6 @@ int main(int argc, char *argv[])
                                
                                // Initialize menu data
                                MainMenuData menudata;
-                               menudata.kill = kill;
                                menudata.address = address;
                                menudata.name = playername;
                                menudata.port = itos(port);
@@ -1565,13 +1564,11 @@ int main(int argc, char *argv[])
                                        }
                                        infostream<<"Waited for other menus"<<std::endl;
 
-                                       GUIEngine* temp = new GUIEngine(device, guiroot, &g_menumgr,smgr,&menudata);
+                                       GUIEngine* temp = new GUIEngine(device, guiroot, &g_menumgr,smgr,&menudata,kill);
                                        
                                        delete temp;
                                        //once finished you'll never end up here
                                        smgr->clear();
-                                       kill = menudata.kill;
-
                                }
 
                                if(menudata.errormessage != ""){
index 65676eacd244f07a47b83c6232845fc68bb81565..6417d1e183b15986ec4daa9b932372f0bafefd85 100644 (file)
@@ -131,11 +131,7 @@ int ModApiMainMenu::l_close(lua_State *L)
        GUIEngine* engine = getGuiEngine(L);
        assert(engine != 0);
 
-       engine->m_data->kill = true;
-
-       //close menu next time
-       engine->m_startgame = true;
-       engine->m_menu->quitMenu();
+       engine->m_kill = true;
        return 0;
 }