// ----------------------------------------------------------------------------
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;
		}
	}
}
示例#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 );
}	
示例#3
0
void CTotemBase::totemFileCallback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream)
{
	static CPersistentDataRecordRyzomStore pdr;
	pdr.clear();
	pdr.fromBuffer(dataStream);
//	pdr.readFromFile( sFilePath.c_str() );

	apply( pdr );
}
示例#4
0
bool CTotemBase::tickUpdate()
{
	if ( _IsBuildingFinished == true )
		return false;

	NLMISC::TGameCycle currentCycle = CTickEventHandler::getGameCycle();
	
	_TotemCurrentHP += ( currentCycle - _LastTickUpdate ) * _BuildHpGain;

	if ( _TotemCurrentHP > _TotemMaxHP )
		_TotemCurrentHP = _TotemMaxHP;

	if ( _BotObject )
	{
		_BotObject->getScores()._PhysicalScores[SCORES::hit_points].Current = (sint32)_TotemCurrentHP;
		nlinfo( "Totem %d HP : %d", _RegionAlias, _BotObject->currentHp() );
	}
	
	if ( currentCycle - _BuildingStartTime >= TotemBuildTime )
	{
		// the totem has finished building
		_IsBuildingFinished = true;
		CPVPFactionHOF::getInstance()->writeStatInHOFDatabase( 0, _OwnerFaction, CPVPFactionHOF::builded_spire, 1 );
	}

	// save updates every 10 seconds
	if ( ( currentCycle % 100 ) == 0 )
	{
		string sFilePath = toString( "totems/totems_%d.bin", _RegionAlias );
				
		static CPersistentDataRecordRyzomStore pdr;
		pdr.clear();

		store( pdr );

		CBackupMsgSaveFile msg( sFilePath, CBackupMsgSaveFile::SaveFile, Bsi );
		
		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 );
	}

	_LastTickUpdate = currentCycle;

	return true;
}
//----------------------------------------------------------------------------
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());
	}
}