mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-29 04:24:17 +01:00
Fix UTC offset calculation (#890)
This commit is contained in:
parent
b0ae008a89
commit
ea86c77088
@ -125,6 +125,21 @@ namespace act
|
||||
return getNNReturnCode(resultCode, actRequest);
|
||||
}
|
||||
|
||||
sint64 GetUtcOffset()
|
||||
{
|
||||
return ((ppcCyclesSince2000 / ESPRESSO_CORE_CLOCK) - (ppcCyclesSince2000_UTC / ESPRESSO_CORE_CLOCK)) * 1'000'000;
|
||||
}
|
||||
|
||||
sint32 GetUtcOffsetEx(sint64be* pOutOffset, uint8 slotNo)
|
||||
{
|
||||
|
||||
if (!pOutOffset)
|
||||
return 0xc0712c80;
|
||||
|
||||
*pOutOffset = GetUtcOffset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
sint32 g_initializeCount = 0; // inc in Initialize and dec in Finalize
|
||||
uint32 Initialize()
|
||||
{
|
||||
@ -649,30 +664,6 @@ void nnActExport_AcquirePrincipalIdByAccountId(PPCInterpreter_t* hCPU)
|
||||
osLib_returnFromFunction(hCPU, result);
|
||||
}
|
||||
|
||||
void nnActExport_GetUtcOffsetEx(PPCInterpreter_t* hCPU)
|
||||
{
|
||||
// GetUtcOffsetEx__Q2_2nn3actFPLUc
|
||||
ppcDefineParamU32BEPtr(utcOffsetOut, 0);
|
||||
ppcDefineParamU32(uknParam, 1);
|
||||
|
||||
cemuLog_logDebug(LogType::Force, "Called nn_act.GetUtcOffsetEx");
|
||||
|
||||
*utcOffsetOut = 0;
|
||||
|
||||
cemuLog_logDebug(LogType::Force, "GetUtcOffsetEx stub");
|
||||
|
||||
osLib_returnFromFunction(hCPU, 0);
|
||||
}
|
||||
|
||||
void nnActExport_GetUtcOffset(PPCInterpreter_t* hCPU)
|
||||
{
|
||||
uint64 utcOffset = 0;
|
||||
|
||||
uint64 utcDifferenceInSeconds = (ppcCyclesSince2000_UTC / ESPRESSO_CORE_CLOCK) - (ppcCyclesSince2000 / ESPRESSO_CORE_CLOCK);
|
||||
|
||||
osLib_returnFromFunction64(hCPU, utcDifferenceInSeconds * 1000000ULL);
|
||||
}
|
||||
|
||||
// register account functions
|
||||
void nnAct_load()
|
||||
{
|
||||
@ -737,8 +728,8 @@ void nnAct_load()
|
||||
// placeholders / incomplete implementations
|
||||
osLib_addFunction("nn_act", "HasNfsAccount__Q2_2nn3actFv", nnActExport_HasNfsAccount);
|
||||
osLib_addFunction("nn_act", "GetHostServerSettings__Q2_2nn3actFPcT1Uc", nnActExport_GetHostServerSettings);
|
||||
osLib_addFunction("nn_act", "GetUtcOffset__Q2_2nn3actFv", nnActExport_GetUtcOffset);
|
||||
osLib_addFunction("nn_act", "GetUtcOffsetEx__Q2_2nn3actFPLUc", nnActExport_GetUtcOffsetEx);
|
||||
cafeExportRegisterFunc(nn::act::GetUtcOffset, "nn_act", "GetUtcOffset__Q2_2nn3actFv", LogType::Placeholder);
|
||||
cafeExportRegisterFunc(nn::act::GetUtcOffsetEx, "nn_act", "GetUtcOffsetEx__Q2_2nn3actFPLUc", LogType::Placeholder);
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,9 @@ namespace act
|
||||
uint32 GetSimpleAddressIdEx(uint32be* simpleAddressId, uint8 slot);
|
||||
uint32 GetTransferableIdEx(uint64* transferableId, uint32 unique, uint8 slot);
|
||||
|
||||
sint64 GetUtcOffset();
|
||||
sint32 GetUtcOffsetEx(sint64be* pOutOffset, uint8 slotNo);
|
||||
|
||||
uint32 AcquireIndependentServiceToken(independentServiceToken_t* token, const char* clientId, uint32 cacheDurationInSeconds);
|
||||
|
||||
static uint32 getCountryCodeFromSimpleAddress(uint32 simpleAddressId)
|
||||
|
@ -16,24 +16,6 @@ namespace nn
|
||||
ParamPackStorage g_ParamPack;
|
||||
DiscoveryResultStorage g_DiscoveryResults;
|
||||
|
||||
uint64 get_utc_offset()
|
||||
{
|
||||
time_t gmt, rawtime = time(NULL);
|
||||
struct tm* ptm;
|
||||
|
||||
#if !defined(WIN32)
|
||||
struct tm gbuf;
|
||||
ptm = gmtime_r(&rawtime, &gbuf);
|
||||
#else
|
||||
ptm = gmtime(&rawtime);
|
||||
#endif
|
||||
|
||||
ptm->tm_isdst = -1;
|
||||
gmt = mktime(ptm);
|
||||
|
||||
return (uint64)difftime(rawtime, gmt);
|
||||
}
|
||||
|
||||
sint32 GetOlvAccessKey(uint32_t* pOutKey)
|
||||
{
|
||||
*pOutKey = 0;
|
||||
@ -77,7 +59,7 @@ namespace nn
|
||||
g_ParamPack.transferableId = transferrableId;
|
||||
|
||||
strcpy(g_ParamPack.tzName, "CEMU/Olive"); // Should be nn::act::GetTimeZoneId
|
||||
g_ParamPack.utcOffset = get_utc_offset();
|
||||
g_ParamPack.utcOffset = (uint64_t)nn::act::GetUtcOffset() / 1'000'000;
|
||||
|
||||
char paramPackStr[1024];
|
||||
snprintf(
|
||||
|
Loading…
Reference in New Issue
Block a user