Exemplo n.º 1
0
bool ConfigManager::LoadLevel(const std::string &FileName, int level)
{
	if (LevelExists(level))
		return true;

	//Stream that reads through the file
	std::ifstream stream;

	//Open the stream
	stream.open(m_sdirectory + FileName);

	//Validation if the stream was able to open the file
	if (!stream.is_open())
	{
		return false;
	}

	//A dynamic array to store all the lines in the file
	std::vector<std::string>FileLines;

	//Segment the files content into seperate lines
	if (stream.is_open())
	{
		while (!stream.eof())
		{
			std::string Line;
			std::getline(stream, Line, '\n');
			FileLines.push_back(Line);
		}
		//If there were no lines, then just skip
		if (FileLines.size() < 1)
		{
			//Log::Message("File is empty.");
		}
		else
		{
			m_Levels.insert(std::pair<int, std::vector<std::string>>(level, FileLines));
		}
	}

	//Close the stream
	stream.close();

	return true;
}
Exemplo n.º 2
0
uint32 CDLCManager::GetRequiredDLCsForLevel(const char* pLevelName)
{
	if (pLevelName[0] == 0)
	{
		// Server hasn't set a level yet, no dlc required as yet
		return 0;
	}

	int req = 0;

	// Strip off the first part from the level name (e.g. "Wars/")
	const char* pTrimmedLevelName = strrchr(pLevelName, '/');
	if (pTrimmedLevelName)
	{
		pTrimmedLevelName++;
	}
	else
	{
		pTrimmedLevelName = pLevelName;
	}

	for (int i=0; i<MAX_DLC_COUNT; ++i)
	{
		for (size_t j=0; j<m_dlcContents[i].levels.size(); ++j)
		{
			if (stricmp(m_dlcContents[i].levels[j].c_str(), pTrimmedLevelName) == 0)
			{
				req |= BIT(i);
			}
		}
	}

	//TODO: Add explioit prevention DLC level list here if needed


	if (req == 0 && !LevelExists(pLevelName))
	{
		// this means we know the level's DLC but we can't work out *which* DLC it needs
		// (probably due to this being called on a client without the requisite DLC) - so for sanity lets say it needs all of them!
		req = 0xFFffFFff;
	}

	return req;
}