Browse Source

Some tweaks for mod loading. Still doesn't work.

DjWarmonger 13 years ago
parent
commit
20b54a39b6
1 changed files with 14 additions and 15 deletions
  1. 14 15
      lib/CModHandler.cpp

+ 14 - 15
lib/CModHandler.cpp

@@ -1,7 +1,7 @@
 #include "StdInc.h"
 #include "CModHandler.h"
 #include "JsonNode.h"
-
+#include "Filesystem\CResourceLoader.h" //TODO: reorganize
 /*
  * CModHandler.h, part of VCMI engine
  *
@@ -65,23 +65,22 @@ void CModHandler::loadConfigFromFile (std::string name)
 
 	//auto mods = config["activeMods"]; //TODO: load only mods from the list
 
-	CResourceLoader * modLoader = new CResourceLoader;
+	auto resourceLoader = CResourceHandler::get();
+	auto iterator = resourceLoader->getIterator([](const ResourceID & ident) ->  bool
+	{
+		std::string name = ident.getName();
 
-	auto iterator = modLoader->getIterator([](const ResourceID & ident) ->  bool
-	{
-		std::string name = ident.getName();
-
-		return ident.getType() == EResType::TEXT
-		    && std::count(name.begin(), name.end(), '/') == 3
-		    && boost::algorithm::starts_with(name, "ALL/MODS/")
-		    && boost::algorithm::ends_with(name, "MOD"); //all mods have "mod.json" name - does it make sense?
+		return ident.getType() == EResType::TEXT
+		    && std::count(name.begin(), name.end(), '/') == 3
+		    && boost::algorithm::starts_with(name, "ALL/MODS/")
+		    && boost::algorithm::ends_with(name, "MOD"); //all mods have "mod.json" name - does it make sense?
 	});
 
-	std::set<std::string> foundMods;
-	while (iterator.hasNext())
-	{
-		foundMods.insert(iterator->getName());
-		++iterator;
+	std::set<std::string> foundMods;
+	while (iterator.hasNext())
+	{
+		foundMods.insert(iterator->getName());
+		++iterator;
 	}
 
 	BOOST_FOREACH (auto mod, foundMods)