mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
4004534732
* Optionally compiled additional TCP transport layer. * Config to enable it. * Tested and functional with lcdr's tcpudp dll, udp being disabled in the dll due to port issues. * Removed unused RakNet replica manager and id manager. We've got our own replica manager since pre-open-source. * Utilizes async boost behavior. Todo: * Figure out how to do ping calculations. * Fix crashes on universe shutdown. * Test TLS on a VPS. * Remove unnecessary logging. * Test with lots of clients. * Finish "master" to "manager" naming refactor.
124 lines
4.1 KiB
C++
124 lines
4.1 KiB
C++
#include "MasterPackets.h"
|
|
#include "BitStream.h"
|
|
#include "dCommonVars.h"
|
|
#include "TransportLayer.h"
|
|
#include "eConnectionType.h"
|
|
#include "eManagerMessageType.h"
|
|
#include "BitStreamUtils.h"
|
|
|
|
#include <string>
|
|
|
|
void MasterPackets::SendPersistentIDRequest(TransportLayer* server, uint64_t requestID) {
|
|
CBITSTREAM;
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eManagerMessageType::REQUEST_PERSISTENT_ID);
|
|
bitStream.Write(requestID);
|
|
server->SendToManager(bitStream);
|
|
}
|
|
|
|
void MasterPackets::SendPersistentIDResponse(TransportLayer* server, const SystemAddress& sysAddr, uint64_t requestID, uint32_t objID) {
|
|
RakNet::BitStream bitStream;
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eManagerMessageType::REQUEST_PERSISTENT_ID_RESPONSE);
|
|
|
|
bitStream.Write(requestID);
|
|
bitStream.Write(objID);
|
|
|
|
server->Send(bitStream, sysAddr, false);
|
|
}
|
|
|
|
void MasterPackets::SendZoneTransferRequest(TransportLayer* server, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t cloneID) {
|
|
RakNet::BitStream bitStream;
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eManagerMessageType::REQUEST_ZONE_TRANSFER);
|
|
|
|
bitStream.Write(requestID);
|
|
bitStream.Write<uint8_t>(mythranShift);
|
|
bitStream.Write(zoneID);
|
|
bitStream.Write(cloneID);
|
|
|
|
server->SendToManager(bitStream);
|
|
}
|
|
|
|
void MasterPackets::SendZoneCreatePrivate(TransportLayer* server, uint32_t zoneID, uint32_t cloneID, const std::string& password) {
|
|
RakNet::BitStream bitStream;
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eManagerMessageType::CREATE_PRIVATE_ZONE);
|
|
|
|
bitStream.Write(zoneID);
|
|
bitStream.Write(cloneID);
|
|
|
|
bitStream.Write<uint32_t>(password.size());
|
|
for (auto character : password) {
|
|
bitStream.Write<char>(character);
|
|
}
|
|
|
|
server->SendToManager(bitStream);
|
|
}
|
|
|
|
void MasterPackets::SendZoneRequestPrivate(TransportLayer* server, uint64_t requestID, bool mythranShift, const std::string& password) {
|
|
RakNet::BitStream bitStream;
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eManagerMessageType::REQUEST_PRIVATE_ZONE);
|
|
|
|
bitStream.Write(requestID);
|
|
bitStream.Write<uint8_t>(mythranShift);
|
|
|
|
bitStream.Write<uint32_t>(password.size());
|
|
for (auto character : password) {
|
|
bitStream.Write<char>(character);
|
|
}
|
|
|
|
server->SendToManager(bitStream);
|
|
}
|
|
|
|
void MasterPackets::SendWorldReady(TransportLayer* server, LWOMAPID zoneId, LWOINSTANCEID instanceId) {
|
|
RakNet::BitStream bitStream;
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eManagerMessageType::WORLD_READY);
|
|
|
|
bitStream.Write(zoneId);
|
|
bitStream.Write(instanceId);
|
|
|
|
server->SendToManager(bitStream);
|
|
}
|
|
|
|
void MasterPackets::SendZoneTransferResponse(TransportLayer* 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) {
|
|
RakNet::BitStream bitStream;
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eManagerMessageType::REQUEST_ZONE_TRANSFER_RESPONSE);
|
|
|
|
bitStream.Write(requestID);
|
|
bitStream.Write<uint8_t>(mythranShift);
|
|
bitStream.Write(zoneID);
|
|
bitStream.Write(zoneInstance);
|
|
bitStream.Write(zoneClone);
|
|
bitStream.Write<uint16_t>(serverPort);
|
|
bitStream.Write(LUString(serverIP, 255));
|
|
|
|
server->Send(bitStream, sysAddr, false);
|
|
}
|
|
|
|
void MasterPackets::HandleServerInfo(Packet* packet) {
|
|
RakNet::BitStream inStream(packet->data, packet->length, false);
|
|
uint64_t header = inStream.Read(header);
|
|
|
|
uint32_t theirPort = 0;
|
|
uint32_t theirZoneID = 0;
|
|
uint32_t theirInstanceID = 0;
|
|
LUString theirIP;
|
|
|
|
inStream.Read(theirPort);
|
|
inStream.Read(theirZoneID);
|
|
inStream.Read(theirInstanceID);
|
|
inStream.Read(theirIP);
|
|
|
|
//TODO: Actually mark this server as an available server in the manager
|
|
}
|
|
|
|
void MasterPackets::SendServerInfo(TransportLayer* server, Packet* packet) {
|
|
RakNet::BitStream bitStream;
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eManagerMessageType::SERVER_INFO);
|
|
|
|
bitStream.Write(server->GetPort());
|
|
bitStream.Write(server->GetZoneID());
|
|
bitStream.Write(server->GetInstanceID());
|
|
bitStream.Write(server->GetServerType());
|
|
bitStream.Write(LUString(server->GetIP()));
|
|
|
|
server->SendToManager(bitStream);
|
|
}
|