Sources/CcgDump/CgfUtils.cpp
//////////////////////////////////////////////////////////////////////////
// given the chunk, parses it and returns the array of pointers to the strings with the bone names 
// in the supplied array. Returns true when successful
// PARAMETERS:
//  chunkHeader - the header of the chunk in the chunk table
//  pChunk      - the raw chunk data in the file
//  nChunkSize  - the size of the raw data piece in the file
//  arrNames    - the array that will be resized according to the number of entries, and each element of this array
//                will be the pointer to the corresponding 0-terminated name string.

given the chunk, parses it and returns the array of pointers to the strings with the bone names
in the supplied array.
given the chunk parses it and returns the array of pointers to the strings with the bone names in the supplied array .
bool LoadBoneNameList (const CHUNK_HEADER& chunkHeader, const void* pChunk, unsigned nChunkSize, std::vector<const char*>& arrNames)
{
	switch (chunkHeader.ChunkVersion)
	{
		case BONENAMELIST_CHUNK_DESC_0744::VERSION:
		{
			const BONENAMELIST_CHUNK_DESC_0744* pNameChunk = (const BONENAMELIST_CHUNK_DESC_0744*)(pChunk);
			int nGeomBones = pNameChunk->nEntities;
			const NAME_ENTITY* pGeomBoneNameTable = (const NAME_ENTITY*)(pNameChunk+1);
			if(nGeomBones < 0 || nGeomBones > 0x800)
				return false;
			arrNames.resize(nGeomBones);
			for (int i = 0; i < nGeomBones; ++i)
				arrNames[i] = pGeomBoneNameTable[i].name;
		}
		break;
		case BONENAMELIST_CHUNK_DESC_0745::VERSION:
		{
			const BONENAMELIST_CHUNK_DESC_0745* pNameChunk = (const BONENAMELIST_CHUNK_DESC_0745*)(pChunk);
			int nGeomBones = pNameChunk->numEntities;
			arrNames.resize(nGeomBones, "");
			const char* pNameListEnd = ((const char*)pNameChunk) + nChunkSize;
			const char* pName = (const char*)(pNameChunk+1);
			int nName = 0;
			while (*pName && pName < pNameListEnd && nName < nGeomBones)
			{
				arrNames[nName] = pName;
				pName += strnlen(pName, pNameListEnd) + 1;
				++nName;
			}
			if (nName < nGeomBones)
			{
#ifdef _CRY_ANIMATION_BASE_HEADER_
				g_GetLog()->LogWarning ("\003inconsistent bone name list chunk: only %d out of %d bone names have been read.", nName, nGeomBones);
#endif
				return false;
			}
		}
		break;
	}
	return true;
}
bool LoadBoneNameList ( const CHUNK_HEADER & chunkHeader , const void * pChunk , unsigned nChunkSize , std :: vector < const char * > & arrNames ) { switch ( chunkHeader . ChunkVersion ) { case BONENAMELIST_CHUNK_DESC_0744 :: VERSION : { const BONENAMELIST_CHUNK_DESC_0744 * pNameChunk = ( const BONENAMELIST_CHUNK_DESC_0744 * ) ( pChunk ) ; int nGeomBones = pNameChunk -> nEntities ; const NAME_ENTITY * pGeomBoneNameTable = ( const NAME_ENTITY * ) ( pNameChunk + 1 ) ; if ( nGeomBones < 0 || nGeomBones > 0x800 ) return false ; arrNames . resize ( nGeomBones ) ; for ( int i = 0 ; i < nGeomBones ; ++ i ) arrNames [ i ] = pGeomBoneNameTable [ i ] . name ; } break ; case BONENAMELIST_CHUNK_DESC_0745 :: VERSION : { const BONENAMELIST_CHUNK_DESC_0745 * pNameChunk = ( const BONENAMELIST_CHUNK_DESC_0745 * ) ( pChunk ) ; int nGeomBones = pNameChunk -> numEntities ; arrNames . resize ( nGeomBones , " " ) ; const char * pNameListEnd = ( ( const char * ) pNameChunk ) + nChunkSize ; const char * pName = ( const char * ) ( pNameChunk + 1 ) ; int nName = 0 ; while ( * pName && pName < pNameListEnd && nName < nGeomBones ) { arrNames [ nName ] = pName ; pName += strnlen ( pName , pNameListEnd ) + 1 ; ++ nName ; } if ( nName < nGeomBones ) { #ifdef _CRY_ANIMATION_BASE_HEADER_ g_GetLog ( ) -> LogWarning ( " \003 " , nName , nGeomBones ) ; #endif return false ; } } break ; } return true ; }
given the chunk, parses it and returns the array of pointers to the strings with the bone names
in the supplied array.
given the chunk parses it and returns the array of pointers to the strings with the bone names in the supplied array .
// the old chunk version - fixed-size name list
 // just fill in the pointers to the fixed-size string buffers
 // the new memory-economizing chunk with variable-length packed strings following tightly each other
 // we know how many strings there are there; the whole bunch of strings may 
 // be followed by pad zeros, to enable alignment
 // scan through all the strings, each string following immediately the 0 terminator of the previous one
 // the chunk is truncated
 // if this is in the engine, log the error
