Sources/CcgDump/CrySkinBase.cpp
//------------------------------------------------------------------------------
//-----  this is the serialize version for little-endian CPUs              -----
//------------------------------------------------------------------------------

this is the serialize version for little-endian CPUs
this is the serialize version for little - endian CPUs
unsigned CrySkinBase::Serialize_PC (bool bSave, void* pStream, unsigned nBufSize)
{
	SerialHeader Header;
	if (bSave)
	{
		Header.initFromSkin(this);
	}
	else
	{
		if (!pStream)
			return 0;
		if (nBufSize < sizeof(Header))
			return 0;
		Header = *((SerialHeader*)pStream);
	}
	unsigned nSizeAuxInts = ((sizeof(CrySkinAuxInt)*Header.numAuxInts+3)&~3);
	unsigned nSizeRequired = 
		sizeof(SerialHeader) +
		nSizeAuxInts +
		sizeof(Vertex) * Header.numVertices;									 
	if (!pStream)
		return bSave?nSizeRequired:0;
	if (nBufSize < nSizeRequired)
		return 0;
	CrySkinAuxInt* pAuxInts = (CrySkinAuxInt*)(((SerialHeader*)pStream) + 1);
	Vertex* pVertices = (Vertex*)(((char*)pAuxInts) + nSizeAuxInts);
	if (bSave)
	{
		*((SerialHeader*)pStream) = Header;
		memcpy (pAuxInts, &m_arrAux[0], sizeof(CrySkinAuxInt)*m_arrAux.size());
		memcpy (pVertices, &m_arrVertices[0], sizeof(Vertex)*m_arrVertices.size());
	}
	else
	{
		m_arrAux.clear();
		m_arrAux.resize (Header.numAuxInts);
		m_arrVertices.clear();
		m_arrVertices.resize (Header.numVertices);
		m_numBones = Header.numBones;
		m_numSkipBones = Header.numSkipBones;
		m_numDests = Header.numDests;
		memcpy (&m_arrAux[0], pAuxInts, sizeof(CrySkinAuxInt)*m_arrAux.size());
		memcpy (&m_arrVertices[0], pVertices, sizeof(Vertex)*m_arrVertices.size());
	}
	return nSizeRequired;
}
unsigned CrySkinBase :: Serialize_PC ( bool bSave , void * pStream , unsigned nBufSize ) { SerialHeader Header ; if ( bSave ) { Header . initFromSkin ( this ) ; } else { if ( ! pStream ) return 0 ; if ( nBufSize < sizeof ( Header ) ) return 0 ; Header = * ( ( SerialHeader * ) pStream ) ; } unsigned nSizeAuxInts = ( ( sizeof ( CrySkinAuxInt ) * Header . numAuxInts + 3 ) & ~ 3 ) ; unsigned nSizeRequired = sizeof ( SerialHeader ) + nSizeAuxInts + sizeof ( Vertex ) * Header . numVertices ; if ( ! pStream ) return bSave ? nSizeRequired : 0 ; if ( nBufSize < nSizeRequired ) return 0 ; CrySkinAuxInt * pAuxInts = ( CrySkinAuxInt * ) ( ( ( SerialHeader * ) pStream ) + 1 ) ; Vertex * pVertices = ( Vertex * ) ( ( ( char * ) pAuxInts ) + nSizeAuxInts ) ; if ( bSave ) { * ( ( SerialHeader * ) pStream ) = Header ; memcpy ( pAuxInts , & m_arrAux [ 0 ] , sizeof ( CrySkinAuxInt ) * m_arrAux . size ( ) ) ; memcpy ( pVertices , & m_arrVertices [ 0 ] , sizeof ( Vertex ) * m_arrVertices . size ( ) ) ; } else { m_arrAux . clear ( ) ; m_arrAux . resize ( Header . numAuxInts ) ; m_arrVertices . clear ( ) ; m_arrVertices . resize ( Header . numVertices ) ; m_numBones = Header . numBones ; m_numSkipBones = Header . numSkipBones ; m_numDests = Header . numDests ; memcpy ( & m_arrAux [ 0 ] , pAuxInts , sizeof ( CrySkinAuxInt ) * m_arrAux . size ( ) ) ; memcpy ( & m_arrVertices [ 0 ] , pVertices , sizeof ( Vertex ) * m_arrVertices . size ( ) ) ; } return nSizeRequired ; }
this is the serialize version for little-endian CPUs
this is the serialize version for little - endian CPUs
// the m_numBones, m_numSkipBones, m_numDests
 // m_arrAux.size(), m_arrVertices.size()
 //saving
 // loading
