aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDuarte Duarte <dnpd.dd@gmail.com>2014-10-30 02:05:40 +0000
committerDuarte Duarte <dnpd.dd@gmail.com>2014-10-30 02:05:40 +0000
commit6f65d48a2149d4b5145f664bbf1aae20c1ea0b27 (patch)
tree51bc69b2e59ea157caca19e09c508f5a8fe113a9 /src
parent386b97c4851ca614bfac3916502e2e2a26dd9fd6 (diff)
parent7b2274a7447973f698426bcdb51c8faad6ba1296 (diff)
Merge pull request #13434 from TrinityCore/packitify
Networking code overhaul proof of concept
Diffstat (limited to 'src')
-rw-r--r--src/server/game/CMakeLists.txt1
-rw-r--r--src/server/game/Handlers/AuctionHouseHandler.cpp33
-rw-r--r--src/server/game/Handlers/AuthHandler.cpp92
-rw-r--r--src/server/game/Server/Packet.cpp22
-rw-r--r--src/server/game/Server/Packet.h53
-rw-r--r--src/server/game/Server/Packets/AuctionHousePackets.cpp57
-rw-r--r--src/server/game/Server/Packets/AuctionHousePackets.h56
-rw-r--r--src/server/game/Server/Packets/AuthenticationPackets.cpp107
-rw-r--r--src/server/game/Server/Packets/AuthenticationPackets.h99
-rw-r--r--src/server/game/Server/WorldSession.cpp25
-rw-r--r--src/server/game/Server/WorldSession.h17
-rw-r--r--src/server/game/Server/WorldSocket.cpp13
-rw-r--r--src/server/game/Server/WorldSocket.h5
-rw-r--r--src/server/shared/Utilities/Util.h7
14 files changed, 476 insertions, 111 deletions
diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt
index 27b3ea2c381..bcf1a33a626 100644
--- a/src/server/game/CMakeLists.txt
+++ b/src/server/game/CMakeLists.txt
@@ -191,6 +191,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/Quests
${CMAKE_CURRENT_SOURCE_DIR}/Reputation
${CMAKE_CURRENT_SOURCE_DIR}/Scripting
+ ${CMAKE_CURRENT_SOURCE_DIR}/Server/Packets
${CMAKE_CURRENT_SOURCE_DIR}/Server/Protocol
${CMAKE_CURRENT_SOURCE_DIR}/Server
${CMAKE_CURRENT_SOURCE_DIR}/Skills
diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp
index cb14d45d750..ca52eeb348f 100644
--- a/src/server/game/Handlers/AuctionHouseHandler.cpp
+++ b/src/server/game/Handlers/AuctionHouseHandler.cpp
@@ -30,6 +30,8 @@
#include "Util.h"
#include "AccountMgr.h"
+#include "AuctionHousePackets.h"
+
//void called when player click on auctioneer npc
void WorldSession::HandleAuctionHelloOpcode(WorldPacket& recvData)
{
@@ -70,31 +72,14 @@ void WorldSession::SendAuctionHello(ObjectGuid guid, Creature* unit)
SendPacket(&data);
}
-//call this method when player bids, creates, or deletes auction
-void WorldSession::SendAuctionCommandResult(AuctionEntry* auction, uint32 action, uint32 errorCode, uint32 bidError)
+void WorldSession::SendAuctionCommandResult(AuctionEntry* auction, uint32 action, uint32 errorCode, uint32 /*bidError = 0*/)
{
- WorldPacket data(SMSG_AUCTION_COMMAND_RESULT);
- data << uint32(auction ? auction->Id : 0);
- data << uint32(action);
- data << uint32(errorCode);
-
- switch (errorCode)
- {
- case ERR_AUCTION_OK:
- if (action == AUCTION_PLACE_BID)
- data << uint64(auction->bid ? auction->GetAuctionOutBid() : 0);
- break;
- case ERR_AUCTION_INVENTORY:
- data << uint32(bidError);
- break;
- case ERR_AUCTION_HIGHER_BID:
- data << uint64(auction->bidder);
- data << uint64(auction->bid);
- data << uint64(auction->bid ? auction->GetAuctionOutBid() : 0);
- break;
- }
-
- SendPacket(&data);
+ WorldPackets::AuctionHousePackets::AuctionCommandResult auctionCommandResult;
+ auctionCommandResult.InitializeAuction(auction);
+ auctionCommandResult.Action = action;
+ auctionCommandResult.ErrorCode = errorCode;
+ auctionCommandResult.Write();
+ SendPacket(&auctionCommandResult.GetWorldPacket());
}
//this function sends notification, if bidder is online
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)
diff --git a/src/server/game/Server/Packet.cpp b/src/server/game/Server/Packet.cpp
new file mode 100644
index 00000000000..bff5643f410
--- /dev/null
+++ b/src/server/game/Server/Packet.cpp
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "Packet.h"
+
+WorldPackets::ServerPacket::ServerPacket(OpcodeServer opcode, size_t initialSize = 200) : Packet(WorldPacket(opcode, initialSize))
+{
+}
diff --git a/src/server/game/Server/Packet.h b/src/server/game/Server/Packet.h
new file mode 100644
index 00000000000..ebfa5c302a9
--- /dev/null
+++ b/src/server/game/Server/Packet.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PacketBaseWorld_h__
+#define PacketBaseWorld_h__
+
+namespace WorldPackets
+{
+ class Packet
+ {
+ public:
+ Packet(WorldPacket&& worldPacket) : _worldPacket(std::move(worldPacket)) { }
+ virtual ~Packet() = default;
+
+ Packet(Packet const& right) = delete;
+ Packet& operator=(Packet const& right) = delete;
+
+ virtual void Write() = 0;
+ virtual void Read() = 0;
+
+ WorldPacket& GetWorldPacket() { return _worldPacket; }
+
+ protected:
+ WorldPacket _worldPacket;
+ };
+
+ class ServerPacket : public Packet
+ {
+ public:
+ ServerPacket(OpcodeServer opcode, size_t initialSize);
+
+ void Read() override final { ASSERT(!"Read not implemented for server packets."); }
+
+ size_t GetSize() const { return _worldPacket.size(); }
+ void Reset() { _worldPacket.clear(); }
+ };
+}
+
+#endif
diff --git a/src/server/game/Server/Packets/AuctionHousePackets.cpp b/src/server/game/Server/Packets/AuctionHousePackets.cpp
new file mode 100644
index 00000000000..c9232e2bb19
--- /dev/null
+++ b/src/server/game/Server/Packets/AuctionHousePackets.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "AuctionHousePackets.h"
+#include "AuctionHouseMgr.h"
+#include "ObjectGuid.h"
+
+WorldPackets::AuctionHousePackets::AuctionCommandResult::AuctionCommandResult()
+ : ServerPacket(SMSG_AUCTION_COMMAND_RESULT, 4 + 4 + 4 + 8 + 4 + 8 + 8 + 8) { }
+
+void WorldPackets::AuctionHousePackets::AuctionCommandResult::InitializeAuction(AuctionEntry* auction)
+{
+ if (auction)
+ {
+ AuctionId = auction->Id;
+ Bid = auction->bid;
+ AuctionOutBid = auction->GetAuctionOutBid();
+ Bidder = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
+ }
+}
+
+void WorldPackets::AuctionHousePackets::AuctionCommandResult::Write()
+{
+ _worldPacket << uint32(AuctionId);
+ _worldPacket << uint32(Action);
+ _worldPacket << uint32(ErrorCode);
+
+ switch (ErrorCode)
+ {
+ case ERR_AUCTION_OK:
+ if (Action == AUCTION_PLACE_BID)
+ _worldPacket << uint64(Bid ? AuctionOutBid : 0);
+ break;
+ case ERR_AUCTION_INVENTORY:
+ _worldPacket << uint32(BidError);
+ break;
+ case ERR_AUCTION_HIGHER_BID:
+ _worldPacket << Bidder;
+ _worldPacket << uint64(Bid);
+ _worldPacket << uint64(Bid ? AuctionOutBid : 0);
+ break;
+ }
+} \ No newline at end of file
diff --git a/src/server/game/Server/Packets/AuctionHousePackets.h b/src/server/game/Server/Packets/AuctionHousePackets.h
new file mode 100644
index 00000000000..044810ced6c
--- /dev/null
+++ b/src/server/game/Server/Packets/AuctionHousePackets.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef AuctionHousePackets_h__
+
+#include "Packet.h"
+
+class ObjectGuid;
+
+struct AuctionEntry;
+
+namespace WorldPackets
+{
+ namespace AuctionHousePackets
+ {
+ class AuctionCommandResult final : public ServerPacket
+ {
+ public:
+ AuctionCommandResult();
+
+ /**
+ * @fn void WorldPackets::AuctionHousePackets::AuctionCommandResult::InitializeAuction(AuctionEntry* auction);
+ *
+ * @brief Initialize the following fields: AuctionId, Bid, AuctionOutBid, Bidder
+ *
+ * @param auction The relevant auction object
+ */
+ void InitializeAuction(AuctionEntry* auction);
+
+ void Write() override;
+
+ uint32 AuctionId = 0; ///< the id of the auction that triggered this notification
+ uint32 Action = 0; ///< the type of action that triggered this notification. Possible values are @ref AuctionAction
+ uint32 ErrorCode = 0; ///< the error code that was generated when trying to perform the action. Possible values are @ref AuctionError
+ uint64 Bid = 0; ///< the amount of money that the player bid in copper
+ uint32 BidError = 0; ///< the bid error. Possible values are @ref AuctionError
+ ObjectGuid Bidder; ///< the GUID of the bidder for this auction.
+ uint64 AuctionOutBid = 0; ///< the sum of outbid is (1% of current bid) * 5, if the bid is too small, then this value is 1 copper.
+ };
+ }
+}
+#endif
diff --git a/src/server/game/Server/Packets/AuthenticationPackets.cpp b/src/server/game/Server/Packets/AuthenticationPackets.cpp
new file mode 100644
index 00000000000..1d20c582b0b
--- /dev/null
+++ b/src/server/game/Server/Packets/AuthenticationPackets.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "AuthenticationPackets.h"
+
+WorldPackets::Auth::AuthResponse::AuthResponse()
+ : ServerPacket(SMSG_AUTH_RESPONSE, 132)
+{
+ WaitInfo.HasValue = false;
+ SuccessInfo.HasValue = false;
+}
+
+void WorldPackets::Auth::AuthResponse::Write()
+{
+ _worldPacket << uint8(Result);
+ _worldPacket.WriteBit(SuccessInfo.HasValue);
+ _worldPacket.WriteBit(WaitInfo.HasValue);
+
+ if (SuccessInfo.HasValue)
+ {
+ _worldPacket << uint32(SuccessInfo.value.VirtualRealmAddress);
+ _worldPacket << uint32(SuccessInfo.value.VirtualRealms.size());
+ _worldPacket << uint32(SuccessInfo.value.TimeRemain);
+ _worldPacket << uint32(SuccessInfo.value.TimeOptions);
+ _worldPacket << uint32(SuccessInfo.value.TimeRested);
+ _worldPacket << uint8(SuccessInfo.value.ActiveExpansionLevel);
+ _worldPacket << uint8(SuccessInfo.value.AccountExpansionLevel);
+ _worldPacket << uint32(SuccessInfo.value.TimeSecondsUntilPCKick);
+ _worldPacket << uint32(SuccessInfo.value.AvailableRaces->size());
+ _worldPacket << uint32(SuccessInfo.value.AvailableClasses->size());
+ _worldPacket << uint32(SuccessInfo.value.Templates.size());
+ _worldPacket << uint32(SuccessInfo.value.CurrencyID);
+
+ for (auto& realm : SuccessInfo.value.VirtualRealms)
+ {
+ _worldPacket << uint32(realm.RealmAddress);
+ _worldPacket.WriteBit(realm.IsLocal);
+ _worldPacket.WriteBit(realm.IsInternalRealm);
+ _worldPacket.WriteBits(realm.RealmNameActual.length(), 8);
+ _worldPacket.WriteBits(realm.RealmNameNormalized.length(), 8);
+ _worldPacket.WriteString(realm.RealmNameActual);
+ _worldPacket.WriteString(realm.RealmNameNormalized);
+ }
+
+ for (auto& race : *SuccessInfo.value.AvailableRaces)
+ {
+ _worldPacket << uint8(race.first); /// the current race
+ _worldPacket << uint8(race.second); /// the required Expansion
+ }
+
+ for (auto& klass : *SuccessInfo.value.AvailableClasses)
+ {
+ _worldPacket << uint8(klass.first); /// the current class
+ _worldPacket << uint8(klass.second); /// the required Expansion
+ }
+
+ for (auto& templat : SuccessInfo.value.Templates)
+ {
+ _worldPacket << uint32(templat.TemplateSetId);
+ _worldPacket << uint32(templat.TemplateClasses.size());
+ for (auto& templatClass : templat.TemplateClasses)
+ {
+ _worldPacket << uint8(templatClass.Class);
+ _worldPacket << uint8(templatClass.FactionGroup);
+ }
+
+ _worldPacket.WriteBits(templat.Name.length(), 7);
+ _worldPacket.WriteBits(templat.Description.length(), 10);
+ _worldPacket.WriteString(templat.Name);
+ _worldPacket.WriteString(templat.Description);
+ }
+
+ _worldPacket.WriteBit(SuccessInfo.value.IsExpansionTrial);
+ _worldPacket.WriteBit(SuccessInfo.value.ForceCharacterTemplate);
+ _worldPacket.WriteBit(SuccessInfo.value.NumPlayersHorde != 0);
+ _worldPacket.WriteBit(SuccessInfo.value.NumPlayersAlliance != 0);
+ _worldPacket.WriteBit(SuccessInfo.value.IsVeteranTrial);
+
+ if (SuccessInfo.value.NumPlayersHorde)
+ _worldPacket << uint16(SuccessInfo.value.NumPlayersHorde);
+
+ if (SuccessInfo.value.NumPlayersAlliance)
+ _worldPacket << uint16(SuccessInfo.value.NumPlayersAlliance);
+ }
+
+ if (WaitInfo.HasValue)
+ {
+ _worldPacket << uint32(WaitInfo.value.WaitCount);
+ _worldPacket.WriteBit(WaitInfo.value.HasFCM);
+ }
+
+ _worldPacket.FlushBits();
+} \ No newline at end of file
diff --git a/src/server/game/Server/Packets/AuthenticationPackets.h b/src/server/game/Server/Packets/AuthenticationPackets.h
new file mode 100644
index 00000000000..dd5fea06e10
--- /dev/null
+++ b/src/server/game/Server/Packets/AuthenticationPackets.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef AuthenticationPackets_h__
+
+#include "Packet.h"
+#include "Util.h"
+
+namespace WorldPackets
+{
+ namespace Auth
+ {
+ class AuthResponse final : public ServerPacket
+ {
+ public:
+ struct RealmInfo
+ {
+ RealmInfo(uint32 realmAddress, bool isHomeRealm, bool isInternalRealm, std::string const& realmNameActual, std::string const& realmNameNormalized) :
+ RealmAddress(realmAddress), IsLocal(isHomeRealm), IsInternalRealm(isInternalRealm), RealmNameActual(realmNameActual), RealmNameNormalized(realmNameNormalized) { }
+
+ uint32 RealmAddress; ///< the virtual address of this realm, constructed as RealmHandle::Region << 24 | RealmHandle::Battlegroup << 16 | RealmHandle::Index
+ bool IsLocal; ///< true if the realm is the same as the account's home realm
+ bool IsInternalRealm; ///< @todo research
+ std::string RealmNameActual; ///< the name of the realm
+ std::string RealmNameNormalized; ///< the name of the realm without spaces
+ };
+
+ struct CharacterTemplate
+ {
+ struct TemplateClass
+ {
+ uint8 Class;
+ uint8 FactionGroup; ///< @todo research
+ };
+
+ uint32 TemplateSetId; ///< @todo research
+ std::list<TemplateClass> TemplateClasses;
+ std::string Name;
+ std::string Description;
+ };
+
+ struct AuthSuccessInfo
+ {
+ uint32 TimeRemain = 0; ///< the remaining game time that the account has in seconds. It is not currently implemented and probably won't ever be.
+ uint8 AccountExpansionLevel = 0; ///< the current expansion of this account, the possible values are in @ref Expansions
+ uint8 ActiveExpansionLevel = 0; ///< the current server expansion, the possible values are in @ref Expansions
+ uint32 TimeRested = 0; ///< affects the return value of the GetBillingTimeRested() client API call, it is the number of seconds you have left until the experience points and loot you receive from creatures and quests is reduced. It is only used in the Asia region in retail, it's not implemented in TC and will probably never be.
+ uint8 TimeOptions = 0; ///< controls the behavior of the client regarding billing, used in Asia realms, as they don't have monthly subscriptions, possible values are in @ref BillingPlanFlags. It is not currently implemented and will probably never be.
+
+ uint32 VirtualRealmAddress = 0; ///< a special identifier made from the Index, BattleGroup and Region. @todo implement
+ uint32 RealmNamesCount = 0; ///< the number of realms connected to this one (inclusive). @todo implement
+ uint32 TimeSecondsUntilPCKick = 0; ///< @todo research
+ uint32 CurrencyID = 0; ///< this is probably used for the ingame shop. @todo implement
+
+ std::list<RealmInfo> VirtualRealms; ///< list of realms connected to this one (inclusive) @todo implement
+ std::list<CharacterTemplate> Templates; ///< list of pre-made character templates. @todo implement
+
+ ExpansionRequirementContainer const* AvailableClasses = nullptr; ///< the minimum AccountExpansion required to select the classes
+ ExpansionRequirementContainer const* AvailableRaces = nullptr; ///< the minimum AccountExpansion required to select the races
+
+ bool IsExpansionTrial = false;
+ bool ForceCharacterTemplate = false; ///< forces the client to always use a character template when creating a new character. @see Templates. @todo implement
+ uint16 NumPlayersHorde = 0; ///< number of horde players in this realm. @todo implement
+ uint16 NumPlayersAlliance = 0; ///< number of alliance players in this realm. @todo implement
+ bool IsVeteranTrial = false; ///< @todo research
+ };
+
+ struct AuthWaitInfo
+ {
+ uint32 WaitCount = 0; ///< position of the account in the login queue
+ bool HasFCM = false; ///< true if the account has a forced character migration pending. @todo implement
+ };
+
+ AuthResponse();
+
+ void Write() override;
+
+ Optional<AuthSuccessInfo> SuccessInfo; ///< contains the packet data in case that it has account information (It is never set when WaitInfo is set), otherwise its contents are undefined.
+ Optional<AuthWaitInfo> WaitInfo; ///< contains the queue wait information in case the account is in the login queue.
+ uint8 Result = 0; ///< the result of the authentication process, it is AUTH_OK if it succeeded and the account is ready to log in. It can also be AUTH_WAIT_QUEUE if the account entered the login queue (Queued, QueuePos), possible values are @ref ResponseCodes
+ };
+ }
+}
+
+#endif
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index 050a30a4b5d..2332829e69a 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -21,6 +21,7 @@
*/
#include "WorldSocket.h"
+#include "Packet.h"
#include <zlib.h>
#include "Config.h"
#include "Common.h"
@@ -684,30 +685,6 @@ void WorldSession::Handle_Deprecated(WorldPacket& recvPacket)
, GetOpcodeNameForLogging(static_cast<OpcodeClient>(recvPacket.GetOpcode())).c_str(), GetPlayerInfo().c_str());
}
-void WorldSession::SendAuthWaitQue(uint32 position)
-{
- if (position == 0)
- {
- WorldPacket packet(SMSG_AUTH_RESPONSE, 2);
- packet << uint8(AUTH_OK);
- packet.WriteBit(0); // has account info
- packet.WriteBit(0); // has queue info
- packet.FlushBits();
- SendPacket(&packet);
- }
- else
- {
- WorldPacket packet(SMSG_AUTH_RESPONSE, 6);
- packet << uint8(AUTH_WAIT_QUEUE);
- packet.WriteBit(0); // has account info
- packet.WriteBit(1); // has queue info
- packet << uint32(position);
- packet.WriteBit(0); // unk queue bool
- packet.FlushBits();
- SendPacket(&packet);
- }
-}
-
void WorldSession::LoadGlobalAccountData()
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_DATA);
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 8599fa1b314..254532bcf4c 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -71,6 +71,11 @@ namespace rbac
class RBACData;
}
+namespace WorldPackets
+{
+ class ServerPacket;
+}
+
enum AccountDataType
{
GLOBAL_CONFIG_CACHE = 0, // 0x01 g
@@ -380,7 +385,19 @@ class WorldSession
bool SendItemInfo(uint32 itemid, WorldPacket data);
//auction
void SendAuctionHello(ObjectGuid guid, Creature* unit);
+
+ /**
+ * @fn void WorldSession::SendAuctionCommandResult(AuctionEntry* auction, uint32 Action, uint32 ErrorCode, uint32 bidError = 0);
+ *
+ * @brief Notifies the client of the result of his last auction operation. It is called when the player bids, creates, or deletes an auction
+ *
+ * @param auction The relevant auction object
+ * @param Action The action that was performed.
+ * @param ErrorCode The resulting error code.
+ * @param bidError (Optional) the bid error.
+ */
void SendAuctionCommandResult(AuctionEntry* auction, uint32 Action, uint32 ErrorCode, uint32 bidError = 0);
+
void SendAuctionBidderNotification(uint32 location, uint32 auctionId, ObjectGuid bidder, uint32 bidSum, uint32 diff, uint32 item_template);
void SendAuctionOwnerNotification(AuctionEntry* auction);
void SendAuctionRemovedNotification(uint32 auctionId, uint32 itemEntry, int32 randomPropertyId);
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index 3d8e804aac6..e9200eae84c 100644
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -17,6 +17,7 @@
*/
#include "WorldSocket.h"
+#include "AuthenticationPackets.h"
#include "BigNumber.h"
#include "Opcodes.h"
#include "Player.h"
@@ -588,13 +589,13 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
void WorldSocket::SendAuthResponseError(uint8 code)
{
- WorldPacket packet(SMSG_AUTH_RESPONSE, 2);
- packet << uint8(code);
- packet.WriteBit(0); // has account info
- packet.WriteBit(0); // has queue info
+ WorldPackets::Auth::AuthResponse response;
+ response.SuccessInfo.HasValue = false;
+ response.WaitInfo.HasValue = false;
+ response.Result = code;
+ response.Write();
- packet.FlushBits();
- SendPacket(packet);
+ SendPacket(response.GetWorldPacket());
}
void WorldSocket::HandlePing(WorldPacket& recvPacket)
diff --git a/src/server/game/Server/WorldSocket.h b/src/server/game/Server/WorldSocket.h
index 79ca6fe1621..0517ebcce91 100644
--- a/src/server/game/Server/WorldSocket.h
+++ b/src/server/game/Server/WorldSocket.h
@@ -32,6 +32,11 @@
using boost::asio::ip::tcp;
+namespace WorldPackets
+{
+ class ServerPacket;
+}
+
#pragma pack(push, 1)
union ClientPktHeader
diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h
index 73ee37eb079..e2d8cd3a195 100644
--- a/src/server/shared/Utilities/Util.h
+++ b/src/server/shared/Utilities/Util.h
@@ -28,6 +28,13 @@
#include <list>
#include <map>
+template<typename T>
+struct Optional
+{
+ T value;
+ bool HasValue;
+};
+
// Searcher for map of structs
template<typename T, class S> struct Finder
{