Added a version control for custom archives

This commit is contained in:
B3n30 2017-09-15 14:45:50 +02:00
parent 38d79c56b9
commit 36f613db7a
9 changed files with 64 additions and 22 deletions

View File

@ -255,6 +255,7 @@ if (ENABLE_CUSTOM_SYSTEM_ARCHIVES)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/externals/system_archives.7z"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
set(CUSTOM_ARCHIVES_PREFIX "${CMAKE_BINARY_DIR}/externals/system_archives")
add_definitions(-DCUSTOM_ARCHIVES_VERSION="v1.0")
add_definitions(-DENABLE_CUSTOM_SYSTEM_ARCHIVES)
endif()

View File

@ -81,6 +81,8 @@ void Config::ReadValues() {
// Core
Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true);
Settings::values.shared_font_jeu_version =
sdl2_config->Get("Core", "shared_font_jeu_version", "dumped");
// Renderer
Settings::values.use_hw_renderer = sdl2_config->GetBoolean("Renderer", "use_hw_renderer", true);

View File

@ -66,6 +66,9 @@ motion_device=
# Whether to use the Just-In-Time (JIT) compiler for CPU emulation
# 0: Interpreter (slow), 1 (default): JIT (fast)
use_cpu_jit =
# The version of the JP/EUR/USA shared Font
# "dumped" (default)
shared_font_jeu_version = dumped
[Renderer]
# Whether to use software or hardware rendering.

View File

