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

Method LoadLevel

Source/Main/engine.cpp:5597–5813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5595}
5596
5597void Engine::LoadLevel(Path queued_level) {
5598 GetAssetManager()->SetLoadWarningMode(false, "", "");
5599 Shaders::Instance()->level_path = queued_level;
5600 Shaders::Instance()->create_program_warning = false;
5601
5602 PROFILER_ZONE(g_profiler_ctx, "Loading queued level");
5603 PROFILER_NAME_TIMELINE(g_profiler_ctx, "Loading level");
5604
5605 Path level_path = queued_level;
5606
5607 latest_level_path_ = level_path;
5608
5609 std::string difficulty = config.GetClosestDifficulty();
5610
5611 if (difficulty == "Casual") {
5612 loading_screen_og_logo = loading_screen_og_logo_casual;
5613 } else if (difficulty == "Hardcore") {
5614 loading_screen_og_logo = loading_screen_og_logo_hardcore;
5615 } else if (difficulty == "Expert") {
5616 loading_screen_og_logo = loading_screen_og_logo_expert;
5617 }
5618
5619 if (level_path.isValid()) {
5620 LevelInfoAssetRef lia = Engine::Instance()->GetAssetManager()->LoadSync<LevelInfoAsset>(level_path.GetOriginalPath());
5621 if (lia.valid()) {
5622 Path shortest_path = FindShortestPath2(level_path.GetFullPath());
5623 const char* shortest_path_orig_folder = shortest_path.GetOriginalPath();
5624
5625 if (beginswith(shortest_path_orig_folder, "Data/Levels/")) {
5626 shortest_path_orig_folder = &shortest_path_orig_folder[strlen("Data/Levels/")];
5627 }
5628
5629 level_has_screenshot = false;
5630 level_screenshot.clear();
5631 char screenshot_path[kPathSize];
5632
5633 if (lia->GetLoadingScreenImage().empty() == false) {
5634 strscpy(screenshot_path, lia->GetLoadingScreenImage().c_str(), kPathSize);
5635 } else {
5636 LOGI << "No loading screen image, loading normal." << std::endl;
5637
5638 FormatString(screenshot_path, kPathSize, "Data/LevelLoading/%s_loading.jpg", shortest_path_orig_folder);
5639 }
5640
5641 if (FileExists(screenshot_path, kModPaths | kDataPaths)) {
5642 level_screenshot = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>(screenshot_path, PX_NOCONVERT | PX_NOREDUCE | PX_NOMIPMAP, 0x0);
5643 } else if (Online::Instance()->IsActive()) {
5644 // Multiplayer needs an image for the "waiting for all clients" dialogue!
5645 strscpy(screenshot_path, "Data/Images/full_fallback.png", kPathSize);
5646 if (FileExists(screenshot_path, kModPaths | kDataPaths)) {
5647 level_screenshot = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>(screenshot_path, PX_NOCONVERT | PX_NOREDUCE | PX_NOMIPMAP, 0x0);
5648 } else {
5649 level_screenshot = loading_screen_logo; // Won't render correctly! Still better than nothing!
5650 }
5651 }
5652
5653 if (level_screenshot.valid()) {
5654 level_has_screenshot = true;

Callers

nothing calls this directly

Calls 15

FindShortestPath2Function · 0.85
beginswithFunction · 0.85
strscpyFunction · 0.85
FormatStringFunction · 0.85
FileExistsFunction · 0.85
maxFunction · 0.85
AddLoadingTextFunction · 0.85
UIShowCursorFunction · 0.85
SDL_TS_GetTicksFunction · 0.85
DisplayLastQueuedErrorFunction · 0.85
SetLoadWarningModeMethod · 0.80
GetClosestDifficultyMethod · 0.80

Tested by

no test coverage detected