bool DEntity::LoadFromEntity( scene::Node& ent, bool bLoadPatches ) { ClearPatches(); ClearBrushes(); ClearEPairs(); QER_Entity = &ent; LoadEPairList( Node_getEntity( ent ) ); bool keep = false; int i; for ( i = 0; brushEntityList[i]; i++ ) { if ( string_equal_nocase( brushEntityList[i], m_Classname ) ) { keep = true; break; } } if ( !keep ) { return false; } if ( Node_getTraversable( ent ) ) { class load_brushes_t : public scene::Traversable::Walker { DEntity* m_entity; mutable int m_count; public: load_brushes_t( DEntity* entity ) : m_entity( entity ), m_count( 0 ){ } bool pre( scene::Node& node ) const { scene::Path path( NodeReference( GlobalSceneGraph().root() ) ); path.push( NodeReference( *m_entity->QER_Entity ) ); path.push( NodeReference( node ) ); scene::Instance* instance = GlobalSceneGraph().find( path ); ASSERT_MESSAGE( instance != 0, "" ); if ( Node_isPatch( node ) ) { DPatch* loadPatch = m_entity->NewPatch(); loadPatch->LoadFromPatch( *instance ); } else if ( Node_isBrush( node ) ) { DBrush* loadBrush = m_entity->NewBrush( m_count++ ); loadBrush->LoadFromBrush( *instance, true ); } return false; } } load_brushes( this ); Node_getTraversable( ent )->traverse( load_brushes ); } return true; }
bool DEntity::LoadFromEntity( entity_t* ent, bool bLoadPatches ) { ClearPatches(); ClearBrushes(); ClearEPairs(); QER_Entity = ent; epair_t* epl = *g_EntityTable.m_pfnGetEntityKeyValList( QER_Entity ); LoadEPairList( epl ); bool keep = FALSE; int i; for ( i = 0; brushEntityList[i]; i++ ) { if ( !stricmp( brushEntityList[i], m_Classname ) ) { keep = TRUE; break; } } if ( !keep ) { return FALSE; } int count = g_FuncTable.m_pfnAllocateEntityBrushHandles( QER_Entity ); for ( i = 0; i < count; i++ ) { brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetEntityBrushHandle( i ); if ( brush == NULL ) { DoMessageBox( "GTKRadiant returned a NULL pointer, NOT a good sign", "WARNING!!!", MB_OK ); continue; } if ( brush->pPatch ) { if ( bLoadPatches ) { DPatch* loadPatch = NewPatch(); loadPatch->LoadFromBrush_t( brush ); } } else { DBrush* loadBrush = NewBrush( i ); loadBrush->LoadFromBrush_t( brush, TRUE ); } } g_FuncTable.m_pfnReleaseEntityBrushHandles(); return TRUE; }