summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2020-01-22 23:19:25 -0500
committerGravatar bunnei2020-01-22 23:20:19 -0500
commited76c7131903f180ebc2f49c148a8a0339bf05fa (patch)
tree819714caa787b018fac29cca2b925dc0828bc552 /src
parentMerge pull request #3324 from FearlessTobi/port-5037 (diff)
downloadyuzu-ed76c7131903f180ebc2f49c148a8a0339bf05fa.tar.gz
yuzu-ed76c7131903f180ebc2f49c148a8a0339bf05fa.tar.xz
yuzu-ed76c7131903f180ebc2f49c148a8a0339bf05fa.zip
service: time: Implement ToPosixTimeWithMyRule.
- Used by Pokemon Mystery Dungeon.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/time/time_zone_manager.cpp9
-rw-r--r--src/core/hle/service/time/time_zone_manager.h1
-rw-r--r--src/core/hle/service/time/time_zone_service.cpp24
-rw-r--r--src/core/hle/service/time/time_zone_service.h1
4 files changed, 34 insertions, 1 deletions
diff --git a/src/core/hle/service/time/time_zone_manager.cpp b/src/core/hle/service/time/time_zone_manager.cpp
index 717e81818..07b553a43 100644
--- a/src/core/hle/service/time/time_zone_manager.cpp
+++ b/src/core/hle/service/time/time_zone_manager.cpp
@@ -1019,6 +1019,15 @@ ResultCode TimeZoneManager::ToPosixTime(const TimeZoneRule& rules,
1019 return RESULT_SUCCESS; 1019 return RESULT_SUCCESS;
1020} 1020}
1021 1021
1022ResultCode TimeZoneManager::ToPosixTimeWithMyRule(const CalendarTime& calendar_time,
1023 s64& posix_time) const {
1024 if (is_initialized) {
1025 return ToPosixTime(time_zone_rule, calendar_time, posix_time);
1026 }
1027 posix_time = 0;
1028 return ERROR_UNINITIALIZED_CLOCK;
1029}
1030
1022ResultCode TimeZoneManager::GetDeviceLocationName(LocationName& value) const { 1031ResultCode TimeZoneManager::GetDeviceLocationName(LocationName& value) const {
1023 if (!is_initialized) { 1032 if (!is_initialized) {
1024 return ERROR_UNINITIALIZED_CLOCK; 1033 return ERROR_UNINITIALIZED_CLOCK;
diff --git a/src/core/hle/service/time/time_zone_manager.h b/src/core/hle/service/time/time_zone_manager.h
index 7c6f975ae..aaab0a1e0 100644
--- a/src/core/hle/service/time/time_zone_manager.h
+++ b/src/core/hle/service/time/time_zone_manager.h
@@ -39,6 +39,7 @@ public:
39 ResultCode ParseTimeZoneRuleBinary(TimeZoneRule& rules, FileSys::VirtualFile& vfs_file) const; 39 ResultCode ParseTimeZoneRuleBinary(TimeZoneRule& rules, FileSys::VirtualFile& vfs_file) const;
40 ResultCode ToPosixTime(const TimeZoneRule& rules, const CalendarTime& calendar_time, 40 ResultCode ToPosixTime(const TimeZoneRule& rules, const CalendarTime& calendar_time,
41 s64& posix_time) const; 41 s64& posix_time) const;
42 ResultCode ToPosixTimeWithMyRule(const CalendarTime& calendar_time, s64& posix_time) const;
42 43
43private: 44private:
44 bool is_initialized{}; 45 bool is_initialized{};
diff --git a/src/core/hle/service/time/time_zone_service.cpp b/src/core/hle/service/time/time_zone_service.cpp
index 1566e778e..db57ae069 100644
--- a/src/core/hle/service/time/time_zone_service.cpp
+++ b/src/core/hle/service/time/time_zone_service.cpp
@@ -22,7 +22,7 @@ ITimeZoneService ::ITimeZoneService(TimeZone::TimeZoneContentManager& time_zone_
22 {100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"}, 22 {100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"},
23 {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, 23 {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"},
24 {201, &ITimeZoneService::ToPosixTime, "ToPosixTime"}, 24 {201, &ITimeZoneService::ToPosixTime, "ToPosixTime"},
25 {202, nullptr, "ToPosixTimeWithMyRule"}, 25 {202, &ITimeZoneService::ToPosixTimeWithMyRule, "ToPosixTimeWithMyRule"},
26 }; 26 };
27 RegisterHandlers(functions); 27 RegisterHandlers(functions);
28} 28}
@@ -145,4 +145,26 @@ void ITimeZoneService::ToPosixTime(Kernel::HLERequestContext& ctx) {
145 ctx.WriteBuffer(&posix_time, sizeof(s64)); 145 ctx.WriteBuffer(&posix_time, sizeof(s64));
146} 146}
147 147
148void ITimeZoneService::ToPosixTimeWithMyRule(Kernel::HLERequestContext& ctx) {
149 LOG_DEBUG(Service_Time, "called");
150
151 IPC::RequestParser rp{ctx};
152 const auto calendar_time{rp.PopRaw<TimeZone::CalendarTime>()};
153
154 s64 posix_time{};
155 if (const ResultCode result{
156 time_zone_content_manager.GetTimeZoneManager().ToPosixTimeWithMyRule(calendar_time,
157 posix_time)};
158 result != RESULT_SUCCESS) {
159 IPC::ResponseBuilder rb{ctx, 2};
160 rb.Push(result);
161 return;
162 }
163
164 IPC::ResponseBuilder rb{ctx, 3};
165 rb.Push(RESULT_SUCCESS);
166 rb.PushRaw<u32>(1); // Number of times we're returning
167 ctx.WriteBuffer(&posix_time, sizeof(s64));
168}
169
148} // namespace Service::Time 170} // namespace Service::Time
diff --git a/src/core/hle/service/time/time_zone_service.h b/src/core/hle/service/time/time_zone_service.h
index a92b4312b..cb495748b 100644
--- a/src/core/hle/service/time/time_zone_service.h
+++ b/src/core/hle/service/time/time_zone_service.h
@@ -22,6 +22,7 @@ private:
22 void ToCalendarTime(Kernel::HLERequestContext& ctx); 22 void ToCalendarTime(Kernel::HLERequestContext& ctx);
23 void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx); 23 void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx);
24 void ToPosixTime(Kernel::HLERequestContext& ctx); 24 void ToPosixTime(Kernel::HLERequestContext& ctx);
25 void ToPosixTimeWithMyRule(Kernel::HLERequestContext& ctx);
25 26
26private: 27private:
27 TimeZone::TimeZoneContentManager& time_zone_content_manager; 28 TimeZone::TimeZoneContentManager& time_zone_content_manager;