Ejemplo n.º 1
0
int CBlockMember::ReadMember( char **stream, long *streamPos, CIcarus* icarus )
{
	IGameInterface* game = icarus->GetGame();
	m_id = *(int *) (*stream + *streamPos);
	*streamPos += sizeof( int );

	if ( m_id == CIcarus::ID_RANDOM )
	{//special case, need to initialize this member's data to Q3_INFINITE so we can randomize the number only the first time random is checked when inside a wait
		m_size = sizeof( float );
		*streamPos += sizeof( long );
		m_data = game->Malloc( m_size );
		float infinite = game->MaxFloat();
		memcpy( m_data, &infinite, m_size );
	}
	else
	{
		m_size = *(long *) (*stream + *streamPos);
		*streamPos += sizeof( long );
		m_data = game->Malloc( m_size );
		memcpy( m_data, (*stream + *streamPos), m_size );
	}
	*streamPos += m_size;
	
	return true;
}
Ejemplo n.º 2
0
int CBlockMember::ReadMember( char **stream, long *streamPos, CIcarus* icarus )
{
	IGameInterface* game = icarus->GetGame();
	m_id = LittleLong(*(int *) (*stream + *streamPos));
	*streamPos += sizeof( int );

	if ( m_id == CIcarus::ID_RANDOM )
	{//special case, need to initialize this member's data to Q3_INFINITE so we can randomize the number only the first time random is checked when inside a wait
		m_size = sizeof( float );
		*streamPos += sizeof( int );
		m_data = game->Malloc( m_size );
		float infinite = game->MaxFloat();
		memcpy( m_data, &infinite, m_size );
	}
	else
	{
		m_size = LittleLong(*(int *) (*stream + *streamPos));
		*streamPos += sizeof( int );
		m_data = game->Malloc( m_size );
		memcpy( m_data, (*stream + *streamPos), m_size );
#ifdef Q3_BIG_ENDIAN
		// only TK_INT, TK_VECTOR and TK_FLOAT has to be swapped, but just in case
		if (m_size == 4 && m_id != CIcarus::TK_STRING && m_id != CIcarus::TK_IDENTIFIER && m_id != CIcarus::TK_CHAR)
			*(int *)m_data = LittleLong(*(int *)m_data);
#endif
	}
	*streamPos += m_size;
	
	return true;
}