Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Data/Sys/GameFiles/GALE01/GameSetup.dat
Binary file not shown.
Binary file modified Data/Sys/GameFiles/GALE01/GameSetup_gui.dat
Binary file not shown.
Binary file not shown.
15 changes: 8 additions & 7 deletions Data/Sys/GameSettings/GALE01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3369,18 +3369,19 @@ C22600A8 0000000B #Online/Menus/CSS/PreventColorChange.asm
618C028C 7D8903A6
4E800420 3C60803F
60000000 00000000
C226699C 00000028 #Online/Menus/CSS/SceneLoadCSS.asm
4800002C 4E800021
C226699C 00000029 #Online/Menus/CSS/SceneLoadCSS.asm
48000034 4E800021
C2E00000 41A00000
00000000 3DCCCCCD
736C7043 53532E64
61740073 6C704353
53000000 900DB638
536C6970 70694353
535F6775 692E6461
7400736C 70435353
00000000 900DB638
3C608048 80639D30
5463443E 2C030008
408200F8 7C0802A6
90010004 9421FF20
BE8100B0 4BFFFFB1
BE8100B0 4BFFFFA9
7FC802A6 3D808000
618C5618 7D8903A6
4E800421 7C6802A6
Expand All @@ -3404,7 +3405,7 @@ BE8100B0 4BFFFFB1
987F001A 387E0010
3D808001 618C6BE0
7D8903A6 4E800421
389E001B 3D808038
389E0022 3D808038
618C0358 7D8903A6
4E800421 907F0004
BA8100B0 800100E4
Expand Down
15 changes: 8 additions & 7 deletions Data/Sys/GameSettings/GALJ01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3368,18 +3368,19 @@ C22600A8 0000000B #Online/Menus/CSS/PreventColorChange.asm
618C028C 7D8903A6
4E800420 3C60803F
60000000 00000000
C226699C 00000028 #Online/Menus/CSS/SceneLoadCSS.asm
4800002C 4E800021
C226699C 00000029 #Online/Menus/CSS/SceneLoadCSS.asm
48000034 4E800021
C2E00000 41A00000
00000000 3DCCCCCD
736C7043 53532E64
61740073 6C704353
53000000 900DB638
536C6970 70694353
535F6775 692E6461
7400736C 70435353
00000000 900DB638
3C608048 80639D30
5463443E 2C030008
408200F8 7C0802A6
90010004 9421FF20
BE8100B0 4BFFFFB1
BE8100B0 4BFFFFA9
7FC802A6 3D808000
618C5618 7D8903A6
4E800421 7C6802A6
Expand All @@ -3403,7 +3404,7 @@ BE8100B0 4BFFFFB1
987F001A 387E0010
3D808001 618C6BE0
7D8903A6 4E800421
389E001B 3D808038
389E0022 3D808038
618C0358 7D8903A6
4E800421 907F0004
BA8100B0 800100E4
Expand Down
8 changes: 7 additions & 1 deletion Source/Core/Core/HW/DVD/DVDThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,13 @@ void DVDThread::ReadFile(std::string& fileName, std::vector<u8>& buf)
{
WaitUntilIdle();
const DiscIO::FileSystem* filesystem = m_disc->GetFileSystem(DiscIO::PARTITION_NONE);
auto fileInfo = filesystem->FindFileInfo(fileName);
auto fileInfo = filesystem ? filesystem->FindFileInfo(fileName) : nullptr;
if (!fileInfo)
{
// Game file links can name any disc file, so a missing one must not crash
INFO_LOG_FMT(SLIPPI, "File not found on disc: {}", fileName);
return;
}
auto fileSize = fileInfo->GetSize();
buf.resize(fileSize);
DiscIO::ReadFile(*m_disc, DiscIO::PARTITION_NONE, fileInfo.get(), buf.data(), fileSize);
Expand Down
2 changes: 0 additions & 2 deletions Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2351,7 +2351,6 @@ void CEXISlippi::prepareOnlineMatchState()
// Check if someone is picking dumb characters in non-direct
auto local_char_ok = lps.character_id < 26;
auto remote_char_ok = true;
INFO_LOG_FMT(SLIPPI_ONLINE, "remote_player_count: {}", remote_player_count);
for (int i = 0; i < remote_player_count; i++)
{
if (rps[i].character_id >= 26)
Expand Down Expand Up @@ -2442,7 +2441,6 @@ void CEXISlippi::prepareOnlineMatchState()

// Set rng offset
rng_offset = is_decider ? lps.rng_offset : rps[0].rng_offset;
INFO_LOG_FMT(SLIPPI_ONLINE, "Rng Offset: {:#x}", rng_offset);

// Check if everyone is the same color
auto first_team_id = ordered_selections[0]->team_id;
Expand Down
69 changes: 69 additions & 0 deletions Source/Core/Core/Slippi/SlippiGameFileLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#include "Common/FileUtil.h"
#include "Common/IOFile.h"
#include "Common/Logging/Log.h"
#include "Common/Timer.h"
#include "Core/Boot/Boot.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/HW/DVD/DVDThread.h"
#include "Core/System.h"
#include "SlippiRustExtensions.h"

std::string getFilePath(std::string file_name)
{
Expand All @@ -29,6 +31,67 @@ std::string getFilePath(std::string file_name)
return "";
}

bool SlippiGameFileLoader::readDiscFile(void* ctx, const char* file_name, const u8** out_data,
uintptr_t* out_len)
{
auto* loader = static_cast<SlippiGameFileLoader*>(ctx);
std::string name(file_name);

// ReadFile leaves the buffer untouched when it can't read the file, so clear it first to avoid
// handing Rust the previous file
loader->disc_read_buffer.clear();
Core::System::GetInstance().GetDVDThread().ReadFile(name, loader->disc_read_buffer);

*out_data = loader->disc_read_buffer.data();
*out_len = loader->disc_read_buffer.size();
return !loader->disc_read_buffer.empty();
}

bool SlippiGameFileLoader::resolveLinks(const std::string& file_name, std::string& contents)
{
u64 start_ms = Common::Timer::NowMs();

SlippiResolvedGameFile result =
slprs_gamefile_resolve(file_name.c_str(), reinterpret_cast<const u8*>(contents.data()),
contents.size(), this, &SlippiGameFileLoader::readDiscFile);
disc_read_buffer.clear();
disc_read_buffer.shrink_to_fit();

if (result.status == SLPRS_GAMEFILE_NO_LINKS)
{
return true;
}

if (result.status != SLPRS_GAMEFILE_RESOLVED)
{
// Serve nothing rather than a file with dangling links. The reason was logged by Rust
ERROR_LOG_FMT(SLIPPI, "Serving nothing for {} because its links could not be resolved",
file_name);
contents.clear();
return false;
}

contents.assign(reinterpret_cast<const char*>(result.data), result.len);
slprs_gamefile_free(result);
INFO_LOG_FMT(SLIPPI, "Resolved links in {}, {} bytes, took {} ms", file_name, contents.size(),
Common::Timer::NowMs() - start_ms);

// Drop a copy for offline comparison when the user has created the dump folder
std::string dump_dir = File::GetUserPath(D_DUMP_IDX) + "GameFiles/";
if (File::IsDirectory(dump_dir))
{
std::string dump_path = dump_dir + file_name;
if (File::WriteStringToFile(dump_path, contents))
INFO_LOG_FMT(SLIPPI, "Wrote resolved {} to {}", file_name, dump_path);
}
else
{
INFO_LOG_FMT(SLIPPI, "Create {} to dump resolved game files", dump_dir);
}

return true;
}

u32 SlippiGameFileLoader::LoadFile(Core::System& system, std::string file_name, std::string& data)
{
if (file_cache.count(file_name))
Expand Down Expand Up @@ -75,6 +138,12 @@ u32 SlippiGameFileLoader::LoadFile(Core::System& system, std::string file_name,
decoder.Decode((char*)buf.data(), buf.size(), diff_contents, &file_contents);
}

// Pull in any assets the file links to on the disc
if (!file_contents.empty())
{
resolveLinks(file_name, file_contents);
}

file_cache[file_name] = file_contents;
data = file_cache[file_name];
INFO_LOG_FMT(SLIPPI, "File size: {}", static_cast<u32>(data.size()));
Expand Down
9 changes: 9 additions & 0 deletions Source/Core/Core/Slippi/SlippiGameFileLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ class SlippiGameFileLoader
std::set<std::string> grpsx_strings = {"GrPs1.dat", "GrPs2.dat", "GrPs3.dat", "GrPs4.dat"};

protected:
// Replaces the slp: links in an archive with the assets they name, read from the disc. Returns
// false and empties contents when a link could not be resolved
bool resolveLinks(const std::string& file_name, std::string& contents);
static bool readDiscFile(void* ctx, const char* file_name, const u8** out_data,
uintptr_t* out_len);

std::unordered_map<std::string, std::string> file_cache;
open_vcdiff::VCDiffDecoder decoder;

// Holds the disc file most recently handed to Rust by readDiscFile
std::vector<u8> disc_read_buffer;
};
Loading