Skip to content

Commit

Permalink
Extended cases when the game can set loadscreen level logo
Browse files Browse the repository at this point in the history
Now it can set level logos from Clear Sky and Shadow of Chernobyl
  • Loading branch information
Xottab-DUTY committed Apr 2, 2019
1 parent a799fc4 commit 01b07c2
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions src/xrEngine/x_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,52 +399,62 @@ 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);

u32 len = xr_strlen(dest);
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);
}

Expand Down

1 comment on commit 01b07c2

@Xottab-DUTY
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #382 and #392

Please sign in to comment.