@@ -829,7 +829,7 @@ int main(int argc, char *argv[])
829829 /*
830830 Low-level initialization
831831 */
832-
832+
833833 // Quiet mode, print errors only
834834 if (cmd_args.getFlag (" quiet" )) {
835835 log_remove_output (&main_stderr_log_out);
@@ -1027,7 +1027,7 @@ int main(int argc, char *argv[])
10271027 commanded_world.substr (commanded_world.size () - worldmt.size ())
10281028 == worldmt) {
10291029 dstream << _ (" Supplied world.mt file - stripping it off." ) << std::endl;
1030- commanded_world = commanded_world.substr (0 ,
1030+ commanded_world = commanded_world.substr (0 ,
10311031 commanded_world.size () - worldmt.size ());
10321032 }
10331033 }
@@ -1208,7 +1208,7 @@ int main(int argc, char *argv[])
12081208 if (cmd_args.exists (" migrate" )) {
12091209 std::string migrate_to = cmd_args.get (" migrate" );
12101210 Settings world_mt;
1211- bool success = world_mt.readConfigFile ((world_path + DIR_DELIM
1211+ bool success = world_mt.readConfigFile ((world_path + DIR_DELIM
12121212 + " world.mt" ).c_str ());
12131213 if (!success) {
12141214 errorstream << " Cannot read world.mt" << std::endl;
@@ -1237,7 +1237,7 @@ int main(int argc, char *argv[])
12371237 new_db = new Database_Redis (&(ServerMap&)server.getMap (), world_path);
12381238 #endif
12391239 else {
1240- errorstream << " Migration to " << migrate_to
1240+ errorstream << " Migration to " << migrate_to
12411241 << " is not supported" << std::endl;
12421242 return 1 ;
12431243 }
@@ -1429,16 +1429,16 @@ int main(int argc, char *argv[])
14291429 ELL_ERROR,
14301430 ELL_WARNING,
14311431 ELL_INFORMATION,
1432- #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
1432+ #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
14331433 ELL_INFORMATION
14341434#else
14351435 ELL_DEBUG
14361436#endif
14371437 };
1438-
1438+
14391439 ILogger* irr_logger = device->getLogger ();
14401440 irr_logger->setLogLevel (irr_log_level[loglevel]);
1441-
1441+
14421442 porting::initIrrlicht (device);
14431443
14441444 /*
@@ -1633,15 +1633,14 @@ int main(int argc, char *argv[])
16331633 std::vector<WorldSpec> worldspecs = getAvailableWorlds ();
16341634
16351635 // If a world was commanded, append and select it
1636- if (commanded_world != " " ) {
1637-
1638- std::string gameid = getWorldGameId (commanded_world, true );
1639- std::string name = _ (" [--world parameter]" );
1640- if (gameid == " " ) {
1641- gameid = g_settings->get (" default_game" );
1642- name += " [new]" ;
1636+ if (commanded_world != " " ) {
1637+ worldspec.gameid = getWorldGameId (commanded_world, true );
1638+ worldspec.name = _ (" [--world parameter]" );
1639+ if (worldspec.gameid == " " ) {
1640+ worldspec.gameid = g_settings->get (" default_game" );
1641+ worldspec.name += " [new]" ;
16431642 }
1644- // TODO find within worldspecs and set config
1643+ worldspec. path = commanded_world;
16451644 }
16461645
16471646 if (skip_main_menu == false ) {
@@ -1695,11 +1694,6 @@ int main(int argc, char *argv[])
16951694 // Save settings
16961695 g_settings->set (" name" , playername);
16971696
1698- if ((menudata.selected_world >= 0 ) &&
1699- (menudata.selected_world < (int )worldspecs.size ()))
1700- g_settings->set (" selected_world_path" ,
1701- worldspecs[menudata.selected_world ].path );
1702-
17031697 // Break out of menu-game loop to shut down cleanly
17041698 if (device->run () == false || kill == true )
17051699 break ;
@@ -1724,22 +1718,35 @@ int main(int argc, char *argv[])
17241718 ServerList::insert (server);
17251719 }
17261720
1727- // Set world path to selected one
1728- if ((menudata.selected_world >= 0 ) &&
1729- (menudata.selected_world < (int )worldspecs.size ())) {
1721+ if ((!skip_main_menu) &&
1722+ (menudata.selected_world >= 0 ) &&
1723+ (menudata.selected_world < (int )worldspecs.size ())) {
1724+ g_settings->set (" selected_world_path" ,
1725+ worldspecs[menudata.selected_world ].path );
17301726 worldspec = worldspecs[menudata.selected_world ];
1731- infostream<<" Selected world: " <<worldspec.name
1732- <<" [" <<worldspec.path <<" ]" <<std::endl;
1727+
17331728 }
17341729
1730+ infostream <<" Selected world: " << worldspec.name
1731+ << " [" <<worldspec.path <<" ]" <<std::endl;
1732+
1733+
17351734 // If local game
17361735 if (current_address == " " ) {
1737- if (menudata. selected_world == - 1 ) {
1736+ if (worldspec. path == " " ) {
17381737 error_message = wgettext (" No world selected and no address "
17391738 " provided. Nothing to do." );
17401739 errorstream << wide_to_narrow (error_message) << std::endl;
17411740 continue ;
17421741 }
1742+
1743+ if (!fs::PathExists (worldspec.path )) {
1744+ error_message = wgettext (" Provided world path doesn't exist: " )
1745+ + narrow_to_wide (worldspec.path );
1746+ errorstream << wide_to_narrow (error_message) << std::endl;
1747+ continue ;
1748+ }
1749+
17431750 // Load gamespec for required game
17441751 gamespec = findWorldSubgame (worldspec.path );
17451752 if (!gamespec.isValid () && !commanded_gamespec.isValid ()) {
0 commit comments