MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / LoadDMapFile

Function LoadDMapFile

neo/tools/compilers/dmap/map.cpp:512–576  ·  view source on GitHub ↗

================ LoadDMapFile ================ */

Source from the content-addressed store, hash-verified

510================
511*/
512bool LoadDMapFile( const char *filename ) {
513 primitive_t *prim;
514 idBounds mapBounds;
515 int brushes, triSurfs;
516 int i;
517 int size;
518
519 common->Printf( "--- LoadDMapFile ---\n" );
520 common->Printf( "loading %s\n", filename );
521
522 // load and parse the map file into canonical form
523 dmapGlobals.dmapFile = new idMapFile();
524 if ( !dmapGlobals.dmapFile->Parse(filename) ) {
525 delete dmapGlobals.dmapFile;
526 dmapGlobals.dmapFile = NULL;
527 common->Warning( "Couldn't load map file: '%s'", filename );
528 return false;
529 }
530
531 dmapGlobals.mapPlanes.Clear();
532 dmapGlobals.mapPlanes.SetGranularity( 1024 );
533
534 // process the canonical form into utility form
535 dmapGlobals.num_entities = 0;
536 c_numMapPatches = 0;
537 c_areaportals = 0;
538
539 size = dmapGlobals.dmapFile->GetNumEntities() * sizeof( dmapGlobals.uEntities[0] );
540 dmapGlobals.uEntities = (uEntity_t *)Mem_Alloc( size );
541 memset( dmapGlobals.uEntities, 0, size );
542
543 // allocate a very large temporary brush for building
544 // the brushes as they are loaded
545 buildBrush = AllocBrush( MAX_BUILD_SIDES );
546
547 for ( i = 0 ; i < dmapGlobals.dmapFile->GetNumEntities() ; i++ ) {
548 ProcessMapEntity( dmapGlobals.dmapFile->GetEntity(i) );
549 }
550
551 CreateMapLights( dmapGlobals.dmapFile );
552
553 brushes = 0;
554 triSurfs = 0;
555
556 mapBounds.Clear();
557 for ( prim = dmapGlobals.uEntities[0].primitives ; prim ; prim = prim->next ) {
558 if ( prim->brush ) {
559 brushes++;
560 mapBounds.AddBounds( prim->brush->bounds );
561 } else if ( prim->tris ) {
562 triSurfs++;
563 }
564 }
565
566 common->Printf( "%5i total world brushes\n", brushes );
567 common->Printf( "%5i total world triSurfs\n", triSurfs );
568 common->Printf( "%5i patches\n", c_numMapPatches );
569 common->Printf( "%5i entities\n", dmapGlobals.num_entities );

Callers 1

DmapFunction · 0.85

Calls 13

Mem_AllocFunction · 0.85
AllocBrushFunction · 0.85
ProcessMapEntityFunction · 0.85
CreateMapLightsFunction · 0.85
GetNumEntitiesMethod · 0.80
PrintfMethod · 0.45
ParseMethod · 0.45
WarningMethod · 0.45
ClearMethod · 0.45
SetGranularityMethod · 0.45
GetEntityMethod · 0.45
AddBoundsMethod · 0.45

Tested by

no test coverage detected