mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 19:03:43 +00:00
Converts the vendor, donation vendor and trade game messages to
NetGameMsgs in VendorMessages.{h,cpp} and TradeMessages.{h,cpp}:
VendorOpenWindow and VendorTransactionResult (SendToClient: the old
functions never broadcast), VendorStatusUpdate, ServerTradeInvite,
ServerTradeInitialReply, ServerTradeFinalReply, ServerTradeAccept,
ServerTradeCancel and ServerTradeUpdate, and the received
RequestVendorStatusUpdate, BuyFromVendor, SellToVendor,
BuybackFromVendor, AddDonationItem, RemoveDonationItem,
ConfirmDonationOnPlayer, CancelDonationOnPlayer, ClientTradeRequest,
ClientTradeCancel, ClientTradeAccept and ClientTradeUpdate. A trade
offer entry (the client's inventory item layout, optional fields and
config block included) is TradeItemEntry, shared by both trade updates.
Selling and buying back move into VendorComponent (SellToVendor,
BuybackFromVendor), adding and confirming donations into
DonationVendorComponent, and VendorComponent builds its own status
update and transaction results. Only the VENDOR component sends its
stock, as before. The received messages are registered in
GameMessageHandler's map, the switch cases and the old functions are
deleted. Handler logic is unchanged.
No wire change and no change in recipients. Verified byte for byte
against a frozen verbatim copy of the old functions over an input grid
(to one client and broadcast), received messages compared with the old
handlers' read sequences (every optional field of a trade entry,
raw and compressed config blocks) and truncated payloads rejected, hand
computed golden bytes, round trips, and a deliberate width mutation made
the tests fail. ConfirmDonationOnPlayer still accepts a message without
its vendor ID, since the old handler read nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#ifndef __DONATIONVENDORCOMPONENT__H__
|
|
#define __DONATIONVENDORCOMPONENT__H__
|
|
|
|
#include "VendorComponent.h"
|
|
#include "eReplicaComponentType.h"
|
|
|
|
class Entity;
|
|
|
|
class DonationVendorComponent final : public VendorComponent {
|
|
public:
|
|
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::DONATION_VENDOR;
|
|
DonationVendorComponent(Entity* parent, const int32_t componentID);
|
|
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
|
uint32_t GetActivityID() {return m_ActivityId;};
|
|
void SubmitDonation(uint32_t count);
|
|
|
|
// AddDonationItem from the player at sysAddr: moves count of the item into their donation inventory.
|
|
void AddDonationItem(const SystemAddress& sysAddr, LWOOBJID itemObjID, uint32_t count);
|
|
|
|
// ConfirmDonationOnPlayer: the player donates everything in their donation inventory to this vendor.
|
|
void ConfirmDonation(Entity& player);
|
|
|
|
private:
|
|
bool m_DirtyDonationVendor = false;
|
|
float m_PercentComplete = 0.0;
|
|
int32_t m_TotalDonated = 0;
|
|
int32_t m_TotalRemaining = 0;
|
|
uint32_t m_ActivityId = 0;
|
|
int32_t m_Goal = 0;
|
|
};
|
|
|
|
|
|
#endif //!__DONATIONVENDORCOMPONENT__H__
|