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::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.º 3
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);
    }
}
Exemplo n.º 4
0
void MwIniImporter::merge(multistrmap &cfg, const multistrmap &ini) const {
    multistrmap::const_iterator iniIt;
    for(strmap::const_iterator it=mMergeMap.begin(); it!=mMergeMap.end(); ++it) {
        if((iniIt = ini.find(it->second)) != ini.end()) {
            for(std::vector<std::string>::const_iterator vc = iniIt->second.begin(); vc != iniIt->second.end(); ++vc) {
                cfg.erase(it->first);
                insertMultistrmap(cfg, it->first, *vc);
            }
        }
    }
}
Exemplo n.º 5
0
void MwIniImporter::mergeFallback(multistrmap &cfg, const multistrmap &ini) const {
    cfg.erase("fallback");

    multistrmap::const_iterator iniIt;
    for(std::vector<std::string>::const_iterator it=mMergeFallback.begin(); it!=mMergeFallback.end(); ++it) {
        if((iniIt = ini.find(*it)) != ini.end()) {
            for(std::vector<std::string>::const_iterator vc = iniIt->second.begin(); vc != iniIt->second.end(); ++vc) {
                std::string value(*it);
                std::replace( value.begin(), value.end(), ' ', '_' );
                std::replace( value.begin(), value.end(), ':', '_' );
                value.append(",").append(vc->substr(0,vc->length()));
                insertMultistrmap(cfg, "fallback", value);
            }
        }
    }
}