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

Function Map_LoadFile

neo/tools/radiant/EditorMap.cpp:416–547  ·  view source on GitHub ↗

======================================================================================================================= Map_LoadFile ======================================================================================================================= */

Source from the content-addressed store, hash-verified

414 =======================================================================================================================
415 */
416void Map_LoadFile(const char *filename) {
417 entity_t *ent;
418 CWaitDlg dlg;
419 idStr fileStr, status;
420 idMapFile mapfile;
421
422 Sys_BeginWait();
423 Select_Deselect();
424
425 dlg.AllowCancel( true );
426 idStr( filename ).ExtractFileName( fileStr );
427 sprintf( status, "Loading %s...", fileStr.c_str() );
428 dlg.SetWindowText( status );
429 sprintf( status, "Reading file %s...", fileStr.c_str() );
430 dlg.SetText( status );
431
432 // SetInspectorMode(W_CONSOLE);
433 fileStr = filename;
434 fileStr.BackSlashesToSlashes();
435
436 common->Printf( "Map_LoadFile: %s\n", fileStr.c_str() );
437
438 // DG: make sure that this is set to the default value.
439 // it's changed when Entity_PostParse() is called with the worldspawn
440 // and the worldspawn has "allow_nospecular" "1" set
441 tr.allowNoSpecular = false;
442
443 Map_Free();
444
445 g_qeglobals.d_parsed_brushes = 0;
446 strcpy( currentmap, filename );
447
448 if(mapfile.Parse(filename, true, true)) {
449 g_qeglobals.bNeedConvert = false;
450 g_qeglobals.bOldBrushes = false;
451 g_qeglobals.bPrimitBrushes = false;
452 g_qeglobals.mapVersion = 1.0;
453
454 long lastUpdate = 0;
455 int count = mapfile.GetNumEntities();
456 for (int i = 0; i < count; i++) {
457 idMapEntity *mapent = mapfile.GetEntity(i);
458 if (mapent) {
459 idStr classname = mapent->epairs.GetString("classname");
460 // Update 20 times a second
461 if ( (GetTickCount() - lastUpdate) > 50 ) {
462 lastUpdate = GetTickCount();
463 sprintf(status, "Loading entity %i (%s)...", i, classname.c_str());
464 dlg.SetText(status);
465 }
466 if ( dlg.CancelPressed() ) {
467 Sys_Status("Map load cancelled.\n");
468 Map_New();
469 return;
470 }
471 if (classname == "worldspawn") {
472 world_entity = EntityFromMapEntity(mapent, &dlg);
473 Entity_PostParse(world_entity, &active_brushes);

Callers 4

OnCreateMethod · 0.85
DoMruFunction · 0.85
Map_VerifyCurrentMapFunction · 0.85
OpenDialogFunction · 0.85

Calls 15

Sys_BeginWaitFunction · 0.85
Select_DeselectFunction · 0.85
sprintfFunction · 0.85
Map_FreeFunction · 0.85
Sys_StatusFunction · 0.85
Map_NewFunction · 0.85
EntityFromMapEntityFunction · 0.85
Entity_PostParseFunction · 0.85
Entity_NameFunction · 0.85
Map_RestoreBetweenFunction · 0.85
Map_BuildBrushDataFunction · 0.85
AngledEntityFunction · 0.85

Tested by

no test coverage detected