Esempio n. 1
0
void CAiWrapperServer::primitiveFileToPdr(const std::string& primitiveName, CPersistentDataRecord& pdr)
{
	pdr.clear();
	CAIPrimitiveParser::init(&pdr);	
	AI_SHARE::parsePrimFile(primitiveName.c_str());
	CAIPrimitiveParser::release();	
}
Esempio n. 2
0
void CDynamicItems::fileAvailable(const CFileDescription& fileDescription, NLMISC::IStream& dataStream)
{
	static CPersistentDataRecord	pdr;
	pdr.clear();

	pdr.fromBuffer(dataStream);
	apply(pdr, 0);
}
Esempio n. 3
0
// ----------------------------------------------------------------------------
void CMissionQueueManager::init()
{
	string sFilename = MissionQueueFile.get();
	sFilename = Bsi.getLocalPath() + sFilename;
	
	if (CFile::fileExists(sFilename))
	{
		static CPersistentDataRecord	pdr;
		pdr.clear();
		pdr.readFromTxtFile(sFilename.c_str());
		apply(pdr);
	}
	_InitOk = true;
}
bool CCharacterScanJob::runForFile(const std::string& fileName)
{
	// load the file into a pdr record
	static CPersistentDataRecord	pdr;
	pdr.clear();
	pdr.readFromFile(fileName.c_str());

	// create a character representation and apply the pdr
	CStatsScanCharacter c;
	c.apply(pdr);

	// iterate over the filters executing their core code
	for (uint32 i=(uint32)_Filters.size();i--;)
	{
		if (!_Filters[i]->evaluate(&c))
			return true;
	}

	// we've been accepted by the filters so add this file to the file list (if there is one)
	if (_FileList!=NULL)
	{
		_FileList->addFile(fileName);
	}

	// iterate over the info extractors executing their core code
	for (uint32 i=0;i<_InfoExtractors.size();++i)
	{
		_InfoExtractors[i]->execute(this,&c);
	}

	// flush the info collected by the info extractors to the output file
	CVectorSString words;
	CSString(fileName).splitFrom("account_").splitTo("_pdr.").splitBySeparator('_',words,false,true,true,true);
	if (words.size()==2)
	{
		charTblFlushRow(words[0].atoi(),words[1].atoi());
	}

	return true;
}
void COutpostManager::outpostFileCallback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream)
{
	// get the corresponding outpost
	string aliasStr = CFile::getFilename(fileDescription.FileName);
	aliasStr.resize( aliasStr.length() - 4 );
	aliasStr = aliasStr.substr( 8);

	TAIAlias alias;
	NLMISC::fromString(aliasStr, alias);
	COutpost * outpost = getOutpostFromAlias( alias );
	if ( !outpost )
		OUTPOST_WRN("Invalid outpost file '%s' %s : not found in the primitive", fileDescription.FileName.c_str(), CPrimitivesParser::aliasToString(alias).c_str());
	else
	{
		// load dynamic data
		static CPersistentDataRecord	pdr;
		pdr.clear();
		pdr.fromBuffer(dataStream);
		outpost->apply( pdr );
		loadedOutposts.push_back( outpost );
	}
}
Esempio n. 6
0
void CGuildScanJob::update()
{
	// if nothing left to do then give up
	if (finished())
		return;

	// treat the next file in the list
	NLMISC::CSString fileName=_Files[_NextFile].FileName;

	// read the file contents
	static CPersistentDataRecord	fileContent;
	fileContent.clear();
	fileContent.readFromFile(fileName.c_str());

	// add the result to the target guild container
	if (_GuildContainer!=NULL)
	{
		_GuildContainer->addGuildFile(fileName,fileContent);
	}

	// move counter on to next file
	++_NextFile;
}
Esempio n. 7
0
//-----------------------------------------------------------------------------
void CNamedItems::loadNamedItemsFromFile(const std::string & fileName)
{
	CHashMap<std::string, CGameItemPtr>::iterator it;
	for (it = _NamedItems.begin(); it != _NamedItems.end(); ++it)
	{
		GameItemManager.destroyItem((*it).second);
	}
	_NamedItems.clear();

	string path;
	try
	{
		path = CPath::lookup(fileName);
	}
	catch (Exception &)
	{
		nlwarning("<NAMED_ITEMS> file '%s' was not found", fileName.c_str());
		return;
	}

	static CPersistentDataRecord	pdr;
	pdr.clear();
	pdr.readFromTxtFile(path.c_str());
	CInventoryPtr inv = loadFromPdr(pdr);
	if (inv == NULL)
	{
		nlwarning("<NAMED_ITEMS> error while loading items from the PDR");
		return;
	}

	const uint size = inv->getSlotCount();
	nlinfo("loading '%u' named items", size);
	for (uint i = 0; inv->getFreeSlotCount() != inv->getSlotCount() && i < size; ++i)
	{
		if (inv->getItem(i) == NULL)
			continue;
		CGameItemPtr item = inv->removeItem(i);
		if (item != NULL)
		{
			if (item->getSheetId() == CSheetId::Unknown)
			{
				nlwarning("<NAMED_ITEMS> item '%u' has invalid sheet id", i);
				GameItemManager.destroyItem(item);
				continue;
			}
			if (item->getPhraseId().empty())
			{
				nlwarning("<NAMED_ITEMS> item '%u' has no name", i);
				GameItemManager.destroyItem(item);
				continue;
			}
			if (_NamedItems.find(item->getPhraseId()) != _NamedItems.end())
			{
				nlwarning("<NAMED_ITEMS> item '%u', name '%s' exists more than once", i, item->getPhraseId().c_str());
				GameItemManager.destroyItem(item);
				continue;
			}

			// Yoyo: force this item to work with the new form requirement system.
			// BUT: do it only if _UseNewSystemRequirement==false (if LDs put true, we suppose that the named item has special req value)
			if(item->getUseNewSystemRequirement()==false)
				item->computeRequirementFromForm();

			nldebug("<NAMED_ITEMS> creating named item '%s'",item->getPhraseId().c_str());
			_NamedItems.insert(make_pair(item->getPhraseId(), item));
		}
	}
}