Esempio n. 1
0
// ----------------------------------------------------------------------------
void CMissionQueueManager::saveToFile()
{
	H_AUTO(CMissionQueueManagerSaveToFile);

	if( _InitOk )
	{
		string sFilename = MissionQueueFile.get();
		
		// save file via Backup Service (BS)
		try
		{
			static CPersistentDataRecordRyzomStore	pdr;
			pdr.clear();
			store(pdr);

			CBackupMsgSaveFile msg( sFilename, CBackupMsgSaveFile::SaveFile, Bsi );
			{
				std::string s;
				pdr.toString(s);
				msg.DataMsg.serialBuffer((uint8*)&s[0], (uint)s.size());
			}
			Bsi.sendFile( msg );
		}
		catch(const Exception &)
		{
			nlwarning("(EGS)<CMissionQueueManager::saveToFile>  :  Can't serial file %s (connection with BS service down ?)",sFilename.c_str());
			return;
		}
	}
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
void CDynamicItems::save(uint subIndex)
{
	H_AUTO(CDynamicItems_save);
	
	static CPersistentDataRecordRyzomStore	pdr;
	pdr.clear();
	store(pdr, subIndex);

	string fileName;
	makeFileName(subIndex, fileName);

	CBackupMsgSaveFile msg( fileName, CBackupMsgSaveFile::SaveFile, Bsi );

	if (XMLSave)
	{
		string s;
		pdr.toString(s);
		msg.DataMsg.serialBuffer((uint8*)&s[0], (uint)s.size());
	}
	else
	{
		uint size = pdr.totalDataSize();
		vector<char> buffer(size);
		pdr.toBuffer(&buffer[0], size);
		msg.DataMsg.serialBuffer((uint8*)&buffer[0], size);
	}
	
	Bsi.sendFile( msg );
}	
//----------------------------------------------------------------------------
void COutpostManager::saveOutpost(NLMISC::CSmartPtr<COutpost> outpost)
{
	nlassert(_OutpostSaveFilesLoaded);
	if (outpost == NULL)
		return;

	H_AUTO(COutpostManager_saveOutpost);

	static CPersistentDataRecordRyzomStore	pdr;
	pdr.clear();
	{
		H_AUTO(COutpostManagerSTORE)
		outpost->store(pdr);
	}
	string fileName = NLMISC::toString("outposts/outpost_%u.%s", outpost->getAlias(), (XMLSave)? "xml" : "bin" );
	if( UseBS )
	{
		try
		{
			CBackupMsgSaveFile msg( fileName, CBackupMsgSaveFile::SaveFile, Bsi );
			if (XMLSave)
			{
				H_AUTO(COutpostSerialXML);
				std::string s;
				pdr.toString(s);
				msg.DataMsg.serialBuffer((uint8*)&s[0], (uint)s.size());
			}
			else
			{
				H_AUTO(COutpostSerialBin);					
				uint32 bufSize= pdr.totalDataSize();
				vector<char> buffer;
				buffer.resize(bufSize);
				pdr.toBuffer(&buffer[0],bufSize);
				msg.DataMsg.serialBuffer((uint8*)&buffer[0], bufSize);
			}
			Bsi.sendFile( msg );
		}
		catch( Exception& )
		{
			OUTPOST_WRN("Can't serial file %s",fileName.c_str());
			return;
		}
	}
	else
	{
		H_AUTO( COutpostManagerSTORE_NO_BS )
		pdr.writeToBinFile((Bsi.getLocalPath() + fileName).c_str());
	}
}