]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/guiEngine.cpp
Fix player:set_animation() in third person view
[dragonfireclient.git] / src / guiEngine.cpp
index 0ec68e3ae46771d55c0bd1db8178031d2ac64d56..e32d629d0da826d84b3e0d2d5964be23ea717240 100644 (file)
@@ -166,7 +166,7 @@ GUIEngine::GUIEngine(       irr::IrrlichtDevice* dev,
                rect,false,true,0,-1);
 
        //create formspecsource
-       m_formspecgui = new FormspecFormSource("",&m_formspecgui);
+       m_formspecgui = new FormspecFormSource("");
 
        /* Create menu */
        m_menu =
@@ -176,28 +176,30 @@ GUIEngine::GUIEngine(     irr::IrrlichtDevice* dev,
                                                                m_menumanager,
                                                                0 /* &client */,
                                                                0 /* gamedef */,
-                                                               m_texture_source);
+                                                               m_texture_source,
+                                                               m_formspecgui,
+                                                               m_buttonhandler,
+                                                               NULL);
 
        m_menu->allowClose(false);
        m_menu->lockSize(true,v2u32(800,600));
-       m_menu->setFormSource(m_formspecgui);
-       m_menu->setTextDest(m_buttonhandler);
 
        // Initialize scripting
 
-       infostream<<"GUIEngine: Initializing Lua"<<std::endl;
+       infostream << "GUIEngine: Initializing Lua" << std::endl;
 
        m_script = new MainMenuScripting(this);
 
        try {
-               if (m_data->errormessage != "")
-               {
+               if (m_data->errormessage != "") {
                        m_script->setMainMenuErrorMessage(m_data->errormessage);
                        m_data->errormessage = "";
                }
 
-               if (!loadMainMenuScript())
-                       assert("no future without mainmenu" == 0);
+               if (!loadMainMenuScript()) {
+                       errorstream << "No future without mainmenu" << std::endl;
+                       abort();
+               }
 
                run();
        }
@@ -226,7 +228,8 @@ bool GUIEngine::loadMainMenuScript()
                }
                else {
                        infostream
-                               << "GUIEngine: execution of custom menu failed!"
+                               << "GUIEngine: execution of custom menu: \""
+                               << menuscript << "\" failed!"
                                << std::endl
                                << "\tfalling back to builtin menu"
                                << std::endl;
@@ -288,7 +291,7 @@ void GUIEngine::run()
                else
                        sleep_ms(25);
 
-               m_script->Step();
+               m_script->step();
        }
 }
 
@@ -510,34 +513,25 @@ bool GUIEngine::setTexture(texture_layer layer,std::string texturepath) {
 /******************************************************************************/
 bool GUIEngine::downloadFile(std::string url,std::string target) {
 #if USE_CURL
-       bool retval = true;
-
-       FILE* targetfile = fopen(target.c_str(),"wb");
-
-       if (targetfile) {
-               HTTPFetchRequest fetchrequest;
-               HTTPFetchResult fetchresult;
-               fetchrequest.url = url;
-               fetchrequest.useragent = std::string("Minetest ")+minetest_version_hash;
-               fetchrequest.timeout = g_settings->getS32("curl_timeout");
-               fetchrequest.caller = HTTPFETCH_SYNC;
-               httpfetch_sync(fetchrequest,fetchresult);
-
-               if (fetchresult.succeeded) {
-                       if (fwrite(fetchresult.data.c_str(),1,fetchresult.data.size(),targetfile) != fetchresult.data.size()) {
-                               retval = false;
-                       }
-               }
-               else {
-                       retval = false;
-               }
-               fclose(targetfile);
+       std::ofstream targetfile(target.c_str(), std::ios::out | std::ios::binary);
+
+       if (!targetfile.good()) {
+               return false;
        }
-       else {
-               retval = false;
+
+       HTTPFetchRequest fetchrequest;
+       HTTPFetchResult fetchresult;
+       fetchrequest.url = url;
+       fetchrequest.caller = HTTPFETCH_SYNC;
+       httpfetch_sync(fetchrequest, fetchresult);
+
+       if (fetchresult.succeeded) {
+               targetfile << fetchresult.data;
+       } else {
+               return false;
        }
 
-       return retval;
+       return true;
 #else
        return false;
 #endif
@@ -569,7 +563,8 @@ void GUIEngine::stopSound(s32 handle)
 }
 
 /******************************************************************************/
-unsigned int GUIEngine::DoAsync(std::string serialized_fct,
+unsigned int GUIEngine::queueAsync(std::string serialized_func,
                std::string serialized_params) {
-       return m_script->DoAsync(serialized_fct,serialized_params);
+       return m_script->queueAsync(serialized_func, serialized_params);
 }
+