From: Perttu Ahola Date: Mon, 12 Mar 2012 20:15:56 +0000 (+0200) Subject: Remember selected world by path X-Git-Tag: 0.4.dev-20120318~33 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=82073025ccc551c2fd205cc1dc6fcecac61cc7ea;p=oweals%2Fminetest.git Remember selected world by path --- diff --git a/src/main.cpp b/src/main.cpp index 7caec19c1..41cf583f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1277,11 +1277,22 @@ int main(int argc, char *argv[]) i != worldspecs.end(); i++) menudata.worlds.push_back(narrow_to_wide( i->name + " [" + i->gameid + "]")); - // Select if there is only one - if(worldspecs.size() == 1) + // Default to selecting nothing + menudata.selected_world = -1; + // If there is only one world, select it + if(worldspecs.size() == 1){ menudata.selected_world = 0; - else - menudata.selected_world = -1; + } + // Otherwise try to select according to selected_world_path + else if(g_settings->exists("selected_world_path")){ + std::string trypath = g_settings->get("selected_world_path"); + for(u32 i=0; iset("name", playername); g_settings->set("address", address); g_settings->set("port", itos(port)); + if(menudata.selected_world != -1) + g_settings->set("selected_world_path", + worldspecs[menudata.selected_world].path); // Update configuration file if(configpath != "") g_settings->updateConfigFile(configpath.c_str());