From 2e66aca35722e7fee786027d545fe371786fc01f Mon Sep 17 00:00:00 2001 From: sapier Date: Tue, 26 Nov 2013 18:15:31 +0100 Subject: Fix modstore/favourites hang by adding asynchronous lua job support --- src/main.cpp | 111 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 51 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 373e1ca96..2833bdcf7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -85,6 +85,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "database-leveldb.h" #endif +#if USE_CURL +#include "curl.h" +#endif + /* Settings. These are loaded from the config file. @@ -309,7 +313,7 @@ public: { return keyIsDown[keyCode]; } - + // Checks whether a key was down and resets the state bool WasKeyDown(const KeyPress &keyCode) { @@ -361,7 +365,7 @@ public: private: IrrlichtDevice *m_device; - + // The current state of keys KeyList keyIsDown; // Whether a key has been pressed or not @@ -405,7 +409,7 @@ public: { return m_receiver->right_active; } - + virtual bool getLeftClicked() { return m_receiver->leftclicked; @@ -656,7 +660,7 @@ void SpeedTests() } } } - + infostream<<"All of the following tests should take around 100ms each." < map1; tempf = -324; const s16 ii=300; @@ -702,7 +706,7 @@ void SpeedTests() { infostream<<"Around 5000/ms should do well here."< allowed_options; allowed_options.insert(std::make_pair("help", ValueSpec(VALUETYPE_FLAG, @@ -806,7 +810,7 @@ int main(int argc, char *argv[]) #endif Settings cmd_args; - + bool ret = cmd_args.parseCommandLine(argc, argv, allowed_options); if(ret == false || cmd_args.getFlag("help") || cmd_args.exists("nonopt1")) @@ -843,11 +847,11 @@ int main(int argc, char *argv[]) dstream<<"Build info: "<readConfigFile(cmd_args.get("config").c_str()); @@ -958,12 +962,12 @@ int main(int argc, char *argv[]) break; } } - + // If no path found, use the first one (menu creates the file) if(g_settings_path == "") g_settings_path = filenames[0]; } - + // Initialize debug streams #define DEBUGFILE "debug.txt" #if RUN_IN_PLACE @@ -973,7 +977,7 @@ int main(int argc, char *argv[]) #endif if(cmd_args.exists("logfile")) logfile = cmd_args.get("logfile"); - + log_remove_output(&main_dstream_no_stderr_log_out); int loglevel = g_settings->getS32("debug_log_level"); @@ -986,13 +990,18 @@ int main(int argc, char *argv[]) debugstreams_init(false, logfile.c_str()); else debugstreams_init(false, NULL); - + infostream<<"logfile = "<getU16("port"); if(port == 0) port = 30000; - + // World directory std::string commanded_world = ""; if(cmd_args.exists("world")) @@ -1031,12 +1040,12 @@ int main(int argc, char *argv[]) commanded_world = cmd_args.get("nonopt0"); else if(g_settings->exists("map-dir")) commanded_world = g_settings->get("map-dir"); - + // World name std::string commanded_worldname = ""; if(cmd_args.exists("worldname")) commanded_worldname = cmd_args.get("worldname"); - + // Strip world.mt from commanded_world { std::string worldmt = "world.mt"; @@ -1048,7 +1057,7 @@ int main(int argc, char *argv[]) 0, commanded_world.size()-worldmt.size()); } } - + // If a world name was specified, convert it to a path if(commanded_worldname != ""){ // Get information about available worlds @@ -1268,7 +1277,7 @@ int main(int argc, char *argv[]) } server.start(port); - + // Run server dedicated_server_loop(server, kill); @@ -1280,17 +1289,17 @@ int main(int argc, char *argv[]) /* More parameters */ - + std::string address = g_settings->get("address"); if(commanded_world != "") address = ""; else if(cmd_args.exists("address")) address = cmd_args.get("address"); - + std::string playername = g_settings->get("name"); if(cmd_args.exists("name")) playername = cmd_args.get("name"); - + bool skip_main_menu = cmd_args.getFlag("go"); /* @@ -1298,7 +1307,7 @@ int main(int argc, char *argv[]) */ // Resolution selection - + bool fullscreen = g_settings->getBool("fullscreen"); u16 screenW = g_settings->getU16("screenW"); u16 screenH = g_settings->getU16("screenH"); @@ -1312,7 +1321,7 @@ int main(int argc, char *argv[]) // Determine driver video::E_DRIVER_TYPE driverType; - + std::string driverstring = g_settings->get("video_driver"); if(driverstring == "null") @@ -1419,7 +1428,7 @@ int main(int argc, char *argv[]) if (device == 0) return 1; // could not create selected driver. - + /* Continue initialization */ @@ -1434,10 +1443,10 @@ int main(int argc, char *argv[]) // Create time getter g_timegetter = new IrrlichtTimeGetter(device); - + // Create game callback for menus g_gamecallback = new MainGameCallback(device); - + /* Speed tests (done after irrlicht is loaded to get timer) */ @@ -1448,7 +1457,7 @@ int main(int argc, char *argv[]) device->drop(); return 0; } - + device->setResizable(true); bool random_input = g_settings->getBool("random_input") @@ -1458,7 +1467,7 @@ int main(int argc, char *argv[]) input = new RandomInputHandler(); else input = new RealInputHandler(device, &receiver); - + scene::ISceneManager* smgr = device->getSceneManager(); guienv = device->getGUIEnvironment(); @@ -1488,7 +1497,7 @@ int main(int argc, char *argv[]) // If font was not found, this will get us one font = skin->getFont(); assert(font); - + u32 text_height = font->getDimension(L"Hello, world!").Height; infostream<<"text_height="<clear(); - + /* We need some kind of a root node to be able to add custom gui elements directly on the screen. @@ -1564,7 +1573,7 @@ int main(int argc, char *argv[]) */ guiroot = guienv->addStaticText(L"", core::rect(0, 0, 10000, 10000)); - + SubgameSpec gamespec; WorldSpec worldspec; bool simple_singleplayer_mode = false; @@ -1588,13 +1597,13 @@ int main(int argc, char *argv[]) break; } first_loop = false; - + // Cursor can be non-visible when coming from the game device->getCursorControl()->setVisible(true); // Some stuff are left to scene manager when coming from the game // (map at least?) smgr->clear(); - + // Initialize menu data MainMenuData menudata; menudata.address = address; @@ -1643,7 +1652,7 @@ int main(int argc, char *argv[]) infostream<<"Waited for other menus"<clear(); @@ -1683,7 +1692,7 @@ int main(int argc, char *argv[]) // Break out of menu-game loop to shut down cleanly if(device->run() == false || kill == true) break; - + current_playername = playername; current_password = password; current_address = address; @@ -1705,7 +1714,7 @@ int main(int argc, char *argv[]) server["description"] = menudata.serverdescription; ServerList::insert(server); } - + // Set world path to selected one if ((menudata.selected_world >= 0) && (menudata.selected_world < (int)worldspecs.size())) { @@ -1713,7 +1722,7 @@ int main(int argc, char *argv[]) infostream<<"Selected world: "<updateConfigFile(g_settings_path.c_str()); - + // Print modified quicktune values { bool header_printed = false; @@ -1850,9 +1859,9 @@ int main(int argc, char *argv[]) } END_DEBUG_EXCEPTION_HANDLER(errorstream) - + debugstreams_deinit(); - + return retval; } -- cgit v1.2.3