Skip to content

Commit

Permalink
Core/PacketIO: Fixed server queue display
Browse files Browse the repository at this point in the history
Closes #18218
  • Loading branch information
Shauren committed Nov 27, 2016
1 parent 90070d5 commit e12e5f8
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 28 deletions.
27 changes: 14 additions & 13 deletions src/server/game/Handlers/AuthHandler.cpp
Expand Up @@ -27,12 +27,7 @@ void WorldSession::SendAuthResponse(uint32 code, bool queued, uint32 queuePos)
WorldPackets::Auth::AuthResponse response;
response.Result = code;

if (queued)
{
response.WaitInfo = boost::in_place();
response.WaitInfo->WaitCount = queuePos;
}
else if (code == ERROR_OK)
if (code == ERROR_OK)
{
response.SuccessInfo = boost::in_place();

Expand All @@ -53,21 +48,27 @@ void WorldSession::SendAuthResponse(uint32 code, bool queued, uint32 queuePos)
response.SuccessInfo->AvailableRaces = &sObjectMgr->GetRaceExpansionRequirements();
}

if (queued)
{
response.WaitInfo = boost::in_place();
response.WaitInfo->WaitCount = queuePos;
}

SendPacket(response.Write());
}

void WorldSession::SendAuthWaitQue(uint32 position)
{
WorldPackets::Auth::AuthResponse response;
response.Result = ERROR_OK;

if (position)
{
response.WaitInfo = boost::in_place();
response.WaitInfo->WaitCount = position;
WorldPackets::Auth::WaitQueueUpdate waitQueueUpdate;
waitQueueUpdate.WaitInfo.WaitCount = position;
waitQueueUpdate.WaitInfo.WaitTime = 0;
waitQueueUpdate.WaitInfo.HasFCM = false;
SendPacket(waitQueueUpdate.Write());
}

SendPacket(response.Write());
else
SendPacket(WorldPackets::Auth::WaitQueueFinish().Write());
}

void WorldSession::SendClientCacheVersion(uint32 version)
Expand Down
24 changes: 18 additions & 6 deletions src/server/game/Server/Packets/AuthenticationPackets.cpp
Expand Up @@ -73,6 +73,16 @@ void WorldPackets::Auth::AuthSession::Read()
}
}

ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Auth::AuthWaitInfo const& waitInfo)
{
data << uint32(waitInfo.WaitCount);
data << uint32(waitInfo.WaitTime);
data.WriteBit(waitInfo.HasFCM);
data.FlushBits();

return data;
}

WorldPackets::Auth::AuthResponse::AuthResponse()
: ServerPacket(SMSG_AUTH_RESPONSE, 132)
{
Expand Down Expand Up @@ -166,12 +176,14 @@ WorldPacket const* WorldPackets::Auth::AuthResponse::Write()
}

if (WaitInfo)
{
_worldPacket << uint32(WaitInfo->WaitCount);
_worldPacket << uint32(WaitInfo->WaitTime);
_worldPacket.WriteBit(WaitInfo->HasFCM);
_worldPacket.FlushBits();
}
_worldPacket << *WaitInfo;

return &_worldPacket;
}

WorldPacket const* WorldPackets::Auth::WaitQueueUpdate::Write()
{
_worldPacket << WaitInfo;

return &_worldPacket;
}
Expand Down
32 changes: 25 additions & 7 deletions src/server/game/Server/Packets/AuthenticationPackets.h
Expand Up @@ -99,6 +99,13 @@ namespace WorldPackets
void Read() override;
};

struct AuthWaitInfo
{
uint32 WaitCount = 0; ///< position of the account in the login queue
uint32 WaitTime = 0; ///< Wait time in login queue in minutes, if sent queued and this value is 0 client displays "unknown time"
bool HasFCM = false; ///< true if the account has a forced character migration pending. @todo implement
};

class AuthResponse final : public ServerPacket
{
public:
Expand Down Expand Up @@ -146,13 +153,6 @@ namespace WorldPackets
Optional<uint16> NumPlayersAlliance; ///< number of alliance players in this realm. @todo implement
};

struct AuthWaitInfo
{
uint32 WaitCount = 0; ///< position of the account in the login queue
uint32 WaitTime = 0; ///< Wait time in login queue in minutes, if sent queued and this value is 0 client displays "unknown time"
bool HasFCM = false; ///< true if the account has a forced character migration pending. @todo implement
};

AuthResponse();

WorldPacket const* Write() override;
Expand All @@ -162,6 +162,24 @@ namespace WorldPackets
uint32 Result = 0; ///< the result of the authentication process, possible values are @ref BattlenetRpcErrorCode
};

class WaitQueueUpdate final : public ServerPacket
{
public:
WaitQueueUpdate() : ServerPacket(SMSG_WAIT_QUEUE_UPDATE, 4 + 4 + 1) { }

WorldPacket const* Write() override;

AuthWaitInfo WaitInfo;
};

class WaitQueueFinish final : public ServerPacket
{
public:
WaitQueueFinish() : ServerPacket(SMSG_WAIT_QUEUE_FINISH, 0) { }

WorldPacket const* Write() override { return &_worldPacket; }
};

enum class ConnectToSerial : uint32
{
None = 0,
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Server/Protocol/Opcodes.cpp
Expand Up @@ -1764,8 +1764,8 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_STORAGE_FAILED, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_STORAGE_TRANSFER_CHANGES, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_TRANSFER_RESULT, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WAIT_QUEUE_FINISH, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WAIT_QUEUE_UPDATE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WAIT_QUEUE_FINISH, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WAIT_QUEUE_UPDATE, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WARDEN_DATA, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WARGAME_REQUEST_SUCCESSFULLY_SENT_TO_OPPONENT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WEATHER, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
Expand Down

1 comment on commit e12e5f8

@soulfrost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank u 👍

Please sign in to comment.