======================================================================================================================= Map_LoadFile ======================================================================================================================= */
| 414 | ======================================================================================================================= |
| 415 | */ |
| 416 | void 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); |
no test coverage detected