aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/AuthHandler.cpp
diff options
context:
space:
mode:
authorDDuarte <dnpd.dd@gmail.com>2014-10-30 02:04:54 +0000
committerDDuarte <dnpd.dd@gmail.com>2014-10-30 02:04:54 +0000
commit7b2274a7447973f698426bcdb51c8faad6ba1296 (patch)
tree51bc69b2e59ea157caca19e09c508f5a8fe113a9 /src/server/game/Handlers/AuthHandler.cpp
parent386b97c4851ca614bfac3916502e2e2a26dd9fd6 (diff)
Core/Networking: PoC changes to the way packets are handled
This is a rewrite of the way we send SMSG opcodes, the reasoning behind this is to make fixing packets sent in multiple places easier, and allow for clearer documentation of the packet fields. Included SMSG_AUTH_RESPONSE and SMSG_AUCTION_COMMAND_RESULT as two examples.
Diffstat (limited to 'src/server/game/Handlers/AuthHandler.cpp')
-rw-r--r--src/server/game/Handlers/AuthHandler.cpp92
1 files changed, 35 insertions, 57 deletions
diff --git a/src/server/game/Handlers/AuthHandler.cpp b/src/server/game/Handlers/AuthHandler.cpp
index 6ffe0b7f024..9b14a8eef81 100644
--- a/src/server/game/Handlers/AuthHandler.cpp
+++ b/src/server/game/Handlers/AuthHandler.cpp
@@ -19,76 +19,54 @@
#include "Opcodes.h"
#include "WorldSession.h"
#include "WorldPacket.h"
+#include "AuthenticationPackets.h"
void WorldSession::SendAuthResponse(uint8 code, bool queued, uint32 queuePos)
{
- ExpansionRequirementContainer const& raceExpansions = sObjectMgr->GetRaceExpansionRequirements();
- ExpansionRequirementContainer const& classExpansions = sObjectMgr->GetClassExpansionRequirements();
-
- std::list<uint32> realmsToSend;
- // Send current home realm. Also there is no need to send it later in realm queries.
- realmsToSend.push_back(realmHandle.Index);
-
- WorldPacket packet(SMSG_AUTH_RESPONSE, 1 /*bits*/ + 4 + 1 + 4 + 1 + 4 + 1 + 1 + (queued ? 4 : 0));
- packet << uint8(code);
- packet.WriteBit(code == AUTH_OK);
- packet.WriteBit(queued);
-
+ WorldPackets::Auth::AuthResponse response;
+ response.SuccessInfo.HasValue = code == AUTH_OK;
+ response.Result = code;
+ response.WaitInfo.HasValue = queued;
+ response.WaitInfo.value.WaitCount = queuePos;
if (code == AUTH_OK)
{
- packet << uint32(realmHandle.Index);
- packet << uint32(realmsToSend.size()); // RealmNamesCount
- packet << uint32(0); // BillingTimeRemaining
- packet << uint32(0); // BillingPlanFlags
- packet << uint32(0); // BillingTimeRested
- packet << uint8(Expansion()); // ActiveExpansion
- packet << uint8(Expansion()); // AccountExpansion
- packet << uint32(0); // TimeSecondsUntilPCKick
- packet << uint32(raceExpansions.size()); // Races
- packet << uint32(classExpansions.size()); // Classes
- packet << uint32(0); // Templates
- packet << uint32(0); // AccountCurrency (probably for ingame shop)
+ response.SuccessInfo.value.AccountExpansionLevel = Expansion();
+ response.SuccessInfo.value.ActiveExpansionLevel = Expansion();
+ response.SuccessInfo.value.VirtualRealmAddress = realmHandle.Index;
- for (auto realm : realmsToSend)
- {
- std::string realmName = sObjectMgr->GetRealmName(realm);
+ std::string realmName = sObjectMgr->GetRealmName(realmHandle.Index);
- packet << uint32(realm); // realmID
- packet.WriteBit(realm == realmHandle.Index);// IsHomeRealm
- packet.WriteBit(0); // IsInternalRealm = guessed
- packet.WriteBits(realmName.length(), 8);
- packet.WriteBits(realmName.length(), 8);
- packet.WriteString(realmName); // RealmNameActual
- packet.WriteString(realmName); // RealmNameNormalized
- }
+ // Send current home realm. Also there is no need to send it later in realm queries.
+ response.SuccessInfo.value.VirtualRealms.emplace_back(realmHandle.Index, true, false, realmName, realmName);
+
+ response.SuccessInfo.value.AvailableClasses = &sObjectMgr->GetClassExpansionRequirements();
+ response.SuccessInfo.value.AvailableRaces = &sObjectMgr->GetRaceExpansionRequirements();
+ }
- for (auto raceExpansion : raceExpansions)
- {
- packet << uint8(raceExpansion.first); // Race
- packet << uint8(raceExpansion.second); // RequiredExpansion
- }
+ response.Write();
+ SendPacket(&response.GetWorldPacket());
+}
- for (auto classExpansion : classExpansions)
- {
- packet << uint8(classExpansion.first); // Class
- packet << uint8(classExpansion.second); // RequiredExpansion
- }
+void WorldSession::SendAuthWaitQue(uint32 position)
+{
+ WorldPackets::Auth::AuthResponse response;
- packet.WriteBit(0); // Trial
- packet.WriteBit(0); // ForceCharacterTemplate
- packet.WriteBit(0); // NumPlayersHorde (uint16)
- packet.WriteBit(0); // NumPlayersAlliance (uint16)
- packet.WriteBit(0); // IsVeteranTrial
+ if (position == 0)
+ {
+ response.Result = AUTH_OK;
+ response.SuccessInfo.HasValue = false;
+ response.WaitInfo.HasValue = false;
}
-
- if (queued)
+ else
{
- packet << uint32(queuePos); // Queue position
- packet.WriteBit(0); // HasFCM
+ response.WaitInfo.HasValue = true;
+ response.SuccessInfo.HasValue = false;
+ response.WaitInfo.value.WaitCount = position;
+ response.Result = AUTH_WAIT_QUEUE;
}
-
- packet.FlushBits();
- SendPacket(&packet);
+
+ response.Write();
+ SendPacket(&response.GetWorldPacket());
}
void WorldSession::SendClientCacheVersion(uint32 version)