Misc: Normalize code vs serial usage
This commit is contained in:
@@ -61,8 +61,8 @@ add_library(core
|
||||
host_settings.h
|
||||
interrupt_controller.cpp
|
||||
interrupt_controller.h
|
||||
libcrypt_game_codes.cpp
|
||||
libcrypt_game_codes.h
|
||||
libcrypt_serials.cpp
|
||||
libcrypt_serials.h
|
||||
mdec.cpp
|
||||
mdec.h
|
||||
memory_card.cpp
|
||||
|
||||
@@ -684,7 +684,7 @@ bool CheatList::SaveToPCSXRFile(const char* filename)
|
||||
return (std::ferror(fp.get()) == 0);
|
||||
}
|
||||
|
||||
bool CheatList::LoadFromPackage(const std::string& game_code)
|
||||
bool CheatList::LoadFromPackage(const std::string& serial)
|
||||
{
|
||||
const std::optional<std::string> db_string(Host::ReadResourceFileToString("chtdb.txt"));
|
||||
if (!db_string.has_value())
|
||||
@@ -712,7 +712,7 @@ bool CheatList::LoadFromPackage(const std::string& game_code)
|
||||
if (start == end)
|
||||
continue;
|
||||
|
||||
if (start[0] != ':' || std::strcmp(&start[1], game_code.c_str()) != 0)
|
||||
if (start[0] != ':' || std::strcmp(&start[1], serial.c_str()) != 0)
|
||||
continue;
|
||||
|
||||
// game code match
|
||||
@@ -788,11 +788,11 @@ bool CheatList::LoadFromPackage(const std::string& game_code)
|
||||
if (current_code.Valid())
|
||||
m_codes.push_back(std::move(current_code));
|
||||
|
||||
Log_InfoPrintf("Loaded %zu codes from package for %s", m_codes.size(), game_code.c_str());
|
||||
Log_InfoPrintf("Loaded %zu codes from package for %s", m_codes.size(), serial.c_str());
|
||||
return !m_codes.empty();
|
||||
}
|
||||
|
||||
Log_WarningPrintf("No codes found in package for %s", game_code.c_str());
|
||||
Log_WarningPrintf("No codes found in package for %s", serial.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
|
||||
bool SaveToPCSXRFile(const char* filename);
|
||||
|
||||
bool LoadFromPackage(const std::string& game_code);
|
||||
bool LoadFromPackage(const std::string& serial);
|
||||
|
||||
void Apply();
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<ClCompile Include="host_display.cpp" />
|
||||
<ClCompile Include="host_interface_progress_callback.cpp" />
|
||||
<ClCompile Include="interrupt_controller.cpp" />
|
||||
<ClCompile Include="libcrypt_game_codes.cpp" />
|
||||
<ClCompile Include="libcrypt_serials.cpp" />
|
||||
<ClCompile Include="mdec.cpp" />
|
||||
<ClCompile Include="memory_card.cpp" />
|
||||
<ClCompile Include="memory_card_image.cpp" />
|
||||
@@ -129,7 +129,7 @@
|
||||
<ClInclude Include="host_interface_progress_callback.h" />
|
||||
<ClInclude Include="host_settings.h" />
|
||||
<ClInclude Include="interrupt_controller.h" />
|
||||
<ClInclude Include="libcrypt_game_codes.h" />
|
||||
<ClInclude Include="libcrypt_serials.h" />
|
||||
<ClInclude Include="mdec.h" />
|
||||
<ClInclude Include="memory_card.h" />
|
||||
<ClInclude Include="memory_card_image.h" />
|
||||
@@ -165,4 +165,4 @@
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="..\..\dep\msvc\vsprops\Targets.props" />
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -53,7 +53,7 @@
|
||||
<ClCompile Include="cpu_recompiler_code_generator_aarch32.cpp" />
|
||||
<ClCompile Include="gpu_backend.cpp" />
|
||||
<ClCompile Include="gpu_sw_backend.cpp" />
|
||||
<ClCompile Include="libcrypt_game_codes.cpp" />
|
||||
<ClCompile Include="libcrypt_serials.cpp" />
|
||||
<ClCompile Include="texture_replacements.cpp" />
|
||||
<ClCompile Include="multitap.cpp" />
|
||||
<ClCompile Include="gpu_hw_d3d12.cpp" />
|
||||
@@ -114,7 +114,7 @@
|
||||
<ClInclude Include="gpu_types.h" />
|
||||
<ClInclude Include="gpu_backend.h" />
|
||||
<ClInclude Include="gpu_sw_backend.h" />
|
||||
<ClInclude Include="libcrypt_game_codes.h" />
|
||||
<ClInclude Include="libcrypt_serials.h" />
|
||||
<ClInclude Include="texture_replacements.h" />
|
||||
<ClInclude Include="shader_cache_version.h" />
|
||||
<ClInclude Include="multitap.h" />
|
||||
|
||||
@@ -32,6 +32,7 @@ enum : u32
|
||||
};
|
||||
|
||||
static Entry* GetMutableEntry(const std::string_view& serial);
|
||||
static const Entry* GetEntryForId(const std::string_view& code);
|
||||
|
||||
static bool LoadFromCache();
|
||||
static bool SaveToCache();
|
||||
@@ -105,7 +106,7 @@ void GameDatabase::Unload()
|
||||
s_loaded = false;
|
||||
}
|
||||
|
||||
const GameDatabase::Entry* GameDatabase::GetEntryForCode(const std::string_view& code)
|
||||
const GameDatabase::Entry* GameDatabase::GetEntryForId(const std::string_view& code)
|
||||
{
|
||||
EnsureLoaded();
|
||||
|
||||
@@ -140,24 +141,23 @@ std::string GameDatabase::GetSerialForPath(const char* path)
|
||||
|
||||
const GameDatabase::Entry* GameDatabase::GetEntryForDisc(CDImage* image)
|
||||
{
|
||||
std::string exe_name_code(System::GetGameCodeForImage(image, false));
|
||||
if (!exe_name_code.empty())
|
||||
std::string id(System::GetGameIdFromImage(image, false));
|
||||
if (!id.empty())
|
||||
{
|
||||
const Entry* entry = GetEntryForCode(exe_name_code);
|
||||
const Entry* entry = GetEntryForId(id);
|
||||
if (entry)
|
||||
return entry;
|
||||
}
|
||||
|
||||
std::string exe_hash_code(System::GetGameHashCodeForImage(image));
|
||||
if (!exe_hash_code.empty())
|
||||
std::string hash_id(System::GetGameHashIdFromImage(image));
|
||||
if (!hash_id.empty())
|
||||
{
|
||||
const Entry* entry = GetEntryForCode(exe_hash_code);
|
||||
const Entry* entry = GetEntryForId(hash_id);
|
||||
if (entry)
|
||||
return entry;
|
||||
}
|
||||
|
||||
Log_WarningPrintf("No entry found for disc (exe code: '%s', hash code: '%s')", exe_name_code.c_str(),
|
||||
exe_hash_code.c_str());
|
||||
Log_WarningPrintf("No entry found for disc (exe code: '%s', hash code: '%s')", id.c_str(), hash_id.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -365,7 +365,8 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
|
||||
{
|
||||
Host::AddKeyedOSDMessage(
|
||||
"gamedb_disable_pgxp_texture",
|
||||
Host::TranslateStdString("OSDMessage", "PGXP perspective corrected textures disabled by game settings."), osd_duration);
|
||||
Host::TranslateStdString("OSDMessage", "PGXP perspective corrected textures disabled by game settings."),
|
||||
osd_duration);
|
||||
}
|
||||
|
||||
settings.gpu_pgxp_texture_correction = false;
|
||||
@@ -378,7 +379,8 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
|
||||
{
|
||||
Host::AddKeyedOSDMessage(
|
||||
"gamedb_disable_pgxp_texture",
|
||||
Host::TranslateStdString("OSDMessage", "PGXP perspective corrected colors disabled by game settings."), osd_duration);
|
||||
Host::TranslateStdString("OSDMessage", "PGXP perspective corrected colors disabled by game settings."),
|
||||
osd_duration);
|
||||
}
|
||||
|
||||
settings.gpu_pgxp_color_correction = false;
|
||||
|
||||
@@ -86,7 +86,6 @@ void Unload();
|
||||
|
||||
const Entry* GetEntryForDisc(CDImage* image);
|
||||
const Entry* GetEntryForSerial(const std::string_view& serial);
|
||||
const Entry* GetEntryForCode(const std::string_view& code);
|
||||
std::string GetSerialForDisc(CDImage* image);
|
||||
std::string GetSerialForPath(const char* path);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "libcrypt_game_codes.h"
|
||||
#include "libcrypt_serials.h"
|
||||
|
||||
namespace LibcryptGameList {
|
||||
|
||||
@@ -13,7 +13,7 @@ struct SAVE_STATE_HEADER
|
||||
enum : u32
|
||||
{
|
||||
MAX_TITLE_LENGTH = 128,
|
||||
MAX_GAME_CODE_LENGTH = 32,
|
||||
MAX_SERIAL_LENGTH = 32,
|
||||
|
||||
COMPRESSION_TYPE_NONE = 0,
|
||||
COMPRESSION_TYPE_ZLIB = 1,
|
||||
@@ -23,7 +23,7 @@ struct SAVE_STATE_HEADER
|
||||
u32 magic;
|
||||
u32 version;
|
||||
char title[MAX_TITLE_LENGTH];
|
||||
char game_code[MAX_GAME_CODE_LENGTH];
|
||||
char serial[MAX_SERIAL_LENGTH];
|
||||
|
||||
u32 media_filename_length;
|
||||
u32 offset_to_media_filename;
|
||||
|
||||
@@ -1112,8 +1112,8 @@ static std::array<const char*, 6> s_memory_card_type_names = {
|
||||
{"None", "Shared", "PerGame", "PerGameTitle", "PerGameFileTitle", "NonPersistent"}};
|
||||
static std::array<const char*, 6> s_memory_card_type_display_names = {
|
||||
{TRANSLATABLE("MemoryCardType", "No Memory Card"), TRANSLATABLE("MemoryCardType", "Shared Between All Games"),
|
||||
TRANSLATABLE("MemoryCardType", "Separate Card Per Game (Game Code)"),
|
||||
TRANSLATABLE("MemoryCardType", "Separate Card Per Game (Game Title)"),
|
||||
TRANSLATABLE("MemoryCardType", "Separate Card Per Game (Serial)"),
|
||||
TRANSLATABLE("MemoryCardType", "Separate Card Per Game (Title)"),
|
||||
TRANSLATABLE("MemoryCardType", "Separate Card Per Game (File Title)"),
|
||||
TRANSLATABLE("MemoryCardType", "Non-Persistent Card (Do Not Save)")}};
|
||||
|
||||
@@ -1160,9 +1160,9 @@ std::string Settings::GetSharedMemoryCardPath(u32 slot) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string Settings::GetGameMemoryCardPath(const char* game_code, u32 slot)
|
||||
std::string Settings::GetGameMemoryCardPath(const char* serial, u32 slot)
|
||||
{
|
||||
return Path::Combine(EmuFolders::MemoryCards, fmt::format("{}_{}.mcd", game_code, slot + 1));
|
||||
return Path::Combine(EmuFolders::MemoryCards, fmt::format("{}_{}.mcd", serial, slot + 1));
|
||||
}
|
||||
|
||||
static std::array<const char*, 4> s_multitap_enable_mode_names = {{"Disabled", "Port1Only", "Port2Only", "BothPorts"}};
|
||||
|
||||
@@ -294,7 +294,7 @@ struct Settings
|
||||
std::string GetSharedMemoryCardPath(u32 slot) const;
|
||||
|
||||
/// Returns the default path to a memory card for a specific game.
|
||||
static std::string GetGameMemoryCardPath(const char* game_code, u32 slot);
|
||||
static std::string GetGameMemoryCardPath(const char* serial, u32 slot);
|
||||
|
||||
static void CPUOverclockPercentToFraction(u32 percent, u32* numerator, u32* denominator);
|
||||
static u32 CPUOverclockFractionToPercent(u32 numerator, u32 denominator);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "host_interface_progress_callback.h"
|
||||
#include "host_settings.h"
|
||||
#include "interrupt_controller.h"
|
||||
#include "libcrypt_game_codes.h"
|
||||
#include "libcrypt_serials.h"
|
||||
#include "mdec.h"
|
||||
#include "memory_card.h"
|
||||
#include "multitap.h"
|
||||
@@ -135,7 +135,7 @@ static u32 s_frame_number = 1;
|
||||
static u32 s_internal_frame_number = 1;
|
||||
|
||||
static std::string s_running_game_path;
|
||||
static std::string s_running_game_code;
|
||||
static std::string s_running_game_serial;
|
||||
static std::string s_running_game_title;
|
||||
static bool s_running_bios;
|
||||
|
||||
@@ -305,9 +305,9 @@ const std::string& System::GetRunningPath()
|
||||
{
|
||||
return s_running_game_path;
|
||||
}
|
||||
const std::string& System::GetRunningCode()
|
||||
const std::string& System::GetRunningSerial()
|
||||
{
|
||||
return s_running_game_code;
|
||||
return s_running_game_serial;
|
||||
}
|
||||
|
||||
const std::string& System::GetRunningTitle()
|
||||
@@ -419,16 +419,16 @@ ConsoleRegion System::GetConsoleRegionForDiscRegion(DiscRegion region)
|
||||
}
|
||||
}
|
||||
|
||||
std::string System::GetGameCodeForPath(const char* image_path, bool fallback_to_hash)
|
||||
std::string System::GetGameSerialForPath(const char* image_path, bool fallback_to_hash)
|
||||
{
|
||||
std::unique_ptr<CDImage> cdi = CDImage::Open(image_path, false, nullptr);
|
||||
if (!cdi)
|
||||
return {};
|
||||
|
||||
return GetGameCodeForImage(cdi.get(), fallback_to_hash);
|
||||
return GetGameIdFromImage(cdi.get(), fallback_to_hash);
|
||||
}
|
||||
|
||||
std::string System::GetGameCodeForImage(CDImage* cdi, bool fallback_to_hash)
|
||||
std::string System::GetGameIdFromImage(CDImage* cdi, bool fallback_to_hash)
|
||||
{
|
||||
std::string code(GetExecutableNameForImage(cdi));
|
||||
if (!code.empty())
|
||||
@@ -456,10 +456,10 @@ std::string System::GetGameCodeForImage(CDImage* cdi, bool fallback_to_hash)
|
||||
if (!fallback_to_hash)
|
||||
return {};
|
||||
|
||||
return GetGameHashCodeForImage(cdi);
|
||||
return GetGameHashIdFromImage(cdi);
|
||||
}
|
||||
|
||||
std::string System::GetGameHashCodeForImage(CDImage* cdi)
|
||||
std::string System::GetGameHashIdFromImage(CDImage* cdi)
|
||||
{
|
||||
ISOReader iso;
|
||||
if (!iso.Open(cdi, 1))
|
||||
@@ -623,12 +623,12 @@ bool System::ReadExecutableFromImage(CDImage* cdi, std::string* out_executable_n
|
||||
return ReadExecutableFromImage(iso, out_executable_name, out_executable_data);
|
||||
}
|
||||
|
||||
DiscRegion System::GetRegionForCode(std::string_view code)
|
||||
DiscRegion System::GetRegionForSerial(std::string_view serial)
|
||||
{
|
||||
std::string prefix;
|
||||
for (size_t pos = 0; pos < code.length(); pos++)
|
||||
for (size_t pos = 0; pos < serial.length(); pos++)
|
||||
{
|
||||
const int ch = std::tolower(code[pos]);
|
||||
const int ch = std::tolower(serial[pos]);
|
||||
if (ch < 'a' || ch > 'z')
|
||||
break;
|
||||
|
||||
@@ -673,11 +673,11 @@ DiscRegion System::GetRegionForImage(CDImage* cdi)
|
||||
if (system_area_region != DiscRegion::Other)
|
||||
return system_area_region;
|
||||
|
||||
std::string code = GetGameCodeForImage(cdi, false);
|
||||
if (code.empty())
|
||||
std::string serial = GetGameIdFromImage(cdi, false);
|
||||
if (serial.empty())
|
||||
return DiscRegion::Other;
|
||||
|
||||
return GetRegionForCode(code);
|
||||
return GetRegionForSerial(serial);
|
||||
}
|
||||
|
||||
DiscRegion System::GetRegionForExe(const char* path)
|
||||
@@ -778,9 +778,9 @@ void System::LoadSettings(bool display_osd_messages)
|
||||
Host::LoadSettings(si, lock);
|
||||
|
||||
// apply compatibility settings
|
||||
if (g_settings.apply_compatibility_settings && !s_running_game_code.empty())
|
||||
if (g_settings.apply_compatibility_settings && !s_running_game_serial.empty())
|
||||
{
|
||||
const GameDatabase::Entry* entry = GameDatabase::GetEntryForSerial(s_running_game_code);
|
||||
const GameDatabase::Entry* entry = GameDatabase::GetEntryForSerial(s_running_game_serial);
|
||||
if (entry)
|
||||
entry->ApplySettings(g_settings, display_osd_messages);
|
||||
}
|
||||
@@ -828,9 +828,9 @@ bool System::ReloadGameSettings(bool display_osd_messages)
|
||||
bool System::UpdateGameSettingsLayer()
|
||||
{
|
||||
std::unique_ptr<INISettingsInterface> new_interface;
|
||||
if (g_settings.apply_game_settings && !s_running_game_code.empty())
|
||||
if (g_settings.apply_game_settings && !s_running_game_serial.empty())
|
||||
{
|
||||
std::string filename(GetGameSettingsPath(s_running_game_code));
|
||||
std::string filename(GetGameSettingsPath(s_running_game_serial));
|
||||
if (FileSystem::FileExists(filename.c_str()))
|
||||
{
|
||||
Log_InfoPrintf("Loading game settings from '%s'...", filename.c_str());
|
||||
@@ -1039,10 +1039,10 @@ bool System::SaveState(const char* filename, bool backup_existing_save)
|
||||
|
||||
bool System::SaveResumeState()
|
||||
{
|
||||
if (s_running_game_code.empty())
|
||||
if (s_running_game_serial.empty())
|
||||
return false;
|
||||
|
||||
const std::string path(GetGameSaveStateFileName(s_running_game_code, -1));
|
||||
const std::string path(GetGameSaveStateFileName(s_running_game_serial, -1));
|
||||
return SaveState(path.c_str(), false);
|
||||
}
|
||||
|
||||
@@ -1430,14 +1430,14 @@ void System::DestroySystem()
|
||||
|
||||
void System::ClearRunningGame()
|
||||
{
|
||||
s_running_game_code.clear();
|
||||
s_running_game_serial.clear();
|
||||
s_running_game_path.clear();
|
||||
s_running_game_title.clear();
|
||||
s_running_bios = false;
|
||||
s_cheat_list.reset();
|
||||
s_state = State::Shutdown;
|
||||
|
||||
Host::OnGameChanged(s_running_game_path, s_running_game_code, s_running_game_title);
|
||||
Host::OnGameChanged(s_running_game_path, s_running_game_serial, s_running_game_title);
|
||||
|
||||
#ifdef WITH_CHEEVOS
|
||||
Achievements::GameChanged(s_running_game_path, nullptr);
|
||||
@@ -1906,7 +1906,7 @@ bool System::InternalSaveState(ByteStream* state, u32 screenshot_size /* = 256 *
|
||||
header.magic = SAVE_STATE_MAGIC;
|
||||
header.version = SAVE_STATE_VERSION;
|
||||
StringUtil::Strlcpy(header.title, s_running_game_title.c_str(), sizeof(header.title));
|
||||
StringUtil::Strlcpy(header.game_code, s_running_game_code.c_str(), sizeof(header.game_code));
|
||||
StringUtil::Strlcpy(header.serial, s_running_game_serial.c_str(), sizeof(header.serial));
|
||||
|
||||
if (g_cdrom.HasMedia())
|
||||
{
|
||||
@@ -2634,7 +2634,7 @@ std::unique_ptr<MemoryCard> System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp
|
||||
{
|
||||
case MemoryCardType::PerGame:
|
||||
{
|
||||
if (s_running_game_code.empty())
|
||||
if (s_running_game_serial.empty())
|
||||
{
|
||||
Host::AddFormattedOSDMessage(
|
||||
5.0f,
|
||||
@@ -2645,7 +2645,7 @@ std::unique_ptr<MemoryCard> System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp
|
||||
}
|
||||
else
|
||||
{
|
||||
return MemoryCard::Open(g_settings.GetGameMemoryCardPath(s_running_game_code.c_str(), slot));
|
||||
return MemoryCard::Open(g_settings.GetGameMemoryCardPath(s_running_game_serial.c_str(), slot));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2857,13 +2857,13 @@ bool System::InsertMedia(const char* path)
|
||||
|
||||
UpdateRunningGame(path, image.get(), false);
|
||||
g_cdrom.InsertMedia(std::move(image));
|
||||
Log_InfoPrintf("Inserted media from %s (%s, %s)", s_running_game_path.c_str(), s_running_game_code.c_str(),
|
||||
Log_InfoPrintf("Inserted media from %s (%s, %s)", s_running_game_path.c_str(), s_running_game_serial.c_str(),
|
||||
s_running_game_title.c_str());
|
||||
if (g_settings.cdrom_load_image_to_ram)
|
||||
g_cdrom.PrecacheMedia();
|
||||
|
||||
Host::AddFormattedOSDMessage(10.0f, Host::TranslateString("OSDMessage", "Inserted disc '%s' (%s)."),
|
||||
s_running_game_title.c_str(), s_running_game_code.c_str());
|
||||
s_running_game_title.c_str(), s_running_game_serial.c_str());
|
||||
|
||||
if (g_settings.HasAnyPerGameMemoryCards())
|
||||
{
|
||||
@@ -2887,7 +2887,7 @@ void System::UpdateRunningGame(const char* path, CDImage* image, bool booting)
|
||||
return;
|
||||
|
||||
s_running_game_path.clear();
|
||||
s_running_game_code.clear();
|
||||
s_running_game_serial.clear();
|
||||
s_running_game_title.clear();
|
||||
|
||||
if (path && std::strlen(path) > 0)
|
||||
@@ -2904,13 +2904,13 @@ void System::UpdateRunningGame(const char* path, CDImage* image, bool booting)
|
||||
const GameDatabase::Entry* entry = GameDatabase::GetEntryForDisc(image);
|
||||
if (entry)
|
||||
{
|
||||
s_running_game_code = entry->serial;
|
||||
s_running_game_serial = entry->serial;
|
||||
s_running_game_title = entry->title;
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::string display_name(FileSystem::GetDisplayNameFromPath(path));
|
||||
s_running_game_code = GetGameCodeForImage(image, true);
|
||||
s_running_game_serial = GetGameIdFromImage(image, true);
|
||||
s_running_game_title = Path::GetFileTitle(display_name);
|
||||
}
|
||||
|
||||
@@ -2923,7 +2923,7 @@ void System::UpdateRunningGame(const char* path, CDImage* image, bool booting)
|
||||
}
|
||||
}
|
||||
|
||||
g_texture_replacements.SetGameID(s_running_game_code);
|
||||
g_texture_replacements.SetGameID(s_running_game_serial);
|
||||
|
||||
s_cheat_list.reset();
|
||||
if (g_settings.auto_load_cheats && !Achievements::ChallengeModeActive())
|
||||
@@ -2932,7 +2932,7 @@ void System::UpdateRunningGame(const char* path, CDImage* image, bool booting)
|
||||
UpdateGameSettingsLayer();
|
||||
ApplySettings(true);
|
||||
|
||||
Host::OnGameChanged(s_running_game_path, s_running_game_code, s_running_game_title);
|
||||
Host::OnGameChanged(s_running_game_path, s_running_game_serial, s_running_game_title);
|
||||
|
||||
#ifdef WITH_CHEEVOS
|
||||
if (booting)
|
||||
@@ -2944,13 +2944,13 @@ void System::UpdateRunningGame(const char* path, CDImage* image, bool booting)
|
||||
|
||||
bool System::CheckForSBIFile(CDImage* image)
|
||||
{
|
||||
if (s_running_game_code.empty() || !LibcryptGameList::IsLibcryptGameCode(s_running_game_code) || !image ||
|
||||
if (s_running_game_serial.empty() || !LibcryptGameList::IsLibcryptGameCode(s_running_game_serial) || !image ||
|
||||
image->HasNonStandardSubchannel())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Log_WarningPrintf("SBI file missing but required for %s (%s)", s_running_game_code.c_str(),
|
||||
Log_WarningPrintf("SBI file missing but required for %s (%s)", s_running_game_serial.c_str(),
|
||||
s_running_game_title.c_str());
|
||||
|
||||
if (Host::GetBoolSettingValue("CDROM", "AllowBootingWithoutSBIFile", false))
|
||||
@@ -2963,7 +2963,7 @@ bool System::CheckForSBIFile(CDImage* image)
|
||||
"You are attempting to run a libcrypt protected game without an SBI file:\n\n%s: %s\n\nThe game will "
|
||||
"likely not run properly.\n\nPlease check the README for instructions on how to add an SBI file.\n\nDo "
|
||||
"you wish to continue?"),
|
||||
s_running_game_code.c_str(), s_running_game_title.c_str())
|
||||
s_running_game_serial.c_str(), s_running_game_title.c_str())
|
||||
.c_str());
|
||||
}
|
||||
else
|
||||
@@ -2976,7 +2976,7 @@ bool System::CheckForSBIFile(CDImage* image)
|
||||
"You are attempting to run a libcrypt protected game without an SBI file:\n\n%s: %s\n\nYour dump is "
|
||||
"incomplete, you must add the SBI file to run this game. \n\n"
|
||||
"The name of the SBI file must match the name of the disc image."),
|
||||
s_running_game_code.c_str(), s_running_game_title.c_str()));
|
||||
s_running_game_serial.c_str(), s_running_game_title.c_str()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3695,15 +3695,15 @@ bool System::StartDumpingAudio(const char* filename)
|
||||
std::string auto_filename;
|
||||
if (!filename)
|
||||
{
|
||||
const auto& code = System::GetRunningCode();
|
||||
if (code.empty())
|
||||
const auto& serial = System::GetRunningSerial();
|
||||
if (serial.empty())
|
||||
{
|
||||
auto_filename = Path::Combine(
|
||||
EmuFolders::Dumps, fmt::format("audio" FS_OSPATH_SEPARATOR_STR "{}.wav", GetTimestampStringForFileName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto_filename = Path::Combine(EmuFolders::Dumps, fmt::format("audio" FS_OSPATH_SEPARATOR_STR "{}_{}.wav", code,
|
||||
auto_filename = Path::Combine(EmuFolders::Dumps, fmt::format("audio" FS_OSPATH_SEPARATOR_STR "{}_{}.wav", serial,
|
||||
GetTimestampStringForFileName()));
|
||||
}
|
||||
|
||||
@@ -3740,7 +3740,7 @@ bool System::SaveScreenshot(const char* filename /* = nullptr */, bool full_reso
|
||||
std::string auto_filename;
|
||||
if (!filename)
|
||||
{
|
||||
const auto& code = System::GetRunningCode();
|
||||
const auto& code = System::GetRunningSerial();
|
||||
const char* extension = "png";
|
||||
if (code.empty())
|
||||
{
|
||||
@@ -3779,12 +3779,12 @@ bool System::SaveScreenshot(const char* filename /* = nullptr */, bool full_reso
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string System::GetGameSaveStateFileName(const std::string_view& game_code, s32 slot)
|
||||
std::string System::GetGameSaveStateFileName(const std::string_view& serial, s32 slot)
|
||||
{
|
||||
if (slot < 0)
|
||||
return Path::Combine(EmuFolders::SaveStates, fmt::format("{}_resume.sav", game_code));
|
||||
return Path::Combine(EmuFolders::SaveStates, fmt::format("{}_resume.sav", serial));
|
||||
else
|
||||
return Path::Combine(EmuFolders::SaveStates, fmt::format("{}_{}.sav", game_code, slot));
|
||||
return Path::Combine(EmuFolders::SaveStates, fmt::format("{}_{}.sav", serial, slot));
|
||||
}
|
||||
|
||||
std::string System::GetGlobalSaveStateFileName(s32 slot)
|
||||
@@ -3795,7 +3795,7 @@ std::string System::GetGlobalSaveStateFileName(s32 slot)
|
||||
return Path::Combine(EmuFolders::SaveStates, fmt::format("savestate_{}.sav", slot));
|
||||
}
|
||||
|
||||
std::vector<SaveStateInfo> System::GetAvailableSaveStates(const char* game_code)
|
||||
std::vector<SaveStateInfo> System::GetAvailableSaveStates(const char* serial)
|
||||
{
|
||||
std::vector<SaveStateInfo> si;
|
||||
std::string path;
|
||||
@@ -3808,11 +3808,11 @@ std::vector<SaveStateInfo> System::GetAvailableSaveStates(const char* game_code)
|
||||
si.push_back(SaveStateInfo{std::move(path), sd.ModificationTime, static_cast<s32>(slot), global});
|
||||
};
|
||||
|
||||
if (game_code && std::strlen(game_code) > 0)
|
||||
if (serial && std::strlen(serial) > 0)
|
||||
{
|
||||
add_path(GetGameSaveStateFileName(game_code, -1), -1, false);
|
||||
add_path(GetGameSaveStateFileName(serial, -1), -1, false);
|
||||
for (s32 i = 1; i <= PER_GAME_SAVE_STATE_SLOTS; i++)
|
||||
add_path(GetGameSaveStateFileName(game_code, i), i, false);
|
||||
add_path(GetGameSaveStateFileName(serial, i), i, false);
|
||||
}
|
||||
|
||||
for (s32 i = 1; i <= GLOBAL_SAVE_STATE_SLOTS; i++)
|
||||
@@ -3821,10 +3821,10 @@ std::vector<SaveStateInfo> System::GetAvailableSaveStates(const char* game_code)
|
||||
return si;
|
||||
}
|
||||
|
||||
std::optional<SaveStateInfo> System::GetSaveStateInfo(const char* game_code, s32 slot)
|
||||
std::optional<SaveStateInfo> System::GetSaveStateInfo(const char* serial, s32 slot)
|
||||
{
|
||||
const bool global = (!game_code || game_code[0] == 0);
|
||||
std::string path = global ? GetGlobalSaveStateFileName(slot) : GetGameSaveStateFileName(game_code, slot);
|
||||
const bool global = (!serial || serial[0] == 0);
|
||||
std::string path = global ? GetGlobalSaveStateFileName(slot) : GetGameSaveStateFileName(serial, slot);
|
||||
|
||||
FILESYSTEM_STAT_DATA sd;
|
||||
if (!FileSystem::StatFile(path.c_str(), &sd))
|
||||
@@ -3868,8 +3868,8 @@ std::optional<ExtendedSaveStateInfo> System::InternalGetExtendedSaveStateInfo(By
|
||||
|
||||
header.title[sizeof(header.title) - 1] = 0;
|
||||
ssi.title = header.title;
|
||||
header.game_code[sizeof(header.game_code) - 1] = 0;
|
||||
ssi.game_code = header.game_code;
|
||||
header.serial[sizeof(header.serial) - 1] = 0;
|
||||
ssi.serial = header.serial;
|
||||
|
||||
if (header.media_filename_length > 0 &&
|
||||
(header.offset_to_media_filename + header.media_filename_length) <= stream->GetSize())
|
||||
@@ -3899,9 +3899,9 @@ std::optional<ExtendedSaveStateInfo> System::InternalGetExtendedSaveStateInfo(By
|
||||
return ssi;
|
||||
}
|
||||
|
||||
void System::DeleteSaveStates(const char* game_code, bool resume)
|
||||
void System::DeleteSaveStates(const char* serial, bool resume)
|
||||
{
|
||||
const std::vector<SaveStateInfo> states(GetAvailableSaveStates(game_code));
|
||||
const std::vector<SaveStateInfo> states(GetAvailableSaveStates(serial));
|
||||
for (const SaveStateInfo& si : states)
|
||||
{
|
||||
if (si.global || (!resume && si.slot < 0))
|
||||
@@ -3982,11 +3982,11 @@ bool System::LoadCheatListFromGameTitle()
|
||||
|
||||
bool System::LoadCheatListFromDatabase()
|
||||
{
|
||||
if (IsShutdown() || s_running_game_code.empty() || Achievements::ChallengeModeActive())
|
||||
if (IsShutdown() || s_running_game_serial.empty() || Achievements::ChallengeModeActive())
|
||||
return false;
|
||||
|
||||
std::unique_ptr<CheatList> cl = std::make_unique<CheatList>();
|
||||
if (!cl->LoadFromPackage(s_running_game_code))
|
||||
if (!cl->LoadFromPackage(s_running_game_serial))
|
||||
return false;
|
||||
|
||||
Log_InfoPrintf("Loaded %u cheats from database.", cl->GetCodeCount());
|
||||
|
||||
@@ -45,7 +45,7 @@ struct SaveStateInfo
|
||||
struct ExtendedSaveStateInfo
|
||||
{
|
||||
std::string title;
|
||||
std::string game_code;
|
||||
std::string serial;
|
||||
std::string media_path;
|
||||
std::time_t timestamp;
|
||||
|
||||
@@ -98,10 +98,10 @@ ConsoleRegion GetConsoleRegionForDiscRegion(DiscRegion region);
|
||||
std::string GetExecutableNameForImage(CDImage* cdi);
|
||||
bool ReadExecutableFromImage(CDImage* cdi, std::string* out_executable_name, std::vector<u8>* out_executable_data);
|
||||
|
||||
std::string GetGameHashCodeForImage(CDImage* cdi);
|
||||
std::string GetGameCodeForImage(CDImage* cdi, bool fallback_to_hash);
|
||||
std::string GetGameCodeForPath(const char* image_path, bool fallback_to_hash);
|
||||
DiscRegion GetRegionForCode(std::string_view code);
|
||||
std::string GetGameHashIdFromImage(CDImage* cdi);
|
||||
std::string GetGameIdFromImage(CDImage* cdi, bool fallback_to_hash);
|
||||
std::string GetGameSerialForPath(const char* image_path, bool fallback_to_hash);
|
||||
DiscRegion GetRegionForSerial(std::string_view serial);
|
||||
DiscRegion GetRegionFromSystemArea(CDImage* cdi);
|
||||
DiscRegion GetRegionForImage(CDImage* cdi);
|
||||
DiscRegion GetRegionForExe(const char* path);
|
||||
@@ -168,7 +168,7 @@ void FrameDone();
|
||||
void IncrementInternalFrameNumber();
|
||||
|
||||
const std::string& GetRunningPath();
|
||||
const std::string& GetRunningCode();
|
||||
const std::string& GetRunningSerial();
|
||||
const std::string& GetRunningTitle();
|
||||
bool IsRunningBIOS();
|
||||
|
||||
@@ -317,7 +317,7 @@ void DoFrameStep();
|
||||
void DoToggleCheats();
|
||||
|
||||
/// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state.
|
||||
std::string GetGameSaveStateFileName(const std::string_view& game_code, s32 slot);
|
||||
std::string GetGameSaveStateFileName(const std::string_view& serial, s32 slot);
|
||||
|
||||
/// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state.
|
||||
std::string GetGlobalSaveStateFileName(s32 slot);
|
||||
@@ -341,16 +341,16 @@ std::optional<ExtendedSaveStateInfo> GetUndoSaveStateInfo();
|
||||
bool UndoLoadState();
|
||||
|
||||
/// Returns a list of save states for the specified game code.
|
||||
std::vector<SaveStateInfo> GetAvailableSaveStates(const char* game_code);
|
||||
std::vector<SaveStateInfo> GetAvailableSaveStates(const char* serial);
|
||||
|
||||
/// Returns save state info if present. If game_code is null or empty, assumes global state.
|
||||
std::optional<SaveStateInfo> GetSaveStateInfo(const char* game_code, s32 slot);
|
||||
/// Returns save state info if present. If serial is null or empty, assumes global state.
|
||||
std::optional<SaveStateInfo> GetSaveStateInfo(const char* serial, s32 slot);
|
||||
|
||||
/// Returns save state info from opened save state stream.
|
||||
std::optional<ExtendedSaveStateInfo> GetExtendedSaveStateInfo(const char* path);
|
||||
|
||||
/// Deletes save states for the specified game code. If resume is set, the resume state is deleted too.
|
||||
void DeleteSaveStates(const char* game_code, bool resume);
|
||||
void DeleteSaveStates(const char* serial, bool resume);
|
||||
|
||||
/// Returns intended output volume considering fast forwarding.
|
||||
s32 GetAudioOutputVolume();
|
||||
|
||||
Reference in New Issue
Block a user