From 6b2023dc3eb1b483c92ba967f3335bb6880d2db1 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 3 Dec 2011 03:32:30 +0200 Subject: Properly handle mod name conflicts --- src/mods.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/mods.cpp') diff --git a/src/mods.cpp b/src/mods.cpp index 285c4cbb9..db878d78b 100644 --- a/src/mods.cpp +++ b/src/mods.cpp @@ -21,8 +21,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include #include "filesys.h" #include "strfnd.h" +#include "log.h" // Get a dependency-sorted list of ModSpecs core::list getMods(core::list &modspaths) @@ -31,6 +33,8 @@ core::list getMods(core::list &modspaths) std::queue mods_satisfied; core::list mods_unsorted; core::list mods_sorted; + // name, path: For detecting name conflicts + std::map mod_names; for(core::list::Iterator i = modspaths.begin(); i != modspaths.end(); i++){ std::string modspath = *i; @@ -40,6 +44,19 @@ core::list getMods(core::list &modspaths) continue; std::string modname = dirlist[j].name; std::string modpath = modspath + DIR_DELIM + modname; + // Detect mod name conflicts + { + std::map::const_iterator i; + i = mod_names.find(modname); + if(i != mod_names.end()){ + std::string s; + infostream<<"WARNING: Mod name conflict detected: " + <second< depends; std::ifstream is((modpath+DIR_DELIM+"depends.txt").c_str(), std::ios_base::binary); @@ -54,6 +71,7 @@ core::list getMods(core::list &modspaths) mods_unsorted.push_back(spec); if(depends.empty()) mods_satisfied.push(spec); + mod_names[modname] = modpath; } } // Sort by depencencies -- cgit v1.2.3