Fix mod paths
authorPerttu Ahola <celeron55@gmail.com>
Mon, 19 Mar 2012 23:06:44 +0000 (01:06 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 19 Mar 2012 23:07:02 +0000 (01:07 +0200)
src/server.cpp
src/subgame.cpp
src/subgame.h

index b95d047139575605c2c6d36e878bbdc22eadb579..87d43dc69826f5a36fa083f6def072e1b053ed35 100644 (file)
@@ -885,25 +885,13 @@ Server::Server(
        infostream<<"- world:  "<<m_path_world<<std::endl;
        infostream<<"- config: "<<m_path_config<<std::endl;
        infostream<<"- game:   "<<m_gamespec.path<<std::endl;
-       for(std::set<std::string>::const_iterator i = m_gamespec.addon_paths.begin();
-                       i != m_gamespec.addon_paths.end(); i++)
-               infostream<<"- addons: "<<(*i)<<std::endl;
 
-       // Path to builtin.lua
-       std::string builtinpath = porting::path_share + DIR_DELIM + "builtin"
-                       + DIR_DELIM + "builtin.lua";
-
-       // Add default global mod search path
-       m_modspaths.push_front(m_gamespec.path + DIR_DELIM "mods");
        // Add world mod search path
        m_modspaths.push_front(m_path_world + DIR_DELIM + "worldmods");
        // Add addon mod search path
-       for(std::set<std::string>::const_iterator i = m_gamespec.addon_paths.begin();
-                       i != m_gamespec.addon_paths.end(); i++)
-               m_modspaths.push_front((*i) + DIR_DELIM + "mods");
-       // Add simple user mod search path
-       m_modspaths.push_front(porting::path_user + DIR_DELIM + "mods"
-                       + DIR_DELIM + m_gamespec.id);
+       for(std::set<std::string>::const_iterator i = m_gamespec.mods_paths.begin();
+                       i != m_gamespec.mods_paths.end(); i++)
+               m_modspaths.push_front((*i));
 
        // Print out mod search paths
        for(core::list<std::string>::Iterator i = m_modspaths.begin();
@@ -912,6 +900,10 @@ Server::Server(
                infostream<<"- mods:   "<<modspath<<std::endl;
        }
        
+       // Path to builtin.lua
+       std::string builtinpath = porting::path_share + DIR_DELIM + "builtin"
+                       + DIR_DELIM + "builtin.lua";
+
        // Create world if it doesn't exist
        if(!initializeWorld(m_path_world, m_gamespec.id))
                throw ServerError("Failed to initialize world");
index e55f1bc97642c8fd4147c07a31b789955c03d38d..3d4480ebfcbf472b850a495df94da2b6a8565ccb 100644 (file)
@@ -38,14 +38,16 @@ SubgameSpec findSubgame(const std::string &id)
        }
        if(!fs::PathExists(game_path))
                return SubgameSpec();
-       // Find addon directories
-       std::set<std::string> addon_paths;
+       // Find mod directories
+       std::set<std::string> mods_paths;
+       mods_paths.insert(game_path + DIR_DELIM + "mods");
        if(!user_game)
-               addon_paths.insert(share + DIR_DELIM + "addons" + DIR_DELIM + id);
-       addon_paths.insert(user + DIR_DELIM + "addons" + DIR_DELIM + id);
+               mods_paths.insert(share + DIR_DELIM + "mods" + DIR_DELIM + id);
+       if(user != share || user_game)
+               mods_paths.insert(user + DIR_DELIM + "mods" + DIR_DELIM + id);
        // TODO: Read proper name from game_path/game.conf
        std::string game_name = id;
-       return SubgameSpec(id, game_path, addon_paths, game_name);
+       return SubgameSpec(id, game_path, mods_paths, game_name);
 }
 
 std::set<std::string> getAvailableGameIds()
index b201a740255acdaa735d0eecbea725fb1fc9cd4e..061bb41802bc3d58e364d3dc4c44637215a780aa 100644 (file)
@@ -28,16 +28,16 @@ struct SubgameSpec
 {
        std::string id; // "" = game does not exist
        std::string path;
-       std::set<std::string> addon_paths;
+       std::set<std::string> mods_paths;
        std::string name;
 
        SubgameSpec(const std::string &id_="",
                        const std::string &path_="",
-                       const std::set<std::string> &addon_paths_=std::set<std::string>(),
+                       const std::set<std::string> &mods_paths_=std::set<std::string>(),
                        const std::string &name_=""):
                id(id_),
                path(path_),
-               addon_paths(addon_paths_),
+               mods_paths(mods_paths_),
                name(name_)
        {}