mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-04-26 16:46:31 +00:00
33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
#include "BitStreamUtils.h"
|
|
#include "dServer.h"
|
|
#include "BitStream.h"
|
|
#include "PacketUtils.h"
|
|
|
|
|
|
void LUBitStream::WriteHeader(RakNet::BitStream& bitStream) const {
|
|
bitStream.Write<MessageID>(ID_USER_PACKET_ENUM);
|
|
bitStream.Write(this->connectionType);
|
|
bitStream.Write(this->internalPacketID);
|
|
bitStream.Write<uint8_t>(0); // padding
|
|
}
|
|
|
|
bool LUBitStream::ReadHeader(RakNet::BitStream& bitStream) {
|
|
MessageID messageID;
|
|
bitStream.Read(messageID);
|
|
if (messageID != ID_USER_PACKET_ENUM) return false;
|
|
VALIDATE_READ(bitStream.Read(this->connectionType));
|
|
VALIDATE_READ(bitStream.Read(this->internalPacketID));
|
|
uint8_t padding;
|
|
VALIDATE_READ(bitStream.Read<uint8_t>(padding));
|
|
return true;
|
|
}
|
|
|
|
void LUBitStream::Send(const SystemAddress& sysAddr) const {
|
|
RakNet::BitStream bitStream;
|
|
this->WriteHeader(bitStream);
|
|
this->Serialize(bitStream);
|
|
LOG("%s", sysAddr.ToString(true));
|
|
PacketUtils::SavePacket("mailv2", reinterpret_cast<const char *>(bitStream.GetData()), bitStream.GetNumberOfBytesUsed());
|
|
Game::server->Send(bitStream, sysAddr, sysAddr == UNASSIGNED_SYSTEM_ADDRESS);
|
|
}
|