all tested and working

This commit is contained in:
Aaron Kimbre
2025-01-20 00:42:28 -06:00
parent b01b3cc38d
commit a07d54e513
8 changed files with 138 additions and 169 deletions

View File

@@ -26,7 +26,5 @@ 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);
}

View File

@@ -3,33 +3,26 @@
#include "DluAssert.h"
void MailInfo::Serialize(RakNet::BitStream& bitStream) const {
LOG("Writing MailInfo");
LOG("ID: %llu", id);
bitStream.Write(id);
LOG("Subject: %s", subject.c_str());
const LUWString subject(this->subject, 50);
bitStream.Write(subject);
LOG("Body: %s", body.c_str());
const LUWString body(this->body, 400);
bitStream.Write(body);
LOG("Sender: %s", senderUsername.c_str());
const LUWString sender(this->senderUsername, 32);
bitStream.Write(sender);
bitStream.Write<uint32_t>(0); // packing
bitStream.Write<uint64_t>(0); // attachedCurrency
LOG("ItemID: %llu", itemID);
bitStream.Write(itemID);
LOT lot = itemLOT;
LOG("ItemLOT: %u", lot);
if (lot <= 0) bitStream.Write<LOT>(LOT_NULL);
else bitStream.Write(lot);
bitStream.Write<uint32_t>(0); // packing
bitStream.Write(itemSubkey);
bitStream.Write<uint16_t>(itemCount);
bitStream.Write(itemCount);
bitStream.Write<uint8_t>(0); // subject type (used for auction)
bitStream.Write<uint8_t>(0); // packing
bitStream.Write<uint32_t>(0); // packing
@@ -39,13 +32,11 @@ void MailInfo::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write<uint8_t>(wasRead); // was read
bitStream.Write<uint8_t>(0); // isLocalized
bitStream.Write<uint16_t>(0); // packing
bitStream.Write<uint16_t>(1033); // language code
bitStream.Write<uint32_t>(0); // packing
}
bool MailInfo::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(id));
LUWString subject(50);
VALIDATE_READ(bitStream.Read(subject));
this->subject = subject.GetAsString();
@@ -54,36 +45,17 @@ bool MailInfo::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(body));
this->body = body.GetAsString();
LUWString sender(32);
VALIDATE_READ(bitStream.Read(sender));
this->senderUsername = sender.GetAsString();
LUWString recipientName(32);
VALIDATE_READ(bitStream.Read(recipientName));
this->recipient = recipientName.GetAsString();
bitStream.IgnoreBytes(4); // packing
uint64_t unknown;
VALIDATE_READ(bitStream.Read(unknown));
bitStream.IgnoreBytes(8); // attachedCurrency
VALIDATE_READ(bitStream.Read(itemID));
LOT lot;
VALIDATE_READ(bitStream.Read(lot));
if (lot == LOT_NULL) itemLOT = 0;
else itemLOT = lot;
bitStream.IgnoreBytes(4); // packing
VALIDATE_READ(bitStream.Read(itemSubkey));
VALIDATE_READ(bitStream.Read(itemCount));
bitStream.IgnoreBytes(1); // subject type (used for auction)
bitStream.IgnoreBytes(1); // packing
bitStream.IgnoreBytes(4); // packing
VALIDATE_READ(bitStream.Read(timeSent)); // expiration date
VALIDATE_READ(bitStream.Read(timeSent)); // send date
VALIDATE_READ(bitStream.Read(wasRead)); // was read
bitStream.IgnoreBytes(1); // isLocalized
bitStream.IgnoreBytes(2); // packing
bitStream.IgnoreBytes(4); // packing
VALIDATE_READ(bitStream.Read(languageCode));
bitStream.IgnoreBytes(4); // padding
DluAssert(bitStream.GetNumberOfUnreadBits() == 0);

View File

@@ -19,9 +19,10 @@ struct MailInfo {
uint32_t receiverId{};
uint64_t timeSent{};
bool wasRead{};
uint16_t languageCode{};
struct {
LWOOBJID itemID{};
int32_t itemCount{};
int16_t itemCount{};
LOT itemLOT{};
LWOOBJID itemSubkey{};
};