mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
Every MASTER service packet is now an LUBitStream struct (docs/PacketArchitecture.md, PR 14) and the master server's switch is a dispatch map (PacketDispatcher), as are the master handlers of the world, chat and dashboard servers. - dNet/MasterPackets.h: RequestZoneTransfer, RequestZoneTransferResponse, ServerInfo, RequestSessionKey, SetSessionKey, SessionKeyResponse, NewSessionAlert, PlayerAdded / PlayerRemoved, CreatePrivateZone, RequestPrivateZone (passwords still cut to 50 characters when read), WorldReady, WorldReadyInfo (WORLD_READY to the dashboard), PrepZone, Shutdown, ShutdownResponse, WorldShutDown (SHUTDOWN_RESPONSE to the dashboard), ShutdownUniverse, AffirmTransferRequest/Response, RequestServerList, ServerListResponse, DashboardShutdown, ConfigReload, InstanceShutdown. The Send* functions are gone; MasterPackets::SendToMaster(msg) and SendTo(sysAddr, msg) send a struct. - The dashboard and instance migration structs (PlayerAction, DataChanged, Dashboard messages, MessageCapture, InstanceMigration) are LUBitStreams of the MASTER service now and moved to dNet/master/, included by MasterPackets.h. Their payloads are unchanged; master forwards them by re-serializing the struct instead of copying raw bytes. - InstanceManager, ZoneInstanceManager, MigrationCoordinator, dServer (server info, zone transfer response), auth (SET_SESSION_KEY), the world (session keys, player added and removed, world ready, shutdown response, affirmations, prep zone, shutdown universe) and the dashboard (server list, instance shutdown, config reload, announcements, player actions, message capture) send and read structs. - The login stamps are a `stamps` field of RequestZoneTransfer and RequestZoneTransferResponse (read leniently as before: a message without them reads as empty); master adds its stamps in the REQUEST_ZONE_TRANSFER handler and when it answers, as it did. - InstanceManager::GetInstanceBySysAddr takes a const address. Verified: tests/dGameTests/dNetTests/Legacy/MasterPacketsLegacy.h is a verbatim copy of the old writers and readers; MasterPacketsTests requires identical bytes for a grid of inputs, checks the old readers read what the structs write, round trips and truncation, hand written golden packets, that zone transfers without stamps still read, that the dashboard/migration structs write what "header + Serialize" wrote, and that the dispatcher drops truncated packets. No wire bytes changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.2 KiB
C++
69 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <map>
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
// RakNet
|
|
#include "RakNetTypes.h"
|
|
#include "Stamps.h"
|
|
|
|
class dServer;
|
|
|
|
namespace MasterPackets {
|
|
struct RequestZoneTransferResponse;
|
|
}
|
|
|
|
/*!
|
|
\file ZoneInstanceManager.hpp
|
|
\brief A class for handling zone transfers and zone-related functions
|
|
*/
|
|
|
|
//! The zone manager
|
|
class ZoneInstanceManager {
|
|
private:
|
|
static ZoneInstanceManager* m_Address; //!< The singleton instance
|
|
|
|
using TransferCallback = std::function<void(bool, uint32_t, uint32_t, uint32_t, std::string, uint16_t)>;
|
|
// 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
|
|
|
|
public:
|
|
|
|
//! The singleton method
|
|
static ZoneInstanceManager* Instance() {
|
|
if (m_Address == nullptr) {
|
|
m_Address = new ZoneInstanceManager;
|
|
m_Address->currentRequestID = 0;
|
|
}
|
|
|
|
return m_Address;
|
|
}
|
|
|
|
//! Requests a zone transfer
|
|
/*!
|
|
\param zoneID The zone ID
|
|
\param zoneClone The zone clone
|
|
\param mythranShift Whether or not this is a mythran shift
|
|
\param callback The callback function
|
|
*/
|
|
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
|
|
/*!
|
|
\param requestID The request ID
|
|
\param packet The packet
|
|
*/
|
|
void HandleRequestZoneTransferResponse(const MasterPackets::RequestZoneTransferResponse& response);
|
|
|
|
void CreatePrivateZone(dServer* server, uint32_t zoneID, uint32_t zoneClone, const std::string& password);
|
|
|
|
void RequestPrivateZone(dServer* server, bool mythranShift, const std::string& password, TransferCallback callback);
|
|
};
|