TrinityCore
Loading...
Searching...
No Matches
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 "RealmList.h"
28#include "SystemPackets.h"
29#include "Timezone.h"
30#include "Util.h"
31#include "World.h"
32
33void WorldSession::SendAuthResponse(uint32 code, bool queued, uint32 queuePos)
34{
36 response.Result = code;
37
38 if (code == ERROR_OK)
39 {
40 response.SuccessInfo.emplace();
41
42 response.SuccessInfo->ActiveExpansionLevel = GetExpansion();
43 response.SuccessInfo->AccountExpansionLevel = GetAccountExpansion();
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 if (std::shared_ptr<Realm const> currentRealm = sRealmList->GetCurrentRealm())
48 {
49 response.SuccessInfo->VirtualRealmAddress = currentRealm->Id.GetAddress();
50 response.SuccessInfo->VirtualRealms.emplace_back(currentRealm->Id.GetAddress(), true, false, currentRealm->Name, currentRealm->NormalizedName);
51 }
52
54 for (auto&& templ : sCharacterTemplateDataStore->GetCharacterTemplates())
55 response.SuccessInfo->Templates.push_back(&templ.second);
56
57 response.SuccessInfo->AvailableClasses = &sObjectMgr->GetClassExpansionRequirements();
58
59 // TEMPORARY - prevent creating characters in uncompletable zone
60 // This has the side effect of disabling Exile's Reach choice clientside without actually forcing character templates
61 response.SuccessInfo->ForceCharacterTemplate = DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, 2175 /*Exile's Reach*/, nullptr);
62 }
63
64 if (queued)
65 {
66 response.WaitInfo.emplace();
67 response.WaitInfo->WaitCount = queuePos;
68 }
69
70 SendPacket(response.Write());
71}
72
74{
75 if (position)
76 {
78 waitQueueUpdate.WaitInfo.WaitCount = position;
79 waitQueueUpdate.WaitInfo.WaitTime = 0;
80 waitQueueUpdate.WaitInfo.HasFCM = false;
81 SendPacket(waitQueueUpdate.Write());
82 }
83 else
85}
86
94
96{
97 Minutes timezoneOffset = Trinity::Timezone::GetSystemZoneOffset(false);
98 std::string realTimezone = Trinity::Timezone::GetSystemZoneName();
99 std::string_view clientSupportedTZ = Trinity::Timezone::FindClosestClientSupportedTimezone(realTimezone, timezoneOffset);
100
102 packet.ServerTimeTZ = clientSupportedTZ;
103 packet.GameTimeTZ = clientSupportedTZ;
104 packet.ServerRegionalTimeTZ = clientSupportedTZ;
105 SendPacket(packet.Write());
106}
107
109{
111 features.BpayStoreAvailable = false;
116 features.MaximumExpansionLevel = sWorld->getIntConfig(CONFIG_EXPANSION);
117
118 features.EuropaTicketSystemStatus.emplace();
119 features.EuropaTicketSystemStatus->ThrottleState.MaxTries = 10;
120 features.EuropaTicketSystemStatus->ThrottleState.PerMilliseconds = 60000;
121 features.EuropaTicketSystemStatus->ThrottleState.TryCount = 1;
122 features.EuropaTicketSystemStatus->ThrottleState.LastResetTimeBeforeNow = 111111;
123 features.EuropaTicketSystemStatus->TicketsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_TICKETS_ENABLED);
124 features.EuropaTicketSystemStatus->BugsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_BUGS_ENABLED);
125 features.EuropaTicketSystemStatus->ComplaintsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_COMPLAINTS_ENABLED);
126 features.EuropaTicketSystemStatus->SuggestionsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_SUGGESTIONS_ENABLED);
127
128 for (World::GameRule const& gameRule : sWorld->GetGameRules())
129 {
130 WorldPackets::System::GameRuleValuePair& rule = features.GameRules.emplace_back();
131 rule.Rule = AsUnderlyingType(gameRule.Rule);
132 std::visit([&]<typename T>(T value)
133 {
134 if constexpr (std::is_same_v<T, float>)
135 rule.ValueF = value;
136 else
137 rule.Value = value;
138 }, gameRule.Value);
139 }
140
141 features.AvailableGameModeIDs.push_back(8); // GameMode.db2, standard
142
143 SendPacket(features.Write());
144
146 {
147 { "raidLockoutExtendEnabled"sv, "1"sv },
148 { "sellAllJunkEnabled"sv, "1"sv },
149 { "bypassItemLevelScalingCode"sv, "0"sv },
150 { "shop2Enabled"sv, "0"sv },
151 { "bpayStoreEnable"sv, "0"sv },
152 { "recentAlliesEnabledClient"sv, "0"sv },
153 { "browserEnabled"sv, "0"sv },
154 { "housingEnableCreateGuildNeighborhood"sv, "0"sv },
155 { "housingEnableDeleteHouse"sv, "0"sv },
156 { "housingServiceEnabled"sv, "0"sv },
157 { "housingEnableMoveHouse"sv, "0"sv },
158 { "housingEnableCreateCharterNeighborhood"sv, "0"sv },
159 { "housingEnableBuyHouse"sv, "0"sv },
160 { "housingMarketEnabled"sv, "0"sv },
161 };
162
164 variables.Variables = vars;
165 SendPacket(variables.Write());
166}
#define sCharacterTemplateDataStore
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ DISABLE_TYPE_MAP
Definition DisableMgr.h:29
std::chrono::minutes Minutes
Minutes shorthand typedef.
Definition Duration.h:32
#define sObjectMgr
Definition ObjectMgr.h:1885
Role Based Access Control related classes definition.
#define sRealmList
Definition RealmList.h:93
@ EXPANSION_CLASSIC
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition Util.h:565
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...
Optional< EuropaTicketConfig > EuropaTicketSystemStatus
WorldPacket const * Write() override
std::span< MirrorVarSingle > Variables
void SendClientCacheVersion(uint32 version)
void SendAuthResponse(uint32 code, bool queued, uint32 queuePos=0)
void SendAuthWaitQueue(uint32 position)
Handle the authentication waiting queue (to be completed)
void SendSetTimeZoneInformation()
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:916
@ CONFIG_EXPANSION
Definition World.h:306
@ CONFIG_CHARACTERS_PER_REALM
Definition World.h:257
@ CONFIG_SUPPORT_COMPLAINTS_ENABLED
Definition World.h:159
@ CONFIG_SUPPORT_BUGS_ENABLED
Definition World.h:158
@ CONFIG_SUPPORT_SUGGESTIONS_ENABLED
Definition World.h:160
@ CONFIG_SUPPORT_TICKETS_ENABLED
Definition World.h:157
@ CONFIG_FEATURE_SYSTEM_CHARACTER_UNDELETE_ENABLED
Definition World.h:177
bool IsDisabledFor(DisableType type, uint32 entry, WorldObject const *ref, uint8 flags)
time_t GetGameTime()
Definition GameTime.cpp:52
std::string_view FindClosestClientSupportedTimezone(std::string_view currentTimezone, Minutes currentTimezoneOffset)
Definition Timezone.cpp:169
Minutes GetSystemZoneOffset(bool applyDst)
Definition Timezone.cpp:150
std::string GetSystemZoneName()
Definition Timezone.cpp:159
@ RBAC_PERM_USE_CHARACTER_TEMPLATES
Definition RBAC.h:63
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...