Im almost positive...
Code:
bool CBSPReader::Allocate( void )
{
m_pHeader = new dheader_t( );
m_pModels = new dmodel_t[ MAX_MAP_MODELS ];
m_pVertexes = new dvertex_t[ MAX_MAP_VERTS ];
m_pPlanes = new dplane_t[ MAX_MAP_PLANES ];
m_pLeafs = new dleaf_t[ MAX_MAP_LEAFS ];
m_pNodes = new dnode_t[ MAX_MAP_NODES ];
m_pTexInfo = new texinfo_t[ MAX_MAP_TEXINFO ];
m_pClipNodes = new dclipnode_t[ MAX_MAP_CLIPNODES ];
if ( m_pHeader && m_pModels && m_pVertexes && m_pPlanes && m_pLeafs && m_pNodes
&& m_pTexInfo && m_pClipNodes )
{
return true;
}
return false;
}
bool CBSPReader::ReadLump( int iLump, void* ptr )
{
if ( ptr != NULL )
{
fseek( m_pFile, m_pHeader->lumps[ iLump ].fileofs, SEEK_SET );
fread( ptr, m_pHeader->lumps[ iLump ].filelen, 1, m_pFile );
return true;
}
return false;
}
Those are two parts of the class, for now, everything is allocated upon load of a bsp and freed on a call to delete. I tried using malloc aswell but it still came up with the same problem area of fread.
I have no clue why it crashes during the memory freeing though, I know fread fails due to debugging.