TrinityCore
AuthHandler.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "WorldSession.h"
22#include "ClientConfigPackets.h"
23#include "DisableMgr.h"
24#include "GameTime.h"
25#include "ObjectMgr.h"
26#include "RBAC.h"
27#include "Realm.h"
28#include "SystemPackets.h"
29#include "Timezone.h"
30#include "World.h"
31
32void WorldSession::SendAuthResponse(uint32 code, bool queued, uint32 queuePos)
33{
35 response.Result = code;
36
37 if (code == ERROR_OK)
38 {
39 response.SuccessInfo.emplace();
40
41 response.SuccessInfo->ActiveExpansionLevel = GetExpansion();
42 response.SuccessInfo->AccountExpansionLevel = GetAccountExpansion();
43 response.SuccessInfo->VirtualRealmAddress = realm.Id.GetAddress();
44 response.SuccessInfo->Time = int32(GameTime::GetGameTime());
45
46 // Send current home realm. Also there is no need to send it later in realm queries.
47 response.SuccessInfo->VirtualRealms.emplace_back(realm.Id.GetAddress(), true, false, realm.Name, realm.NormalizedName);
48
50 for (auto&& templ : sCharacterTemplateDataStore->GetCharacterTemplates())
51 response.SuccessInfo->Templates.push_back(&templ.second);
52
53 response.SuccessInfo->AvailableClasses = &sObjectMgr->GetClassExpansionRequirements();
54
55 // TEMPORARY - prevent creating characters in uncompletable zone
56 // This has the side effect of disabling Exile's Reach choice clientside without actually forcing character templates
57 response.SuccessInfo->ForceCharacterTemplate = DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, 2175 /*Exile's Reach*/, nullptr);
58 }
59
60 if (queued)
61 {
62 response.WaitInfo.emplace();
63 response.WaitInfo->WaitCount = queuePos;
64 }
65
66 SendPacket(response.Write());
67}
68
70{
71 if (position)
72 {
74 waitQueueUpdate.WaitInfo.WaitCount = position;
75 waitQueueUpdate.WaitInfo.WaitTime = 0;
76 waitQueueUpdate.WaitInfo.HasFCM = false;
77 SendPacket(waitQueueUpdate.Write());
78 }
79 else
81}
82
84{
86 cache.CacheVersion = version;
87
88 SendPacket(cache.Write());
89}
90
92{
93 Minutes timezoneOffset = Trinity::Timezone::GetSystemZoneOffset(false);
94 std::string realTimezone = Trinity::Timezone::GetSystemZoneName();
95 std::string_view clientSupportedTZ = Trinity::Timezone::FindClosestClientSupportedTimezone(realTimezone, timezoneOffset);
96
98 packet.ServerTimeTZ = clientSupportedTZ;
99 packet.GameTimeTZ = clientSupportedTZ;
100 packet.ServerRegionalTZ = clientSupportedTZ;
101 SendPacket(packet.Write());
102}
103
105{
107 features.BpayStoreAvailable = false;
113 features.MaximumExpansionLevel = sWorld->getIntConfig(CONFIG_EXPANSION);
114
115 features.EuropaTicketSystemStatus.emplace();
116 features.EuropaTicketSystemStatus->ThrottleState.MaxTries = 10;
117 features.EuropaTicketSystemStatus->ThrottleState.PerMilliseconds = 60000;
118 features.EuropaTicketSystemStatus->ThrottleState.TryCount = 1;
119 features.EuropaTicketSystemStatus->ThrottleState.LastResetTimeBeforeNow = 111111;
120 features.EuropaTicketSystemStatus->TicketsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_TICKETS_ENABLED);
121 features.EuropaTicketSystemStatus->BugsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_BUGS_ENABLED);
122 features.EuropaTicketSystemStatus->ComplaintsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_COMPLAINTS_ENABLED);
123 features.EuropaTicketSystemStatus->SuggestionsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_SUGGESTIONS_ENABLED);
124
125 SendPacket(features.Write());
126}
#define sCharacterTemplateDataStore
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ DISABLE_TYPE_MAP
Definition: DisableMgr.h:29
std::chrono::minutes Minutes
Minutes shorthand typedef.
Definition: Duration.h:35
#define sObjectMgr
Definition: ObjectMgr.h:1946
Role Based Access Control related classes definition.
@ EXPANSION_CLASSIC
Definition: SharedDefines.h:90
uint32 Result
the result of the authentication process, possible values are BattlenetRpcErrorCode
WorldPacket const * Write() override
Optional< AuthWaitInfo > WaitInfo
contains the queue wait information in case the account is in the login queue.
Optional< AuthSuccessInfo > SuccessInfo
contains the packet data in case that it has account information (It is never set when WaitInfo is se...
WorldPacket const * Write() override
Optional< EuropaTicketConfig > EuropaTicketSystemStatus
WorldPacket const * Write() override
void SendClientCacheVersion(uint32 version)
Definition: AuthHandler.cpp:83
void SendAuthResponse(uint32 code, bool queued, uint32 queuePos=0)
Definition: AuthHandler.cpp:32
void SendAuthWaitQueue(uint32 position)
Handle the authentication waiting queue (to be completed)
Definition: AuthHandler.cpp:69
void SendSetTimeZoneInformation()
Definition: AuthHandler.cpp:91
bool HasPermission(uint32 permissionId)
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
uint8 GetAccountExpansion() const
uint8 GetExpansion() const
void SendFeatureSystemStatusGlueScreen()
#define sWorld
Definition: World.h:931
Realm realm
Definition: World.cpp:3966
@ CONFIG_EXPANSION
Definition: World.h:308
@ CONFIG_CHARACTERS_PER_REALM
Definition: World.h:254
@ CONFIG_SUPPORT_COMPLAINTS_ENABLED
Definition: World.h:158
@ CONFIG_SUPPORT_BUGS_ENABLED
Definition: World.h:157
@ CONFIG_FEATURE_SYSTEM_BPAY_STORE_ENABLED
Definition: World.h:177
@ CONFIG_SUPPORT_SUGGESTIONS_ENABLED
Definition: World.h:159
@ CONFIG_SUPPORT_TICKETS_ENABLED
Definition: World.h:156
@ CONFIG_FEATURE_SYSTEM_CHARACTER_UNDELETE_ENABLED
Definition: World.h:178
bool IsDisabledFor(DisableType type, uint32 entry, WorldObject const *ref, uint8 flags)
Definition: DisableMgr.cpp:285
time_t GetGameTime()
Definition: GameTime.cpp:44
std::string_view FindClosestClientSupportedTimezone(std::string_view currentTimezone, Minutes currentTimezoneOffset)
Definition: Timezone.cpp:163
Minutes GetSystemZoneOffset(bool applyDst)
Definition: Timezone.cpp:144
std::string GetSystemZoneName()
Definition: Timezone.cpp:153
@ RBAC_PERM_USE_CHARACTER_TEMPLATES
Definition: RBAC.h:63
uint32 GetAddress() const
Definition: Realm.h:56
std::string NormalizedName
Definition: Realm.h:87
std::string Name
Definition: Realm.h:86
Battlenet::RealmHandle Id
Definition: Realm.h:82
bool HasFCM
true if the account has a forced character migration pending.
uint32 WaitCount
position of the account in the login queue
uint32 WaitTime
Wait time in login queue in minutes, if sent queued and this value is 0 client displays "unknown time...