Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h
- index 41f3002e9..c8aaf8992 100644
- --- a/src/core/hle/service/time/time.h
- +++ b/src/core/hle/service/time/time.h
- @@ -36,6 +36,10 @@ public:
- void CalculateSpanBetween(Kernel::HLERequestContext& ctx);
- void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx);
- + TimeManager& GetTimeManager() {
- + return module->GetTimeManager();
- + }
- +
- private:
- ResultCode GetClockSnapshotFromSystemClockContextInternal(
- Kernel::Thread* thread, Clock::SystemClockContext user_context,
- diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp
- index b4dfe45e5..aea08e49c 100644
- --- a/src/core/hle/service/time/time_manager.cpp
- +++ b/src/core/hle/service/time/time_manager.cpp
- @@ -5,12 +5,10 @@
- #include <chrono>
- #include <ctime>
- -#include "common/time_zone.h"
- #include "core/hle/service/time/ephemeral_network_system_clock_context_writer.h"
- #include "core/hle/service/time/local_system_clock_context_writer.h"
- #include "core/hle/service/time/network_system_clock_context_writer.h"
- #include "core/hle/service/time/time_manager.h"
- -#include "core/settings.h"
- namespace Service::Time {
- @@ -22,16 +20,8 @@ static std::chrono::seconds GetSecondsSinceEpoch() {
- Settings::values.custom_rtc_differential;
- }
- -static s64 GetExternalTimeZoneOffset() {
- - // With "auto" timezone setting, we use the external system's timezone offset
- - if (Settings::GetTimeZoneString() == "auto") {
- - return Common::TimeZone::GetCurrentOffsetSeconds().count();
- - }
- - return 0;
- -}
- -
- static s64 GetExternalRtcValue() {
- - return GetSecondsSinceEpoch().count() + GetExternalTimeZoneOffset();
- + return GetSecondsSinceEpoch().count() + TimeManager::GetExternalTimeZoneOffset();
- }
- TimeManager::TimeManager(Core::System& system)
- diff --git a/src/core/hle/service/time/time_manager.h b/src/core/hle/service/time/time_manager.h
- index 8e65f0d22..f709e8930 100644
- --- a/src/core/hle/service/time/time_manager.h
- +++ b/src/core/hle/service/time/time_manager.h
- @@ -5,6 +5,7 @@
- #pragma once
- #include "common/common_types.h"
- +#include "common/time_zone.h"
- #include "core/file_sys/vfs_types.h"
- #include "core/hle/service/time/clock_types.h"
- #include "core/hle/service/time/ephemeral_network_system_clock_core.h"
- @@ -15,6 +16,7 @@
- #include "core/hle/service/time/tick_based_steady_clock_core.h"
- #include "core/hle/service/time/time_sharedmemory.h"
- #include "core/hle/service/time/time_zone_content_manager.h"
- +#include "core/settings.h"
- namespace Service::Time {
- @@ -85,6 +87,14 @@ public:
- std::size_t total_location_name_count, u128 time_zone_rule_version,
- FileSys::VirtualFile& vfs_file);
- + static s64 GetExternalTimeZoneOffset() {
- + // With "auto" timezone setting, we use the external system's timezone offset
- + if (Settings::GetTimeZoneString() == "auto") {
- + return Common::TimeZone::GetCurrentOffsetSeconds().count();
- + }
- + return 0;
- + }
- +
- private:
- void SetupStandardSteadyClock(Core::System& system, Common::UUID clock_source_id,
- Clock::TimeSpanType setup_value,
- diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp
- index 10315e7a6..cd6b99016 100644
- --- a/src/yuzu/configuration/configure_system.cpp
- +++ b/src/yuzu/configuration/configure_system.cpp
- @@ -12,10 +12,28 @@
- #include "common/assert.h"
- #include "common/file_util.h"
- #include "core/core.h"
- +#include "core/hle/service/sm/sm.h"
- +#include "core/hle/service/time/standard_local_system_clock_core.h"
- +#include "core/hle/service/time/time.h"
- #include "core/settings.h"
- #include "ui_configure_system.h"
- #include "yuzu/configuration/configure_system.h"
- +void OnCustomRtcChanged() {
- + const s64 new_posix = Settings::values.custom_rtc.value().count() + Service::Time::TimeManager::GetExternalTimeZoneOffset();
- + const auto new_system_time{Service::Time::Clock::TimeSpanType::FromSeconds(new_posix)};
- + Core::System& system{Core::System::GetInstance()};
- + const Service::SM::ServiceManager& sm = system.ServiceManager();
- + const auto& tm = sm.GetService<Service::Time::Module::Interface>("time:a")->GetTimeManager();
- + auto local_system_clock = tm.GetStandardLocalSystemClockCore();
- + auto shared_memory = tm.GetSharedMemory();
- +
- + if (local_system_clock.SetCurrentTime(system, new_system_time.ToSeconds()) != RESULT_SUCCESS) {
- + UNREACHABLE();
- + return;
- + }
- +}
- +
- ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureSystem) {
- ui->setupUi(this);
- connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
- @@ -79,6 +97,18 @@ void ConfigureSystem::SetConfiguration() {
- void ConfigureSystem::ReadSystemSettings() {}
- void ConfigureSystem::ApplyConfiguration() {
- + // Allow setting custom RTC even if system is powered on,
- + // to enable time travel in game.
- + if (ui->custom_rtc_checkbox->isChecked()) {
- + Settings::values.custom_rtc =
- + std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch());
- + if (Core::System::GetInstance().IsPoweredOn()) {
- + OnCustomRtcChanged();
- + }
- + } else {
- + Settings::values.custom_rtc = std::nullopt;
- + }
- +
- if (!enabled) {
- return;
- }
- @@ -94,13 +124,6 @@ void ConfigureSystem::ApplyConfiguration() {
- Settings::values.rng_seed = std::nullopt;
- }
- - if (ui->custom_rtc_checkbox->isChecked()) {
- - Settings::values.custom_rtc =
- - std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch());
- - } else {
- - Settings::values.custom_rtc = std::nullopt;
- - }
- -
- Settings::Apply();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement