Permalink
Browse files

master/plugin support; needs multimap instead of map

  • Loading branch information...
1 parent ceedae4 commit 653fbdd10cf83a3d361b7017b6e491d6df7aa67a @swick committed Mar 31, 2012
Showing with 64 additions and 0 deletions.
  1. +58 −0 apps/mwiniimporter/importer.cpp
  2. +1 −0 apps/mwiniimporter/importer.hpp
  3. +5 −0 apps/mwiniimporter/main.cpp
@@ -2,6 +2,9 @@
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/stream.hpp>
#include <iostream>
+#include <string>
+#include <map>
+#include <vector>
MwIniImporter::MwIniImporter() {
const char *map[][2] =
@@ -99,6 +102,61 @@ void MwIniImporter::merge(strmap &cfg, strmap &ini) {
}
}
+void MwIniImporter::importGameFiles(strmap &cfg, strmap &ini) {
+ std::vector<std::string> esmFiles;
+ std::string baseEsm("Game Files:GameFile");
+ std::string esmFile("");
+
+ strmap::iterator it = ini.begin();
+ for(int i=0; it != ini.end(); i++) {
+ esmFile = baseEsm;
+ esmFile.append(1,i+'0');
+
+ it = ini.find(esmFile);
+ if(it == ini.end()) {
+ break;
+ }
+
+ std::cout << "found EMS file: " << it->second << std::endl;
+ esmFiles.push_back(it->second);
+ esmFile = "";
+ }
+
+
+ std::vector<std::string> bsaFiles;
+ std::string baseBsa("Archives:Archive ");
+ std::string bsaFile("");
+
+ it = ini.begin();
+ for(int i=0; it != ini.end(); i++) {
+ bsaFile = baseBsa;
+ bsaFile.append(1,i+'0');
+
+ it = ini.find(bsaFile);
+ if(it == ini.end()) {
+ break;
+ }
+
+ std::cout << "found BSA file: " << it->second << std::endl;
+ bsaFiles.push_back(it->second);
+ bsaFile = "";
+ }
+
+ if(!esmFiles.empty()) {
+ cfg.erase("master");
+ for(std::vector<std::string>::iterator it = esmFiles.begin(); it != esmFiles.end(); it++) {
+ cfg.insert(std::make_pair<std::string, std::string>("master", *it));
+ }
+ }
+
+ if(!bsaFile.empty()) {
+ cfg.erase("plugin");
+ for(std::vector<std::string>::iterator it = bsaFiles.begin(); it != bsaFiles.end(); it++) {
+ cfg.insert(std::make_pair<std::string, std::string>("plugin", *it));
+ }
+ }
+}
+
bool MwIniImporter::specialMerge(std::string cfgKey, std::string iniKey, strmap &cfg, strmap &ini) {
return false;
}
@@ -16,6 +16,7 @@ class MwIniImporter {
strmap loadIniFile(std::string filename);
strmap loadCfgFile(std::string filename);
void merge(strmap &cfg, strmap &ini);
+ void importGameFiles(strmap &cfg, strmap &ini);
void writeToFile(std::string file, strmap &cfg);
private:
@@ -16,6 +16,7 @@ int main(int argc, char *argv[]) {
("ini,i", bpo::value<std::string>(), "morrowind.ini file")
("cfg,c", bpo::value<std::string>(), "openmw.cfg file")
("output,o", bpo::value<std::string>()->default_value(""), "openmw.cfg file")
+ ("game-files,g", "import esm and esp files")
;
bpo::variables_map vm;
@@ -65,6 +66,10 @@ int main(int argc, char *argv[]) {
std::map<std::string, std::string>cfg = importer.loadCfgFile(cfgFile);
importer.merge(cfg, ini);
+
+ if(vm.count("game-files")) {
+ importer.importGameFiles(cfg, ini);
+ }
std::cout << "write to: " << outputFile << std::endl;
importer.writeToFile(outputFile, cfg);

0 comments on commit 653fbdd

Please sign in to comment.