From b888b1b09f71a8b8b4a9d45c804a1f164fb65ac3 Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 21 Nov 2023 12:25:22 +0100 Subject: Core/Calendar: Implement different timezone support for ingame calendar Closes #8390 Closes #29427 --- src/server/bnetserver/Server/Session.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/server/bnetserver/Server/Session.cpp') diff --git a/src/server/bnetserver/Server/Session.cpp b/src/server/bnetserver/Server/Session.cpp index 6e5b16cd477..95c46418a7d 100644 --- a/src/server/bnetserver/Server/Session.cpp +++ b/src/server/bnetserver/Server/Session.cpp @@ -21,13 +21,17 @@ #include "CryptoRandom.h" #include "DatabaseEnv.h" #include "Errors.h" +#include "Hash.h" #include "IPLocation.h" -#include "QueryCallback.h" #include "LoginRESTService.h" +#include "MapUtils.h" #include "ProtobufJSON.h" +#include "QueryCallback.h" #include "RealmList.h" -#include "ServiceDispatcher.h" #include "RealmList.pb.h" +#include "ServiceDispatcher.h" +#include "Timezone.h" +#include #include void Battlenet::Session::AccountInfo::LoadResult(PreparedQueryResult result) @@ -229,6 +233,26 @@ uint32 Battlenet::Session::HandleLogon(authentication::v1::LogonRequest const* l _os = logonRequest->platform(); _build = logonRequest->application_version(); + _timezoneOffset = [&] + { + if (!logonRequest->has_device_id()) + return 0min; + + rapidjson::Document doc; + doc.Parse(logonRequest->device_id()); + if (doc.HasParseError()) + return 0min; + + auto itr = doc.FindMember("UTCO"); + if (itr == doc.MemberEnd()) + return 0min; + + if (!itr->value.IsUint()) + return 0min; + + return Trinity::Timezone::GetOffsetByHash(itr->value.GetUint()); + }(); + if (logonRequest->has_cached_web_credentials()) return VerifyWebCredentials(logonRequest->cached_web_credentials(), continuation); @@ -670,7 +694,8 @@ uint32 Battlenet::Session::GetRealmList(std::unordered_map const& params, game_utilities::v1::ClientResponse* response) { if (Variant const* realmAddress = GetParam(params, "Param_RealmAddress")) - return sRealmList->JoinRealm(realmAddress->uint_value(), _build, GetRemoteIpAddress(), _clientSecret, GetLocaleByName(_locale), _os, _gameAccountInfo->Name, response); + return sRealmList->JoinRealm(realmAddress->uint_value(), _build, GetRemoteIpAddress(), _clientSecret, GetLocaleByName(_locale), + _os, _timezoneOffset, _gameAccountInfo->Name, response); return ERROR_WOW_SERVICES_INVALID_JOIN_TICKET; } -- cgit v1.2.3