MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / ClearLoadedLevel

Method ClearLoadedLevel

Source/Main/engine.cpp:5563–5595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5561}
5562
5563void Engine::ClearLoadedLevel() {
5564 // We want music in menues now, levels have to clear their own sounds.
5565 sound.ClearTransient();
5566 sound.UpdateGameTimestep(game_timer.timestep);
5567 sound.UpdateGameTimescale(1.0f);
5568 sound.Update();
5569 if (scenegraph_) {
5570 scenegraph_->Dispose();
5571 delete scenegraph_;
5572 scenegraph_ = NULL;
5573 }
5574 Models::Instance()->Dispose();
5575 Online::Instance()->ClearIDTranslations();
5576
5577 asset_manager.Update();
5578 asset_manager.DumpLoadWarningData("asset_manager_warnings.xml");
5579 ActiveCameras::Get()->SetCameraObject(NULL);
5580 level_loaded_ = false;
5581 DebugDraw::Instance()->Dispose();
5582
5583 if (config["full_level_unload"].toBool()) {
5584 LOGI << "Unloading all unreferenced assets after clearing level [full_level_unload: true]..." << std::endl;
5585 size_t pre_count = asset_manager.GetLoadedAssetCount();
5586 size_t tex_pre_count = asset_manager.GetAssetTypeCount(TEXTURE_ASSET);
5587 while (asset_manager.UnloadUnreferenced(0, 0)) {
5588 }
5589 Textures::Instance()->DeleteUnusedTextures();
5590 LOGI << (pre_count - asset_manager.GetLoadedAssetCount()) << " Assets were unloaded" << std::endl;
5591 LOGI << (tex_pre_count - asset_manager.GetAssetTypeCount(TEXTURE_ASSET)) << " Texture assets were unloaded" << std::endl;
5592 } else {
5593 LOGE << "Skipping post-clear level unload (Increases peak memory usage)[full_level_unload: false]" << std::endl;
5594 }
5595}
5596
5597void Engine::LoadLevel(Path queued_level) {
5598 GetAssetManager()->SetLoadWarningMode(false, "", "");

Callers

nothing calls this directly

Calls 14

ClearIDTranslationsMethod · 0.80
DumpLoadWarningDataMethod · 0.80
SetCameraObjectMethod · 0.80
toBoolMethod · 0.80
GetLoadedAssetCountMethod · 0.80
GetAssetTypeCountMethod · 0.80
UnloadUnreferencedMethod · 0.80
DeleteUnusedTexturesMethod · 0.80
GetFunction · 0.50
ClearTransientMethod · 0.45
UpdateGameTimestepMethod · 0.45
UpdateGameTimescaleMethod · 0.45

Tested by

no test coverage detected