2021-12-05 17:54:36 +00:00
|
|
|
#include "MasterPackets.h"
|
|
|
|
#include "BitStream.h"
|
|
|
|
#include "dCommonVars.h"
|
|
|
|
#include "dServer.h"
|
2023-05-03 21:38:32 +00:00
|
|
|
#include "eConnectionType.h"
|
2024-11-18 00:39:44 +00:00
|
|
|
#include "MessageType/Master.h"
|
2023-09-21 01:06:28 +00:00
|
|
|
#include "BitStreamUtils.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
void MasterPackets::SendPersistentIDRequest(dServer* server, uint64_t requestID) {
|
2022-08-05 13:40:12 +00:00
|
|
|
CBITSTREAM;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::REQUEST_PERSISTENT_ID);
|
2022-07-28 13:39:57 +00:00
|
|
|
bitStream.Write(requestID);
|
2024-02-27 05:43:33 +00:00
|
|
|
server->SendToMaster(bitStream);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MasterPackets::SendPersistentIDResponse(dServer* server, const SystemAddress& sysAddr, uint64_t requestID, uint32_t objID) {
|
|
|
|
RakNet::BitStream bitStream;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::REQUEST_PERSISTENT_ID_RESPONSE);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
bitStream.Write(requestID);
|
|
|
|
bitStream.Write(objID);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2024-02-27 05:43:33 +00:00
|
|
|
server->Send(bitStream, sysAddr, false);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MasterPackets::SendZoneTransferRequest(dServer* server, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t cloneID) {
|
|
|
|
RakNet::BitStream bitStream;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::REQUEST_ZONE_TRANSFER);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
bitStream.Write(requestID);
|
2023-12-24 00:11:00 +00:00
|
|
|
bitStream.Write<uint8_t>(mythranShift);
|
2022-07-28 13:39:57 +00:00
|
|
|
bitStream.Write(zoneID);
|
|
|
|
bitStream.Write(cloneID);
|
|
|
|
|
2024-02-27 05:43:33 +00:00
|
|
|
server->SendToMaster(bitStream);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MasterPackets::SendZoneCreatePrivate(dServer* server, uint32_t zoneID, uint32_t cloneID, const std::string& password) {
|
|
|
|
RakNet::BitStream bitStream;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::CREATE_PRIVATE_ZONE);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
bitStream.Write(zoneID);
|
|
|
|
bitStream.Write(cloneID);
|
|
|
|
|
2022-07-17 03:40:46 +00:00
|
|
|
bitStream.Write<uint32_t>(password.size());
|
|
|
|
for (auto character : password) {
|
|
|
|
bitStream.Write<char>(character);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2024-02-27 05:43:33 +00:00
|
|
|
server->SendToMaster(bitStream);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MasterPackets::SendZoneRequestPrivate(dServer* server, uint64_t requestID, bool mythranShift, const std::string& password) {
|
|
|
|
RakNet::BitStream bitStream;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::REQUEST_PRIVATE_ZONE);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
bitStream.Write(requestID);
|
2023-12-24 00:11:00 +00:00
|
|
|
bitStream.Write<uint8_t>(mythranShift);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-17 03:40:46 +00:00
|
|
|
bitStream.Write<uint32_t>(password.size());
|
|
|
|
for (auto character : password) {
|
|
|
|
bitStream.Write<char>(character);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2024-02-27 05:43:33 +00:00
|
|
|
server->SendToMaster(bitStream);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void MasterPackets::SendWorldReady(dServer* server, LWOMAPID zoneId, LWOINSTANCEID instanceId) {
|
2021-12-05 17:54:36 +00:00
|
|
|
RakNet::BitStream bitStream;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::WORLD_READY);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
bitStream.Write(zoneId);
|
|
|
|
bitStream.Write(instanceId);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2024-02-27 05:43:33 +00:00
|
|
|
server->SendToMaster(bitStream);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2022-07-28 13:39:57 +00:00
|
|
|
RakNet::BitStream bitStream;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::REQUEST_ZONE_TRANSFER_RESPONSE);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
bitStream.Write(requestID);
|
2023-12-24 00:11:00 +00:00
|
|
|
bitStream.Write<uint8_t>(mythranShift);
|
2022-07-28 13:39:57 +00:00
|
|
|
bitStream.Write(zoneID);
|
|
|
|
bitStream.Write(zoneInstance);
|
|
|
|
bitStream.Write(zoneClone);
|
2023-12-24 00:11:00 +00:00
|
|
|
bitStream.Write<uint16_t>(serverPort);
|
2024-01-07 08:02:27 +00:00
|
|
|
bitStream.Write(LUString(serverIP, 255));
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2024-02-27 05:43:33 +00:00
|
|
|
server->Send(bitStream, sysAddr, false);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MasterPackets::HandleServerInfo(Packet* packet) {
|
|
|
|
RakNet::BitStream inStream(packet->data, packet->length, false);
|
|
|
|
uint64_t header = inStream.Read(header);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
uint32_t theirPort = 0;
|
|
|
|
uint32_t theirZoneID = 0;
|
|
|
|
uint32_t theirInstanceID = 0;
|
2024-01-12 20:23:44 +00:00
|
|
|
LUString theirIP;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
inStream.Read(theirPort);
|
|
|
|
inStream.Read(theirZoneID);
|
|
|
|
inStream.Read(theirInstanceID);
|
2024-01-07 08:02:27 +00:00
|
|
|
inStream.Read(theirIP);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
//TODO: Actually mark this server as an available server in the manager
|
|
|
|
}
|
|
|
|
|
|
|
|
void MasterPackets::SendServerInfo(dServer* server, Packet* packet) {
|
|
|
|
RakNet::BitStream bitStream;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, MessageType::Master::SERVER_INFO);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
bitStream.Write(server->GetPort());
|
|
|
|
bitStream.Write(server->GetZoneID());
|
|
|
|
bitStream.Write(server->GetInstanceID());
|
|
|
|
bitStream.Write(server->GetServerType());
|
2024-01-07 08:02:27 +00:00
|
|
|
bitStream.Write(LUString(server->GetIP()));
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2024-02-27 05:43:33 +00:00
|
|
|
server->SendToMaster(bitStream);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|