Esempio n. 1
0
//-----------------------------------------------------------------------------
// Color attribute
//-----------------------------------------------------------------------------
bool Serialize( CUtlBuffer &buf, const Color &src )
{
	if ( buf.IsText() )
	{
		buf.Printf( "%d %d %d %d", src[0], src[1], src[2], src[3] );
	}
	else
	{
		buf.PutUnsignedChar( src[0] );
		buf.PutUnsignedChar( src[1] );
		buf.PutUnsignedChar( src[2] );
		buf.PutUnsignedChar( src[3] );
	}
	return buf.IsValid();
}
Esempio n. 2
0
void CMomRunStats::Serialize(CUtlBuffer &writer) 
{
    writer.PutUnsignedChar(m_iTotalZones);

    for (int i = 0; i < m_iTotalZones + 1; ++i)
    {
        //Jumps/Strafes
        writer.PutUnsignedInt(m_iZoneJumps[i]);
        writer.PutUnsignedInt(m_iZoneStrafes[i]);
        //Sync
        writer.PutFloat(m_flZoneStrafeSyncAvg[i]);
        writer.PutFloat(m_flZoneStrafeSync2Avg[i]);
        //Time
        writer.PutUnsignedInt(m_iZoneEnterTick[i]);
        writer.PutUnsignedInt(m_iZoneTicks[i]);
        //Velocity
        writer.PutFloat(m_flZoneVelocityMax3D[i]);
        writer.PutFloat(m_flZoneVelocityMax2D[i]);
        writer.PutFloat(m_flZoneVelocityAvg3D[i]);
        writer.PutFloat(m_flZoneVelocityAvg2D[i]);
        writer.PutFloat(m_flZoneEnterSpeed3D[i]);
        writer.PutFloat(m_flZoneEnterSpeed2D[i]);
        writer.PutFloat(m_flZoneExitSpeed3D[i]);
        writer.PutFloat(m_flZoneExitSpeed2D[i]);
    }
}
Esempio n. 3
0
void CChoreoChannel::SaveToBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool )
{
	buf.PutShort( pStringPool->FindOrAddString( GetName() ) );

	int c = GetNumEvents();
	Assert( c <= 255 );
	buf.PutUnsignedChar( c );

	for ( int i = 0; i < c; i++ )
	{
		CChoreoEvent *e = GetEvent( i );
		Assert( e );
		e->SaveToBuffer( buf, pScene, pStringPool );
	}

	buf.PutChar( GetActive() ? 1 : 0 );
}
Esempio n. 4
0
/// store the directory
void PlaceDirectory::Save( CUtlBuffer &fileBuffer )
{
	// store number of entries in directory
	IndexType count = (IndexType)m_directory.Count();
	fileBuffer.PutUnsignedShort( count );

	// store entries		
	for( int i=0; i<m_directory.Count(); ++i )
	{
		const char *placeName = TheNavMesh->PlaceToName( m_directory[i] );

		// store string length followed by string itself
		unsigned short len = (unsigned short)(strlen( placeName ) + 1);
		fileBuffer.PutUnsignedShort( len );
		fileBuffer.Put( placeName, len );
	}

	fileBuffer.PutUnsignedChar( m_hasUnnamedAreas );
}
Esempio n. 5
0
bool KeyValues::WriteAsBinary(CUtlBuffer &buffer)
{
	if (buffer.IsText())
		return false;

	if (!buffer.IsValid())
		return false;

	for (KeyValues *dat = this; dat != NULL; dat = dat->m_pPeer)
	{
		buffer.PutUnsignedChar(dat->m_iDataType);
		buffer.PutString(dat->GetName());

		switch (dat->m_iDataType)
		{
			case TYPE_NONE:
			{
				dat->m_pSub->WriteAsBinary(buffer);
				break;
			}

			case TYPE_STRING:
			{
				if (dat->m_sValue && *(dat->m_sValue))
				{
					buffer.PutString(dat->m_sValue);
				}
				else
				{
					buffer.PutString("");
				}

				break;
			}

			case TYPE_WSTRING:
			{
				Assert(!"TYPE_WSTRING");
				break;
			}

			case TYPE_INT:
			{
				buffer.PutInt(dat->m_iValue);
				break;
			}

			case TYPE_UINT64:
			{
				buffer.PutDouble(*((double *)dat->m_sValue));
				break;
			}

			case TYPE_FLOAT:
			{
				buffer.PutFloat(dat->m_flValue);
				break;
			}

			case TYPE_COLOR:
			{
				buffer.PutUnsignedChar(dat->m_Color[0]);
				buffer.PutUnsignedChar(dat->m_Color[1]);
				buffer.PutUnsignedChar(dat->m_Color[2]);
				buffer.PutUnsignedChar(dat->m_Color[3]);
				break;
			}

			case TYPE_PTR:
			{
				buffer.PutUnsignedInt((int)dat->m_pValue);
			}

			default:
			{
				break;
			}
		}
	}

	buffer.PutUnsignedChar(TYPE_NUMTYPES); 
	return buffer.IsValid();
}