mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
chore: cleanup LU(W)string writing (#1188)
* chore: cleanup LU(W)string writing and add methods for reading remove redunent "packet" from packet reading helpers move write header to bitstreamutils since it's not packet related add tests for reading/writing LU(W)Strings * remove un-needed function defintions in header * make reading and writing more efficient * p p * quotes * remove unneeded default --------- Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
This commit is contained in:
@@ -5,19 +5,20 @@
|
||||
#include "dServer.h"
|
||||
#include "eConnectionType.h"
|
||||
#include "eMasterMessageType.h"
|
||||
#include "BitStreamUtils.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
void MasterPackets::SendPersistentIDRequest(dServer* server, uint64_t requestID) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_PERSISTENT_ID);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_PERSISTENT_ID);
|
||||
bitStream.Write(requestID);
|
||||
server->SendToMaster(&bitStream);
|
||||
}
|
||||
|
||||
void MasterPackets::SendPersistentIDResponse(dServer* server, const SystemAddress& sysAddr, uint64_t requestID, uint32_t objID) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_PERSISTENT_ID_RESPONSE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_PERSISTENT_ID_RESPONSE);
|
||||
|
||||
bitStream.Write(requestID);
|
||||
bitStream.Write(objID);
|
||||
@@ -27,7 +28,7 @@ void MasterPackets::SendPersistentIDResponse(dServer* server, const SystemAddres
|
||||
|
||||
void MasterPackets::SendZoneTransferRequest(dServer* server, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t cloneID) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_ZONE_TRANSFER);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_ZONE_TRANSFER);
|
||||
|
||||
bitStream.Write(requestID);
|
||||
bitStream.Write(static_cast<uint8_t>(mythranShift));
|
||||
@@ -39,7 +40,7 @@ void MasterPackets::SendZoneTransferRequest(dServer* server, uint64_t requestID,
|
||||
|
||||
void MasterPackets::SendZoneCreatePrivate(dServer* server, uint32_t zoneID, uint32_t cloneID, const std::string& password) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::CREATE_PRIVATE_ZONE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::CREATE_PRIVATE_ZONE);
|
||||
|
||||
bitStream.Write(zoneID);
|
||||
bitStream.Write(cloneID);
|
||||
@@ -54,7 +55,7 @@ void MasterPackets::SendZoneCreatePrivate(dServer* server, uint32_t zoneID, uint
|
||||
|
||||
void MasterPackets::SendZoneRequestPrivate(dServer* server, uint64_t requestID, bool mythranShift, const std::string& password) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_PRIVATE_ZONE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_PRIVATE_ZONE);
|
||||
|
||||
bitStream.Write(requestID);
|
||||
bitStream.Write(static_cast<uint8_t>(mythranShift));
|
||||
@@ -69,7 +70,7 @@ void MasterPackets::SendZoneRequestPrivate(dServer* server, uint64_t requestID,
|
||||
|
||||
void MasterPackets::SendWorldReady(dServer* server, LWOMAPID zoneId, LWOINSTANCEID instanceId) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::WORLD_READY);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::WORLD_READY);
|
||||
|
||||
bitStream.Write(zoneId);
|
||||
bitStream.Write(instanceId);
|
||||
@@ -79,7 +80,7 @@ void MasterPackets::SendWorldReady(dServer* server, LWOMAPID zoneId, LWOINSTANCE
|
||||
|
||||
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) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_ZONE_TRANSFER_RESPONSE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_ZONE_TRANSFER_RESPONSE);
|
||||
|
||||
bitStream.Write(requestID);
|
||||
bitStream.Write(static_cast<uint8_t>(mythranShift));
|
||||
@@ -87,7 +88,7 @@ void MasterPackets::SendZoneTransferResponse(dServer* server, const SystemAddres
|
||||
bitStream.Write(zoneInstance);
|
||||
bitStream.Write(zoneClone);
|
||||
bitStream.Write(static_cast<uint16_t>(serverPort));
|
||||
PacketUtils::WriteString(bitStream, serverIP, static_cast<uint32_t>(serverIP.size() + 1));
|
||||
bitStream.Write(LUString(serverIP, static_cast<uint32_t>(serverIP.size() + 1)));
|
||||
|
||||
server->Send(&bitStream, sysAddr, false);
|
||||
}
|
||||
@@ -111,13 +112,13 @@ void MasterPackets::HandleServerInfo(Packet* packet) {
|
||||
|
||||
void MasterPackets::SendServerInfo(dServer* server, Packet* packet) {
|
||||
RakNet::BitStream bitStream;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SERVER_INFO);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SERVER_INFO);
|
||||
|
||||
bitStream.Write(server->GetPort());
|
||||
bitStream.Write(server->GetZoneID());
|
||||
bitStream.Write(server->GetInstanceID());
|
||||
bitStream.Write(server->GetServerType());
|
||||
PacketUtils::WriteString(bitStream, server->GetIP(), server->GetIP().size());
|
||||
bitStream.Write(LUString(server->GetIP(), server->GetIP().size()));
|
||||
|
||||
server->SendToMaster(&bitStream);
|
||||
}
|
||||
|
Reference in New Issue
Block a user