From 78e52904e5c943fdead6fe35ece6e853600a9639 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sat, 1 Feb 2025 01:51:46 -0600 Subject: [PATCH] address feedback --- dGame/dUtilities/Mail.cpp | 19 +++++++++++-------- dGame/dUtilities/Mail.h | 13 +++---------- .../SlashCommands/GMZeroCommands.cpp | 5 ++++- dNet/MailInfo.cpp | 2 +- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/dGame/dUtilities/Mail.cpp b/dGame/dUtilities/Mail.cpp index 836628c6..43be2fa3 100644 --- a/dGame/dUtilities/Mail.cpp +++ b/dGame/dUtilities/Mail.cpp @@ -70,7 +70,7 @@ namespace Mail { } void SendRequest::Handle() { - SendResponse response(eSendResponse::UnknownError); + SendResponse response; auto* character = player->GetCharacter(); if (character && !(character->HasPermission(ePermissionMap::RestrictedMailAccess) || character->GetParentUser()->GetIsMuted())) { mailInfo.recipient = std::regex_replace(mailInfo.recipient, std::regex("[^0-9a-zA-Z]+"), ""); @@ -178,7 +178,7 @@ namespace Mail { } void AttachmentCollectRequest::Handle() { - auto response = AttachmentCollectResponse(eAttachmentCollectResponse::UnknownError); + AttachmentCollectResponse response; auto inv = player->GetComponent(); if (mailID > 0 && playerID == player->GetObjectID() && inv) { @@ -211,8 +211,9 @@ namespace Mail { } void DeleteRequest::Handle() { - auto response = DeleteResponse(mailID); - + DeleteResponse response; + response.mailID = mailID; + auto mailData = Database::Get()->GetMail(mailID); if (mailData && !(mailData->itemLOT != 0 && mailData->itemCount > 0)) { Database::Get()->DeleteMail(mailID); @@ -239,7 +240,8 @@ namespace Mail { } void ReadRequest::Handle() { - auto response = ReadResponse(mailID); + ReadResponse response; + response.mailID = mailID; if (Database::Get()->GetMail(mailID)) { response.status = eReadResponse::Success; @@ -255,7 +257,7 @@ namespace Mail { } void NotificationRequest::Handle() { - auto response = NotificationResponse(eNotificationResponse::UnknownError); + NotificationResponse response; auto character = player->GetCharacter(); if (character) { auto unreadMailCount = Database::Get()->GetUnreadMailCount(character->GetID()); @@ -352,6 +354,7 @@ void Mail::SendMail(const LWOOBJID sender, const std::string& senderName, LWOOBJ Database::Get()->InsertNewMail(mailInsert); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) return; // TODO: Echo to chat server - - NotificationResponse(eNotificationResponse::NewMail).Send(sysAddr); + NotificationResponse response; + response.status = eNotificationResponse::NewMail; + response.Send(sysAddr); } diff --git a/dGame/dUtilities/Mail.h b/dGame/dUtilities/Mail.h index 2ca5d3b9..f4273543 100644 --- a/dGame/dUtilities/Mail.h +++ b/dGame/dUtilities/Mail.h @@ -125,8 +125,6 @@ namespace Mail { struct SendResponse :public MailLUBitStream { eSendResponse status = eSendResponse::UnknownError; - - SendResponse(eSendResponse _status) : MailLUBitStream(eMessageID::SendResponse), status{_status} {}; void Serialize(RakNet::BitStream& bitStream) const override; }; @@ -134,8 +132,7 @@ namespace Mail { eNotificationResponse status = eNotificationResponse::UnknownError; LWOOBJID auctionID = LWOOBJID_EMPTY; uint32_t mailCount = 1; - NotificationResponse(eNotificationResponse _status) : MailLUBitStream(eMessageID::NotificationResponse), status{_status} {}; - NotificationResponse(eNotificationResponse _status, uint32_t _mailCount) : MailLUBitStream(eMessageID::NotificationResponse), status{_status}, mailCount{_mailCount} {}; + NotificationResponse() : MailLUBitStream(eMessageID::NotificationResponse) {}; void Serialize(RakNet::BitStream& bitStream) const override; }; @@ -165,8 +162,7 @@ namespace Mail { struct AttachmentCollectResponse : public MailLUBitStream { eAttachmentCollectResponse status = eAttachmentCollectResponse::UnknownError; uint64_t mailID = 0; - AttachmentCollectResponse(eAttachmentCollectResponse _status) : MailLUBitStream(eMessageID::AttachmentCollectResponse), status{_status} {}; - AttachmentCollectResponse(eAttachmentCollectResponse _status, uint64_t _mailID) : MailLUBitStream(eMessageID::AttachmentCollectResponse), status{_status}, mailID{_mailID} {}; + AttachmentCollectResponse() : MailLUBitStream(eMessageID::AttachmentCollectResponse) {}; void Serialize(RakNet::BitStream& bitStream) const override; }; @@ -174,7 +170,6 @@ namespace Mail { uint64_t mailID = 0; LWOOBJID playerID = LWOOBJID_EMPTY; - DeleteRequest() : MailLUBitStream(eMessageID::DeleteRequest) {}; bool Deserialize(RakNet::BitStream& bitStream) override; void Handle() override; @@ -183,8 +178,7 @@ namespace Mail { struct DeleteResponse : public MailLUBitStream { eDeleteResponse status = eDeleteResponse::UnknownError; uint64_t mailID = 0; - DeleteResponse(uint64_t _mailID) : MailLUBitStream(eMessageID::DeleteResponse), mailID{_mailID} {}; - DeleteResponse(eDeleteResponse _status, uint64_t _mailID) : MailLUBitStream(eMessageID::DeleteResponse), status{_status}, mailID{_mailID} {}; + DeleteResponse() : MailLUBitStream(eMessageID::DeleteResponse) {}; void Serialize(RakNet::BitStream& bitStream) const override; }; @@ -201,7 +195,6 @@ namespace Mail { eReadResponse status = eReadResponse::UnknownError; ReadResponse() : MailLUBitStream(eMessageID::ReadResponse) {}; - ReadResponse(uint64_t _mailID) : MailLUBitStream(eMessageID::ReadResponse), mailID{_mailID} {}; void Serialize(RakNet::BitStream& bitStream) const override; }; diff --git a/dGame/dUtilities/SlashCommands/GMZeroCommands.cpp b/dGame/dUtilities/SlashCommands/GMZeroCommands.cpp index 6b9e6201..f80f3280 100644 --- a/dGame/dUtilities/SlashCommands/GMZeroCommands.cpp +++ b/dGame/dUtilities/SlashCommands/GMZeroCommands.cpp @@ -217,7 +217,10 @@ namespace GMZeroCommands { } void RequestMailCount(Entity* entity, const SystemAddress& sysAddr, const std::string args) { - Mail::NotificationResponse(Mail::eNotificationResponse::NewMail, Database::Get()->GetUnreadMailCount(entity->GetCharacter()->GetID())).Send(sysAddr); + Mail::NotificationResponse response; + response.status = Mail::eNotificationResponse::NewMail; + response.mailCount = Database::Get()->GetUnreadMailCount(entity->GetCharacter()->GetID()); + response.Send(sysAddr); } void InstanceInfo(Entity* entity, const SystemAddress& sysAddr, const std::string args) { diff --git a/dNet/MailInfo.cpp b/dNet/MailInfo.cpp index 335b4643..1556fc06 100644 --- a/dNet/MailInfo.cpp +++ b/dNet/MailInfo.cpp @@ -60,4 +60,4 @@ bool MailInfo::Deserialize(RakNet::BitStream& bitStream) { DluAssert(bitStream.GetNumberOfUnreadBits() == 0); return true; -} \ No newline at end of file +}