@ -66,6 +66,10 @@ void Config::ReadValues() {
qt_config->beginGroup("Core");
Settings::values.use_cpu_jit = qt_config->value("use_cpu_jit", true).toBool();
Settings::values.shared_font_jeu_version =
qt_config->value("shared_font_jeu_version", QString::fromStdString("dumped"))
.toString()
.toStdString();
qt_config->endGroup();
qt_config->beginGroup("Renderer");
@ -217,6 +221,8 @@ void Config::SaveValues() {
qt_config->beginGroup("Core");
qt_config->setValue("use_cpu_jit", Settings::values.use_cpu_jit);
qt_config->setValue("shared_font_jeu_version",
QString::fromStdString(Settings::values.shared_font_jeu_version));
qt_config->endGroup();
qt_config->beginGroup("Renderer");

View File

@ -422,20 +422,27 @@ bool GMainWindow::LoadROM(const QString& filename) {
return false;
}
Core::System::Integrity integrity = system.GetSystemIntegrity();
if (integrity && Core::System::Integrity::SharedFont) {
switch (integrity.shared_font_JEU) {
case Core::System::Integrity::CreatedCustom:
#ifdef ENABLE_CUSTOM_SYSTEM_ARCHIVES
QMessageBox::critical(
this, tr("Shared Font Created."),
tr("The Shared Font is missing. A custom Shared Font was created. This could result in "
"some ugly or wrong glyphs. It is recomended to dump the Shared Font from your 3ds. "
tr("A custom Shared Font was created. This could result in some ugly or wrong glyphs. "
"It is recomended to dump the Shared Font from your 3DS. "
"For more information on dumping these files, please see the "
"following wiki page: <a "
"href='https://citra-emu.org/wiki/"
"dumping-system-archives-and-the-shared-fonts-from-a-3ds-console/'>Dumping System "
"Archives and the Shared Fonts from a 3DS Console</a>."));
#endif
break;
case Core::System::Integrity::Missing:
// Don't show an error meassage if the Shared Font is missing. This Message will popup
// anyway if the game requires it
break;
default:
// Nothing to do here
break;
}
return true;
}

View File

@ -208,34 +208,46 @@ void System::Shutdown() {
}
void System::SystemIntegrityCheck() {
system_integrity = static_cast<Integrity>(0);
// Shared Font
// TODO(B3N30): check/create font archive for region CHN/KOR/TWN
// Shared Font JP/EUR/USA
std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
const u32 shared_font_archive_id_low = 0x00014002;
const u32_le shared_font_archive_id_high = 0x0004009b;
const u32 shared_font_archive_id_high = 0x0004009b;
std::string shared_font_path = Common::StringFromFormat(
"%s%s/title/%08x/%08x/content/00000000.app.romfs", nand_directory.c_str(), SYSTEM_ID,
shared_font_archive_id_high, shared_font_archive_id_low);
LOG_DEBUG(Core, "%s", shared_font_path.c_str());
auto file = std::make_shared<FileUtil::IOFile>(shared_font_path, "rb");
if (file->IsOpen()) {
file->Close();
if (FileUtil::Exists(shared_font_path)) {
std::string version = Settings::values.shared_font_jeu_version;
if (version == "dumped") {
system_integrity.shared_font_JEU = Integrity::Dumped;
LOG_INFO(Core, "SystemCheck: Shared Font exists.");
} else if (version == CUSTOM_ARCHIVES_VERSION) {
system_integrity.shared_font_JEU = Integrity::Custom;
LOG_WARNING(Core, "SystemCheck: Shared Font (custom) exists.");
#ifdef ENABLE_CUSTOM_SYSTEM_ARCHIVES
} else {
FileUtil::IOFile file(shared_font_path, "wb");
file.WriteBytes(SHARED_FONT_DATA, SHARED_FONT_DATA_len);
file.Close();
system_integrity.shared_font_JEU = Integrity::CreatedCustom;
Settings::values.shared_font_jeu_version = CUSTOM_ARCHIVES_VERSION;
LOG_WARNING(Core, "SystemCheck: Updated Shared Font.");
}
#endif
} else {
std::string shared_font_legacy_path = FileUtil::GetUserPath(D_SYSDATA_IDX) + SHARED_FONT;
file = std::make_shared<FileUtil::IOFile>(shared_font_legacy_path, "rb");
if (file->IsOpen()) {
file->Close();
if (FileUtil::Exists(shared_font_legacy_path)) {
LOG_INFO(Core, "SystemCheck: Shared Font(legacy) exists.");
system_integrity.shared_font_JEU = Integrity::DumpedLegacy;
} else {
LOG_ERROR(Core, "SystemCheck: Shared Font missing.");
system_integrity = static_cast<Integrity>(system_integrity | Integrity::SharedFont);
system_integrity.shared_font_JEU = Integrity::Missing;
#ifdef ENABLE_CUSTOM_SYSTEM_ARCHIVES
file = std::make_shared<FileUtil::IOFile>(shared_font_path, "w+b");
file->WriteBytes(SHARED_FONT_DATA, SHARED_FONT_DATA_len);
file->Close();
LOG_DEBUG(Core, "SystemCheck: Created Shared Font.");
FileUtil::IOFile file(shared_font_path, "wb");
file.WriteBytes(SHARED_FONT_DATA, SHARED_FONT_DATA_len);
file.Close();
system_integrity.shared_font_JEU = Integrity::CreatedCustom;
Settings::values.shared_font_jeu_version = CUSTOM_ARCHIVES_VERSION;
LOG_WARNING(Core, "SystemCheck: Created Shared Font.");
#endif
}
}

View File

@ -43,8 +43,16 @@ public:
ErrorUnknown ///< Any other error
};
enum Integrity : u32 {
SharedFont = 1 << 0,
struct Integrity {
enum Status: u32 {
Dumped,
Custom,
CreatedCustom,
Missing,
DumpedLegacy,
};
Status shared_font_JEU{};
};
/**

View File

@ -84,6 +84,7 @@ struct Values {
// Core
bool use_cpu_jit;
std::string shared_font_jeu_version;
// Data Storage
bool use_virtual_sd;

View File

@ -145,6 +145,8 @@ TelemetrySession::TelemetrySession() {
AddField(Telemetry::FieldType::UserConfig, "Audio_EnableAudioStretching",
Settings::values.enable_audio_stretching);
AddField(Telemetry::FieldType::UserConfig, "Core_UseCpuJit", Settings::values.use_cpu_jit);
AddField(Telemetry::FieldType::UserConfig, "Core_SharedFontJEUVersion",
Settings::values.shared_font_jeu_version);
AddField(Telemetry::FieldType::UserConfig, "Renderer_ResolutionFactor",
Settings::values.resolution_factor);
AddField(Telemetry::FieldType::UserConfig, "Renderer_ToggleFramelimit",