Exemple #1
0
void ReadConfigs(void)
{
    Settings & conf = Settings::Get();
    ListFiles files = conf.GetListFiles("", "fheroes2.cfg");

    for(ListFiles::const_iterator
	it = files.begin(); it != files.end(); ++it)
    	if(IsFile(*it)) conf.Read(*it);
}
bool PrepareMapsFileInfoList(MapsFileInfoList & lists, bool multi)
{
    const Settings & conf = Settings::Get();
    ListFiles maps = conf.GetListFiles("maps", ".mp2");

    // check loyality version
    if(conf.PriceLoyaltyVersion())
        maps.Append(conf.GetListFiles("maps", ".mx2"));

    const ListDirs & list = conf.GetMapsParams();
    if(! list.empty())
    {
	for(ListDirs::const_iterator
	    it = list.begin(); it != list.end(); ++it)
	if(*it != "maps")
	{
    	    maps.Append(conf.GetListFiles(*it, ".mp2"));
	    if(conf.PriceLoyaltyVersion())
    		maps.Append(conf.GetListFiles(*it, ".mx2"));
	}
    }

    if(maps.empty()) return false;
    lists.reserve(maps.size());

    for(ListFiles::const_iterator
	it = maps.begin(); it != maps.end(); ++it)
    {
	Maps::FileInfo fi;
	if(fi.ReadMP2(*it)) lists.push_back(fi);
    }

    std::sort(lists.begin(), lists.end(), Maps::FileInfo::NameSorting);
    lists.resize(std::unique(lists.begin(), lists.end(), Maps::FileInfo::NameCompare) - lists.begin());

    if(multi == false)
    {
	MapsFileInfoList::iterator it = std::remove_if(lists.begin(), lists.end(),
				    std::mem_fun_ref(&Maps::FileInfo::isMultiPlayerMap));
	if(it != lists.begin()) lists.resize(std::distance(lists.begin(), it));
    }

    // set preferably count filter
    if(conf.PreferablyCountPlayers())
    {

	MapsFileInfoList::iterator it = std::remove_if(lists.begin(), lists.end(),
		std::not1(std::bind2nd(std::mem_fun_ref(&Maps::FileInfo::isAllowCountPlayers), conf.PreferablyCountPlayers())));
	if(it != lists.begin()) lists.resize(std::distance(lists.begin(), it));
    }

    return lists.size();
}
Exemple #3
0
void ListFiles::Append(const ListFiles & list)
{
    insert(end(), list.begin(), list.end());
}