mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
feat(master): login stamps travel through master and back
The login's Stamps now go with auth's REQUEST_ZONE_TRANSFER to master and come back in REQUEST_ZONE_TRANSFER_RESPONSE, so master stamps the steps it performs itself, with its own time: got the request (WORLD_PACKET_RECEIVED, zone), the world is still starting and the request waits (IM_LOGIN_QUEUED, instance), answered with a world (WORLD_SESSION_CONFIRM_TO_AUTH, instance). Auth sends what comes back in the login response. Server to server wire change (message IDs unchanged): both messages end with a Stamps list (u32 16 * count + 4, then the stamps); it is empty (4 bytes) when a world server asks for a transfer. Touched: - MasterPackets::SendZoneTransferRequest / SendZoneTransferResponse: take and write the stamps (default empty) - MasterServer.cpp REQUEST_ZONE_TRANSFER: reads them, stamps, keeps them in the PendingInstanceRequest (new stamps member, InstanceManager.h) - InstanceManager::ReadyInstance / AffirmTransfer: stamp and send them back - ZoneInstanceManager: HandleRequestZoneTransferResponse reads them; a RequestZoneTransfer overload takes stamps and a callback that gets them - AuthPackets LoginRequest::Handle uses that overload Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -156,6 +156,8 @@ void InstanceManager::ReadyInstance(const InstancePtr& instance) {
|
|||||||
|
|
||||||
LOG("Responding to pending request %llu -> %i (%i)", request, zoneId.GetMapID(), zoneId.GetCloneID());
|
LOG("Responding to pending request %llu -> %i (%i)", request, zoneId.GetMapID(), zoneId.GetCloneID());
|
||||||
|
|
||||||
|
auto stamps = request.stamps;
|
||||||
|
stamps.Add(eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, zoneId.GetInstanceID());
|
||||||
MasterPackets::SendZoneTransferResponse(
|
MasterPackets::SendZoneTransferResponse(
|
||||||
Game::server,
|
Game::server,
|
||||||
request.sysAddr,
|
request.sysAddr,
|
||||||
@@ -165,7 +167,8 @@ void InstanceManager::ReadyInstance(const InstancePtr& instance) {
|
|||||||
zoneId.GetInstanceID(),
|
zoneId.GetInstanceID(),
|
||||||
zoneId.GetCloneID(),
|
zoneId.GetCloneID(),
|
||||||
instance->GetIP(),
|
instance->GetIP(),
|
||||||
instance->GetPort()
|
instance->GetPort(),
|
||||||
|
stamps
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,6 +202,8 @@ void InstanceManager::AffirmTransfer(const InstancePtr& instance, const uint64_t
|
|||||||
|
|
||||||
const auto& zoneId = instance->GetZoneID();
|
const auto& zoneId = instance->GetZoneID();
|
||||||
|
|
||||||
|
auto stamps = request.stamps;
|
||||||
|
stamps.Add(eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, zoneId.GetInstanceID());
|
||||||
MasterPackets::SendZoneTransferResponse(
|
MasterPackets::SendZoneTransferResponse(
|
||||||
Game::server,
|
Game::server,
|
||||||
request.sysAddr,
|
request.sysAddr,
|
||||||
@@ -208,7 +213,8 @@ void InstanceManager::AffirmTransfer(const InstancePtr& instance, const uint64_t
|
|||||||
zoneId.GetInstanceID(),
|
zoneId.GetInstanceID(),
|
||||||
zoneId.GetCloneID(),
|
zoneId.GetCloneID(),
|
||||||
instance->GetIP(),
|
instance->GetIP(),
|
||||||
instance->GetPort()
|
instance->GetPort(),
|
||||||
|
stamps
|
||||||
);
|
);
|
||||||
|
|
||||||
pending.erase(pending.begin() + i);
|
pending.erase(pending.begin() + i);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "dCommonVars.h"
|
#include "dCommonVars.h"
|
||||||
#include "IServerOperations.h"
|
#include "IServerOperations.h"
|
||||||
#include "RakNetTypes.h"
|
#include "RakNetTypes.h"
|
||||||
|
#include "Stamps.h"
|
||||||
#include "dZMCommon.h"
|
#include "dZMCommon.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ struct PendingInstanceRequest {
|
|||||||
uint64_t id;
|
uint64_t id;
|
||||||
bool mythranShift;
|
bool mythranShift;
|
||||||
SystemAddress sysAddr;
|
SystemAddress sysAddr;
|
||||||
|
Stamps stamps; // The login stamps that came with the request; they go back in the response
|
||||||
};
|
};
|
||||||
|
|
||||||
class Instance {
|
class Instance {
|
||||||
|
|||||||
@@ -640,6 +640,10 @@ void HandlePacket(Packet* packet) {
|
|||||||
inStream.Read(mythranShift);
|
inStream.Read(mythranShift);
|
||||||
inStream.Read(zoneID);
|
inStream.Read(zoneID);
|
||||||
inStream.Read(zoneClone);
|
inStream.Read(zoneClone);
|
||||||
|
// The login stamps travelling with the request (see Stamps.h); master adds its steps
|
||||||
|
Stamps stamps;
|
||||||
|
if (!stamps.Deserialize(inStream)) stamps = {};
|
||||||
|
if (!stamps.empty()) stamps.Add(eStamps::PASSPORT_AUTH_WORLD_PACKET_RECEIVED, zoneID);
|
||||||
if (shutdownSequenceStarted) {
|
if (shutdownSequenceStarted) {
|
||||||
LOG("Shutdown sequence has been started. Not creating a new zone.");
|
LOG("Shutdown sequence has been started. Not creating a new zone.");
|
||||||
break;
|
break;
|
||||||
@@ -652,14 +656,15 @@ void HandlePacket(Packet* packet) {
|
|||||||
|
|
||||||
if (in && !in->GetIsReady()) //Instance not ready, make a pending request
|
if (in && !in->GetIsReady()) //Instance not ready, make a pending request
|
||||||
{
|
{
|
||||||
in->GetPendingRequests().push_back({ requestID, static_cast<bool>(mythranShift), packet->systemAddress });
|
if (!stamps.empty()) stamps.Add(eStamps::PASSPORT_AUTH_IM_LOGIN_QUEUED, in->GetInstanceID());
|
||||||
|
in->GetPendingRequests().push_back({ requestID, static_cast<bool>(mythranShift), packet->systemAddress, stamps });
|
||||||
LOG("Server not ready, adding pending request %llu %i %i", requestID, zoneID, zoneClone);
|
LOG("Server not ready, adding pending request %llu %i %i", requestID, zoneID, zoneClone);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Instance is ready, transfer
|
//Instance is ready, transfer
|
||||||
LOG("Responding to transfer request %llu for zone %i %i", requestID, zoneID, zoneClone);
|
LOG("Responding to transfer request %llu for zone %i %i", requestID, zoneID, zoneClone);
|
||||||
Game::im->RequestAffirmation(in, { requestID, static_cast<bool>(mythranShift), packet->systemAddress });
|
Game::im->RequestAffirmation(in, { requestID, static_cast<bool>(mythranShift), packet->systemAddress, stamps });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ void AuthPackets::LoginRequest::Handle() {
|
|||||||
}
|
}
|
||||||
// Ask master for a world server to send the player to
|
// Ask master for a world server to send the player to
|
||||||
stamps.Add(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_START);
|
stamps.Add(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_START);
|
||||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(server, 0, 0, false, [system, server, username, stamps](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort) mutable {
|
// The stamps go along: master adds its steps and sends them back with the world server
|
||||||
stamps.Add(eStamps::PASSPORT_AUTH_WORLD_PACKET_RECEIVED, zoneInstance);
|
ZoneInstanceManager::Instance()->RequestZoneTransfer(server, 0, 0, false, stamps, [system, server, username](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort, Stamps stamps) mutable {
|
||||||
AuthPackets::SendLoginResponse(server, system, eLoginResponse::SUCCESS, "", zoneIP, zonePort, username, stamps);
|
AuthPackets::SendLoginResponse(server, system, eLoginResponse::SUCCESS, "", zoneIP, zonePort, username, stamps);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,6 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
|
|||||||
|
|
||||||
LOG("Set session key for user %s", username.c_str());
|
LOG("Set session key for user %s", username.c_str());
|
||||||
|
|
||||||
stamps.Add(eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, 1);
|
|
||||||
stamps.Add(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH, wServerPort);
|
stamps.Add(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH, wServerPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
void MasterPackets::SendZoneTransferRequest(dServer* server, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t cloneID) {
|
void MasterPackets::SendZoneTransferRequest(dServer* server, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t cloneID, const Stamps& stamps) {
|
||||||
RakNet::BitStream bitStream;
|
RakNet::BitStream bitStream;
|
||||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::MASTER, MessageType::Master::REQUEST_ZONE_TRANSFER);
|
BitStreamUtils::WriteHeader(bitStream, ServiceType::MASTER, MessageType::Master::REQUEST_ZONE_TRANSFER);
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@ void MasterPackets::SendZoneTransferRequest(dServer* server, uint64_t requestID,
|
|||||||
bitStream.Write<uint8_t>(mythranShift);
|
bitStream.Write<uint8_t>(mythranShift);
|
||||||
bitStream.Write(zoneID);
|
bitStream.Write(zoneID);
|
||||||
bitStream.Write(cloneID);
|
bitStream.Write(cloneID);
|
||||||
|
stamps.Serialize(bitStream);
|
||||||
|
|
||||||
server->SendToMaster(bitStream);
|
server->SendToMaster(bitStream);
|
||||||
}
|
}
|
||||||
@@ -60,7 +61,7 @@ void MasterPackets::SendWorldReady(dServer* server, LWOMAPID zoneId, LWOINSTANCE
|
|||||||
server->SendToMaster(bitStream);
|
server->SendToMaster(bitStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterPackets::SendZoneTransferResponse(dServer* server, const SystemAddress& sysAddr, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, const std::string& serverIP, uint32_t serverPort) {
|
void MasterPackets::SendZoneTransferResponse(dServer* server, const SystemAddress& sysAddr, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, const std::string& serverIP, uint32_t serverPort, const Stamps& stamps) {
|
||||||
RakNet::BitStream bitStream;
|
RakNet::BitStream bitStream;
|
||||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::MASTER, MessageType::Master::REQUEST_ZONE_TRANSFER_RESPONSE);
|
BitStreamUtils::WriteHeader(bitStream, ServiceType::MASTER, MessageType::Master::REQUEST_ZONE_TRANSFER_RESPONSE);
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ void MasterPackets::SendZoneTransferResponse(dServer* server, const SystemAddres
|
|||||||
bitStream.Write(zoneClone);
|
bitStream.Write(zoneClone);
|
||||||
bitStream.Write<uint16_t>(serverPort);
|
bitStream.Write<uint16_t>(serverPort);
|
||||||
bitStream.Write(LUString(serverIP, 255));
|
bitStream.Write(LUString(serverIP, 255));
|
||||||
|
stamps.Serialize(bitStream);
|
||||||
|
|
||||||
server->Send(bitStream, sysAddr, false);
|
server->Send(bitStream, sysAddr, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "RakNetTypes.h"
|
#include "RakNetTypes.h"
|
||||||
#include "dCommonVars.h"
|
#include "dCommonVars.h"
|
||||||
|
#include "Stamps.h"
|
||||||
class dServer;
|
class dServer;
|
||||||
|
|
||||||
namespace MasterPackets {
|
namespace MasterPackets {
|
||||||
void SendZoneTransferRequest(dServer* server, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t cloneID);
|
// stamps: the login stamps travelling with the request (empty unless auth asks for a world during a login)
|
||||||
void SendZoneTransferResponse(dServer* server, const SystemAddress& sysAddr, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, const std::string& serverIP, uint32_t serverPort);
|
void SendZoneTransferRequest(dServer* server, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t cloneID, const Stamps& stamps = {});
|
||||||
|
void SendZoneTransferResponse(dServer* server, const SystemAddress& sysAddr, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, const std::string& serverIP, uint32_t serverPort, const Stamps& stamps = {});
|
||||||
|
|
||||||
void HandleServerInfo(Packet* packet);
|
void HandleServerInfo(Packet* packet);
|
||||||
void SendServerInfo(dServer* server, Packet* packet);
|
void SendServerInfo(dServer* server, Packet* packet);
|
||||||
|
|||||||
@@ -37,10 +37,12 @@
|
|||||||
* BYPASS (1) no play key needed (keys off, or a GM account)
|
* BYPASS (1) no play key needed (keys off, or a GM account)
|
||||||
* DB_INSERT_START / _FINISH writing to the database (lifting an expired ban, recording the address)
|
* DB_INSERT_START / _FINISH writing to the database (lifting an expired ban, recording the address)
|
||||||
* WORLD_DISCONNECT (1) no master server to ask for a world
|
* WORLD_DISCONNECT (1) no master server to ask for a world
|
||||||
* WORLD_COMMUNICATION_START (0) asked master for a world server
|
* WORLD_COMMUNICATION_START (0) auth asked master for a world server (the stamps go along)
|
||||||
* WORLD_PACKET_RECEIVED (instance) master answered
|
* WORLD_PACKET_RECEIVED (zone) master: got the request
|
||||||
* IM_COMMUNICATION_START / IM_LOGIN_START / IM_COMMUNICATION_END (1) the session key was given to master
|
* IM_LOGIN_QUEUED (instance) master: the world is still starting, the request waits for it
|
||||||
* WORLD_SESSION_CONFIRM_TO_AUTH (1), WORLD_COMMUNICATION_FINISH (world port) the player is sent to the world
|
* WORLD_SESSION_CONFIRM_TO_AUTH (instance) master: answered auth with the world (the stamps come back)
|
||||||
|
* IM_COMMUNICATION_START / IM_LOGIN_START / IM_COMMUNICATION_END (1) auth gave the session key to master
|
||||||
|
* WORLD_COMMUNICATION_FINISH (world port) auth sends the player to the world
|
||||||
* The auth server logs the same lines as the client (debug log) when it sends the response.
|
* The auth server logs the same lines as the client (debug log) when it sends the response.
|
||||||
*/
|
*/
|
||||||
enum class eStamps : uint32_t {
|
enum class eStamps : uint32_t {
|
||||||
@@ -102,8 +104,9 @@ struct Stamp {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// The stamps of one login. Each step adds its stamp when it happens, on whichever server performs it: the list
|
// The stamps of one login. Each step adds its stamp when it happens, on whichever server performs it: the list
|
||||||
// travels with the login from auth to master and back inside the server messages (REQUEST_ZONE_TRANSFER and its
|
// travels with the login from auth to master and back inside the server messages (REQUEST_ZONE_TRANSFER and
|
||||||
// response), and the login response finally carries it to the client.
|
// REQUEST_ZONE_TRANSFER_RESPONSE end with it; empty when a world asks), and the login response finally carries it
|
||||||
|
// to the client.
|
||||||
// Written as a u32 holding 16 * count + 4, then the stamps (the login response's layout).
|
// Written as a u32 holding 16 * count + 4, then the stamps (the login response's layout).
|
||||||
struct Stamps {
|
struct Stamps {
|
||||||
std::vector<Stamp> list{};
|
std::vector<Stamp> list{};
|
||||||
|
|||||||
@@ -8,10 +8,16 @@ ZoneInstanceManager* ZoneInstanceManager::m_Address = nullptr;
|
|||||||
|
|
||||||
//! Requests a zone transfer
|
//! Requests a zone transfer
|
||||||
void ZoneInstanceManager::RequestZoneTransfer(dServer* server, uint32_t zoneID, uint32_t zoneClone, bool mythranShift, TransferCallback callback) {
|
void ZoneInstanceManager::RequestZoneTransfer(dServer* server, uint32_t zoneID, uint32_t zoneClone, bool mythranShift, TransferCallback callback) {
|
||||||
|
RequestZoneTransfer(server, zoneID, zoneClone, mythranShift, Stamps{}, [callback](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort, Stamps) {
|
||||||
|
callback(mythranShift, zoneID, zoneInstance, zoneClone, serverIP, serverPort);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneInstanceManager::RequestZoneTransfer(dServer* server, uint32_t zoneID, uint32_t zoneClone, bool mythranShift, const Stamps& stamps, StampedTransferCallback callback) {
|
||||||
const auto nextID = ++currentRequestID;
|
const auto nextID = ++currentRequestID;
|
||||||
requests[nextID] = callback;
|
requests[nextID] = callback;
|
||||||
|
|
||||||
MasterPackets::SendZoneTransferRequest(server, nextID, mythranShift, zoneID, zoneClone);
|
MasterPackets::SendZoneTransferRequest(server, nextID, mythranShift, zoneID, zoneClone, stamps);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Handles a zone transfer response
|
//! Handles a zone transfer response
|
||||||
@@ -33,10 +39,12 @@ void ZoneInstanceManager::HandleRequestZoneTransferResponse(Packet* packet) {
|
|||||||
inStream.Read(serverPort);
|
inStream.Read(serverPort);
|
||||||
LUString serverIP(255);
|
LUString serverIP(255);
|
||||||
inStream.Read(serverIP);
|
inStream.Read(serverIP);
|
||||||
|
Stamps stamps;
|
||||||
|
if (!stamps.Deserialize(inStream)) stamps = {};
|
||||||
|
|
||||||
const auto entry = requests.find(requestID);
|
const auto entry = requests.find(requestID);
|
||||||
if (entry != requests.end()) {
|
if (entry != requests.end()) {
|
||||||
entry->second(mythranShift, zoneID, zoneInstance, zoneClone, serverIP.string, serverPort);
|
entry->second(mythranShift, zoneID, zoneInstance, zoneClone, serverIP.string, serverPort, stamps);
|
||||||
requests.erase(entry);
|
requests.erase(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +59,9 @@ void ZoneInstanceManager::RequestPrivateZone(
|
|||||||
const std::string& password,
|
const std::string& password,
|
||||||
TransferCallback callback) {
|
TransferCallback callback) {
|
||||||
const auto nextID = ++currentRequestID;
|
const auto nextID = ++currentRequestID;
|
||||||
requests[nextID] = callback;
|
requests[nextID] = [callback](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort, Stamps) {
|
||||||
|
callback(mythranShift, zoneID, zoneInstance, zoneClone, serverIP, serverPort);
|
||||||
|
};
|
||||||
|
|
||||||
MasterPackets::SendZoneRequestPrivate(server, nextID, mythranShift, password);
|
MasterPackets::SendZoneRequestPrivate(server, nextID, mythranShift, password);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
// RakNet
|
// RakNet
|
||||||
#include "RakNetTypes.h"
|
#include "RakNetTypes.h"
|
||||||
|
#include "Stamps.h"
|
||||||
|
|
||||||
class dServer;
|
class dServer;
|
||||||
|
|
||||||
@@ -21,7 +22,9 @@ private:
|
|||||||
static ZoneInstanceManager* m_Address; //!< The singleton instance
|
static ZoneInstanceManager* m_Address; //!< The singleton instance
|
||||||
|
|
||||||
using TransferCallback = std::function<void(bool, uint32_t, uint32_t, uint32_t, std::string, uint16_t)>;
|
using TransferCallback = std::function<void(bool, uint32_t, uint32_t, uint32_t, std::string, uint16_t)>;
|
||||||
std::map<uint64_t, TransferCallback> requests; //!< The zone transfer requests
|
// Also gets the login stamps that came back with the response (see Stamps.h)
|
||||||
|
using StampedTransferCallback = std::function<void(bool, uint32_t, uint32_t, uint32_t, std::string, uint16_t, Stamps)>;
|
||||||
|
std::map<uint64_t, StampedTransferCallback> requests; //!< The zone transfer requests
|
||||||
uint64_t currentRequestID; //!< The current request ID
|
uint64_t currentRequestID; //!< The current request ID
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -45,6 +48,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
void RequestZoneTransfer(dServer* server, uint32_t zoneID, uint32_t zoneClone, bool mythranShift, TransferCallback callback);
|
void RequestZoneTransfer(dServer* server, uint32_t zoneID, uint32_t zoneClone, bool mythranShift, TransferCallback callback);
|
||||||
|
|
||||||
|
//! Requests a zone transfer for a login: the stamps travel to master, which adds its own, and come back to the callback
|
||||||
|
void RequestZoneTransfer(dServer* server, uint32_t zoneID, uint32_t zoneClone, bool mythranShift, const Stamps& stamps, StampedTransferCallback callback);
|
||||||
|
|
||||||
//! Handles a zone transfer response
|
//! Handles a zone transfer response
|
||||||
/*!
|
/*!
|
||||||
\param requestID The request ID
|
\param requestID The request ID
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "ClientPackets.h"
|
#include "ClientPackets.h"
|
||||||
#include "CommonPackets.h"
|
#include "CommonPackets.h"
|
||||||
#include "GameDependencies.h"
|
#include "GameDependencies.h"
|
||||||
|
#include "MasterPackets.h"
|
||||||
#include "PacketTestUtils.h"
|
#include "PacketTestUtils.h"
|
||||||
#include "Legacy/CommonAuthPacketsLegacy.h"
|
#include "Legacy/CommonAuthPacketsLegacy.h"
|
||||||
|
|
||||||
@@ -430,3 +431,47 @@ TEST_F(CommonAuthPacketsTests, StampsRoundTrip) {
|
|||||||
Stamps rejected;
|
Stamps rejected;
|
||||||
EXPECT_FALSE(rejected.Deserialize(bad));
|
EXPECT_FALSE(rejected.Deserialize(bad));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(CommonAuthPacketsTests, ZoneTransferResponseCarriesStamps) {
|
||||||
|
Stamps stamps;
|
||||||
|
stamps.list = { Stamp(eStamps::PASSPORT_AUTH_START, 0, 10), Stamp(eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, 7, 11) };
|
||||||
|
const auto sent = Capture([&] { MasterPackets::SendZoneTransferResponse(Game::server, TestAddress(), 99, true, 1000, 7, 0, "127.0.0.1", 2001, stamps); });
|
||||||
|
ASSERT_EQ(sent.size(), 1);
|
||||||
|
|
||||||
|
RakNet::BitStream bitStream(const_cast<uint8_t*>(sent[0].bytes.data()), sent[0].bytes.size(), true);
|
||||||
|
LUBitStream header;
|
||||||
|
ASSERT_TRUE(header.ReadHeader(bitStream));
|
||||||
|
EXPECT_EQ(header.connectionType, ServiceType::MASTER);
|
||||||
|
uint64_t requestID{};
|
||||||
|
uint8_t mythranShift{};
|
||||||
|
uint32_t zoneID{};
|
||||||
|
uint32_t zoneInstance{};
|
||||||
|
uint32_t zoneClone{};
|
||||||
|
uint16_t port{};
|
||||||
|
LUString ip(255);
|
||||||
|
ASSERT_TRUE(bitStream.Read(requestID));
|
||||||
|
ASSERT_TRUE(bitStream.Read(mythranShift));
|
||||||
|
ASSERT_TRUE(bitStream.Read(zoneID));
|
||||||
|
ASSERT_TRUE(bitStream.Read(zoneInstance));
|
||||||
|
ASSERT_TRUE(bitStream.Read(zoneClone));
|
||||||
|
ASSERT_TRUE(bitStream.Read(port));
|
||||||
|
ASSERT_TRUE(bitStream.Read(ip));
|
||||||
|
EXPECT_EQ(requestID, 99);
|
||||||
|
EXPECT_EQ(port, 2001);
|
||||||
|
EXPECT_EQ(ip.string, "127.0.0.1");
|
||||||
|
|
||||||
|
Stamps copy;
|
||||||
|
ASSERT_TRUE(copy.Deserialize(bitStream));
|
||||||
|
EXPECT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
|
||||||
|
ASSERT_EQ(copy.size(), 2);
|
||||||
|
EXPECT_EQ(copy.list[1].type, eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH);
|
||||||
|
EXPECT_EQ(copy.list[1].value, 7);
|
||||||
|
EXPECT_EQ(copy.list[1].timestamp, 11);
|
||||||
|
|
||||||
|
// Without a login the list is empty: just its size field
|
||||||
|
const auto plain = Capture([&] { MasterPackets::SendZoneTransferResponse(Game::server, TestAddress(), 99, true, 1000, 7, 0, "127.0.0.1", 2001); });
|
||||||
|
ASSERT_EQ(plain.size(), 1);
|
||||||
|
EXPECT_EQ(plain[0].bytes.size() + 32, sent[0].bytes.size());
|
||||||
|
const std::vector<uint8_t> tail(plain[0].bytes.end() - 4, plain[0].bytes.end());
|
||||||
|
EXPECT_EQ(tail, (std::vector<uint8_t>{ 4, 0, 0, 0 }));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user