mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
First step of moving hand written bitstream code to struct based messages (see docs/PacketArchitecture.md). No wire changes. - GameMsg is now only a server-internal event (delivered to handlers registered with RegisterMsg); NetGameMsg is a wire message with Send(sysAddr) (UNASSIGNED broadcasts), SendToClient(sysAddr) (one client, never broadcasts), WritePacket, Serialize, Deserialize and Handle. Mixing them up is now a compile error. NetGameMsgEvent<T> / DeliverLocally carry a wire message to local handlers; loot drops, pickup, the object debugger, GM invisibility and model RequestUse use them. The GM invisibility message keeps its target, so its bytes are unchanged. - Behaviour change: GameMessageHandler logs and drops messages whose Deserialize fails instead of handling them with default fields (the 4 messages already registered: RequestUse, RequestServerObjectInfo, ShootingGalleryFire, PickupItem). - LUBitStream (kept as on main) gets a virtual destructor (Mail deleted derived packets through the base) and WritePacket, also used by ChatPackets::SendRoutedMsg with identical bytes. - BitStreamUtils::WriteOptional/ReadOptional for default-flag fields and WriteLengthPrefixed/ReadLengthPrefixed for length prefixed strings. - Every message ID enumerator (MessageType::*, ServiceType, Mail's wire enums) is pinned with static_asserts, so renumbering or removing one fails to compile. - Tests: dServerMock copies each sent packet (it kept a pointer to the caller's destroyed BitStream); PacketTestUtils.h compares packets bit for bit; helper tests use hand computed golden bytes and equality with the hand written patterns they replace; compile-time checks keep the wire/internal split in place. - docs/PacketArchitecture.md: survey, target architecture, conventions, verification method and migration plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
95 lines
6.2 KiB
C++
95 lines
6.2 KiB
C++
// GENERATED by a one-off script from the enum definitions at the time this file was added.
|
|
// Message IDs are sent on the wire and are append-only: never renumber, reuse or remove one.
|
|
// If one of these fails to compile, the change to the enum is wrong, not this file.
|
|
// New enumerators may be added freely; add a pin for them here too.
|
|
|
|
#include "Mail.h"
|
|
#include <cstdint>
|
|
#include <gtest/gtest.h>
|
|
|
|
// Mail::eMessageID: 21 enumerators
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::SendRequest) == 0);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::SendResponse) == 1);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::NotificationResponse) == 2);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::DataRequest) == 3);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::DataResponse) == 4);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::AttachmentCollectRequest) == 5);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::AttachmentCollectResponse) == 6);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::DeleteRequest) == 7);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::DeleteResponse) == 8);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::ReadRequest) == 9);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::ReadResponse) == 10);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::NotificationRequest) == 11);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::AuctionCreate) == 12);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::AuctionCreationResponse) == 13);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::AuctionCancel) == 14);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::AuctionCancelResponse) == 15);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::AuctionList) == 16);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::AuctionListResponse) == 17);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::AuctionBid) == 18);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::AuctionBidResponse) == 19);
|
|
static_assert(static_cast<int64_t>(Mail::eMessageID::UnknownError) == 20);
|
|
|
|
// Mail::eSendResponse: 15 enumerators
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::Success) == 0);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::NotEnoughCoins) == 1);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::AttachmentNotFound) == 2);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::ItemCannotBeMailed) == 3);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::CannotMailSelf) == 4);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::RecipientNotFound) == 5);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::RecipientDifferentFaction) == 6);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::UnHandled7) == 7);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::ModerationFailure) == 8);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::SenderAccountIsMuted) == 9);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::UnHandled10) == 10);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::RecipientIsIgnored) == 11);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::UnHandled12) == 12);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::RecipientIsFTP) == 13);
|
|
static_assert(static_cast<int64_t>(Mail::eSendResponse::UnknownError) == 14);
|
|
|
|
// Mail::eDeleteResponse: 5 enumerators
|
|
static_assert(static_cast<int64_t>(Mail::eDeleteResponse::Success) == 0);
|
|
static_assert(static_cast<int64_t>(Mail::eDeleteResponse::HasAttachments) == 1);
|
|
static_assert(static_cast<int64_t>(Mail::eDeleteResponse::NotFound) == 2);
|
|
static_assert(static_cast<int64_t>(Mail::eDeleteResponse::Throttled) == 3);
|
|
static_assert(static_cast<int64_t>(Mail::eDeleteResponse::UnknownError) == 4);
|
|
|
|
// Mail::eAttachmentCollectResponse: 6 enumerators
|
|
static_assert(static_cast<int64_t>(Mail::eAttachmentCollectResponse::Success) == 0);
|
|
static_assert(static_cast<int64_t>(Mail::eAttachmentCollectResponse::AttachmentNotFound) == 1);
|
|
static_assert(static_cast<int64_t>(Mail::eAttachmentCollectResponse::NoSpaceInInventory) == 2);
|
|
static_assert(static_cast<int64_t>(Mail::eAttachmentCollectResponse::MailNotFound) == 3);
|
|
static_assert(static_cast<int64_t>(Mail::eAttachmentCollectResponse::Throttled) == 4);
|
|
static_assert(static_cast<int64_t>(Mail::eAttachmentCollectResponse::UnknownError) == 5);
|
|
|
|
// Mail::eNotificationResponse: 9 enumerators
|
|
static_assert(static_cast<int64_t>(Mail::eNotificationResponse::NewMail) == 0);
|
|
static_assert(static_cast<int64_t>(Mail::eNotificationResponse::UnHandled) == 1);
|
|
static_assert(static_cast<int64_t>(Mail::eNotificationResponse::AuctionWon) == 2);
|
|
static_assert(static_cast<int64_t>(Mail::eNotificationResponse::AuctionSold) == 3);
|
|
static_assert(static_cast<int64_t>(Mail::eNotificationResponse::AuctionOutbided) == 4);
|
|
static_assert(static_cast<int64_t>(Mail::eNotificationResponse::AuctionExpired) == 5);
|
|
static_assert(static_cast<int64_t>(Mail::eNotificationResponse::AuctionCancelled) == 6);
|
|
static_assert(static_cast<int64_t>(Mail::eNotificationResponse::AuctionUpdated) == 7);
|
|
static_assert(static_cast<int64_t>(Mail::eNotificationResponse::UnknownError) == 8);
|
|
|
|
// Mail::eReadResponse: 2 enumerators
|
|
static_assert(static_cast<int64_t>(Mail::eReadResponse::Success) == 0);
|
|
static_assert(static_cast<int64_t>(Mail::eReadResponse::UnknownError) == 1);
|
|
|
|
// Mail::eAuctionCreateResponse: 5 enumerators
|
|
static_assert(static_cast<int64_t>(Mail::eAuctionCreateResponse::Success) == 0);
|
|
static_assert(static_cast<int64_t>(Mail::eAuctionCreateResponse::NotEnoughMoney) == 1);
|
|
static_assert(static_cast<int64_t>(Mail::eAuctionCreateResponse::ItemNotFound) == 2);
|
|
static_assert(static_cast<int64_t>(Mail::eAuctionCreateResponse::ItemNotSellable) == 3);
|
|
static_assert(static_cast<int64_t>(Mail::eAuctionCreateResponse::UnknownError) == 4);
|
|
|
|
// Mail::eAuctionCancelResponse: 5 enumerators
|
|
static_assert(static_cast<int64_t>(Mail::eAuctionCancelResponse::NotFound) == 0);
|
|
static_assert(static_cast<int64_t>(Mail::eAuctionCancelResponse::NotYours) == 1);
|
|
static_assert(static_cast<int64_t>(Mail::eAuctionCancelResponse::HasBid) == 2);
|
|
static_assert(static_cast<int64_t>(Mail::eAuctionCancelResponse::NoLongerExists) == 3);
|
|
static_assert(static_cast<int64_t>(Mail::eAuctionCancelResponse::UnknownError) == 4);
|
|
|
|
TEST(MailIdPinTests, MailEnumValuesArePinned) { SUCCEED(); }
|