From 01b07c2b33bb436afdf6c266fdce9e3f1f9dd686 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 29 Mar 2019 19:27:35 +0500 Subject: [PATCH] Extended cases when the game can set loadscreen level logo Now it can set level logos from Clear Sky and Shadow of Chernobyl --- src/xrEngine/x_ray.cpp | 54 +++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/src/xrEngine/x_ray.cpp b/src/xrEngine/x_ray.cpp index 55d3cc08973..9b8b5b81785 100644 --- a/src/xrEngine/x_ray.cpp +++ b/src/xrEngine/x_ray.cpp @@ -399,7 +399,7 @@ void CApplication::Level_Scan() FS.file_list_close(folder); } -void gen_logo_name(string_path& dest, LPCSTR level_name, int num) +void gen_logo_name(string_path& dest, LPCSTR level_name, int num = -1) { strconcat(sizeof(dest), dest, "intro" DELIMITER "intro_", level_name); @@ -407,44 +407,54 @@ void gen_logo_name(string_path& dest, LPCSTR level_name, int num) if (dest[len - 1] == _DELIMITER) dest[len - 1] = 0; + if (num < 0) + return; + string16 buff; xr_strcat(dest, sizeof(dest), "_"); xr_strcat(dest, sizeof(dest), xr_itoa(num + 1, buff, 10)); } +// Return true if logo exists +// Always sets the path even if logo doesn't exist +bool set_logo_path(string_path& path, pcstr levelName, int count = -1) +{ + gen_logo_name(path, levelName, count); + string_path temp2; + return FS.exist(temp2, "$game_textures$", path, ".dds") || FS.exist(temp2, "$level$", path, ".dds"); +} + void CApplication::Level_Set(u32 L) { if (L >= Levels.size()) return; FS.get_path("$level$")->_set(Levels[L].folder); + Level_Current = L; static string_path path; + path[0] = 0; - if (Level_Current != L) + int count = 0; + while (true) { - path[0] = 0; - - Level_Current = L; - - int count = 0; - while (true) - { - string_path temp2; - gen_logo_name(path, Levels[L].folder, count); - if (FS.exist(temp2, "$game_textures$", path, ".dds") || FS.exist(temp2, "$level$", path, ".dds")) - count++; - else - break; - } + if (set_logo_path(path, Levels[L].folder, count)) + count++; + else + break; + } - if (count) - { - int num = ::Random.randI(count); - gen_logo_name(path, Levels[L].folder, num); - } + if (count) + { + const int num = ::Random.randI(count); + gen_logo_name(path, Levels[L].folder, num); + } + else if (!set_logo_path(path, Levels[L].folder)) + { + if (!set_logo_path(path, "no_start_picture")) + path[0] = 0; } - if (path[0] && loadingScreen) + if (path[0]) loadingScreen->SetLevelLogo(path); }