View Single Post
Re: fread and large amounts of data
Old
  (#9)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: fread and large amounts of data - 16-01-2004

I'll try that since it will save work down the line. Basically, my class loads BSPs like this...

Code:
  
bool CBSPReader::Open( const char* pszPath )
{
   m_pFile = fopen( pszPath, "rb" );
   if ( m_pFile != NULL )
   {
	  if ( ReadHeader( ) == true )
	  {
		 return true;
	  }
   }
   return false;
}
bool CBSPReader::ReadHeader( void )
{
   m_pHeader = new dheader_t( );
   if ( m_pHeader != NULL )
   {
	  fread( m_pHeader, sizeof( dheader_t ), 1, m_pFile );
	  return true;
   }
   return false;
}
bool CBSPReader::LoadData( unsigned int uiBits )
{
   if ( uiBits & LOAD_MODELS )
   {
	  m_pModels = new dmodel_t[ MAX_MAP_MODELS ];
	  if ( m_pModels == NULL ) 
		 return false;
	  ReadLump( LUMP_MODELS, m_pModels );
   }
...
...
ect...
Shouldn't be that hard to change since the header is loaded and verified before any other loading takes place.

Actually, the user must specify ( with a bitmask ) what parts of the BSP to load. That should take place after Open returns true.
  
Reply With Quote