Exemplo n.º 1
0
void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini) const {
    std::vector<std::string> contentFiles;
    std::string baseGameFile("Game Files:GameFile");
    std::string gameFile("");

    multistrmap::const_iterator it = ini.begin();
    for(int i=0; it != ini.end(); i++) {
        gameFile = baseGameFile;
        gameFile.append(this->numberToString(i));

        it = ini.find(gameFile);
        if(it == ini.end()) {
            break;
        }

        for(std::vector<std::string>::const_iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) {
            std::string filetype(entry->substr(entry->length()-3));
            Misc::StringUtils::toLower(filetype);

            if(filetype.compare("esm") == 0 || filetype.compare("esp") == 0) {
                contentFiles.push_back(*entry);
            }
        }

        gameFile = "";
    }

    cfg.erase("content");
    cfg.insert( std::make_pair("content", std::vector<std::string>() ) );

    for(std::vector<std::string>::const_iterator it=contentFiles.begin(); it!=contentFiles.end(); ++it) {
        cfg["content"].push_back(*it);
    }
}
Exemplo n.º 2
0
void MwIniImporter::insertMultistrmap(multistrmap &cfg, std::string key, std::string value) {
    multistrmap::iterator it = cfg.find(key);
    if(it == cfg.end()) {
        cfg.insert(std::make_pair (key, std::vector<std::string>() ));
    }
    cfg[key].push_back(value);
}
Exemplo n.º 3
0
void MwIniImporter::importArchives(multistrmap &cfg, const multistrmap &ini) const {
    std::vector<std::string> archives;
    std::string baseArchive("Archives:Archive ");
    std::string archive;

    // Search archives listed in ini file
    multistrmap::const_iterator it = ini.begin();
    for(int i=0; it != ini.end(); i++) {
        archive = baseArchive;
        archive.append(this->numberToString(i));

        it = ini.find(archive);
        if(it == ini.end()) {
            break;
        }

        for(std::vector<std::string>::const_iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) {
            archives.push_back(*entry);
        }
    }

    cfg.erase("fallback-archive");
    cfg.insert( std::make_pair<std::string, std::vector<std::string> > ("fallback-archive", std::vector<std::string>()));

    // Add Morrowind.bsa by default, since Vanilla loads this archive even if it
    // does not appears in the ini file
    cfg["fallback-archive"].push_back("Morrowind.bsa");

    for(std::vector<std::string>::const_iterator it=archives.begin(); it!=archives.end(); ++it) {
        cfg["fallback-archive"].push_back(*it);
    }
}
Exemplo n.º 4
0
void MwIniImporter::importGameFiles(multistrmap &cfg, multistrmap &ini) {
    std::vector<std::string> esmFiles;
    std::vector<std::string> espFiles;
    std::string baseGameFile("Game Files:GameFile");
    std::string gameFile("");

    multistrmap::iterator it = ini.begin();
    for(int i=0; it != ini.end(); i++) {
        gameFile = baseGameFile;
        gameFile.append(this->numberToString(i));

        it = ini.find(gameFile);
        if(it == ini.end()) {
            break;
        }

        for(std::vector<std::string>::iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) {
            std::string filetype(entry->substr(entry->length()-4, 3));
            std::transform(filetype.begin(), filetype.end(), filetype.begin(), ::tolower);

            if(filetype.compare("esm") == 0) {
                esmFiles.push_back(*entry);
            }
            else if(filetype.compare("esp") == 0) {
                espFiles.push_back(*entry);
            }
        }

        gameFile = "";
    }

    cfg.erase("master");
    cfg.insert( std::make_pair<std::string, std::vector<std::string> > ("master", std::vector<std::string>() ) );

    for(std::vector<std::string>::iterator it=esmFiles.begin(); it!=esmFiles.end(); ++it) {
        cfg["master"].push_back(*it);
    }

    cfg.erase("plugin");
    cfg.insert( std::make_pair<std::string, std::vector<std::string> > ("plugin", std::vector<std::string>() ) );

    for(std::vector<std::string>::iterator it=espFiles.begin(); it!=espFiles.end(); ++it) {
        cfg["plugin"].push_back(*it);
    }
}