mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
refactor: inventory and item game messages as structs
Converts AddItemToInventoryClientSync, SetInventorySize,
RemoveItemFromInventory, ConsumeClientItem, UseItemResult,
UseItemRequirementsResponse, ResponseMoveItemBetweenInventoryTypes,
NotifyNotEnoughInvSpace, UpdateInventoryUi, MarkInventoryItemAsActive and
MoveInventoryBatch (11 old Send functions) and the received EquipInventory,
UnEquipInventory, RemoveItemFromInventory, MoveItemInInventory,
MoveItemBetweenInventoryTypes, RequestMoveItemBetweenInventoryTypes,
PushEquippedItemsState, PopEquippedItemsState, ClientItemConsumed,
UseNonEquipmentItem, SetConsumableItem, UpdateInventoryGroup and
UpdateInventoryGroupContents (13 handlers) to NetGameMsgs in
InventoryMessages.{h,cpp}. The received messages are registered in
GameMessageHandler's map and handled by InventoryComponent (new On* methods
holding the old handler logic verbatim); the old functions and switch cases
are deleted. AddItemToInventoryClientSync::SetItem fills the fields that
come from the Item.
No wire change and no change in recipients. Kept as DLU has always sent them
and documented: NotifyNotEnoughInvSpace goes out with the message ID of
VehicleNotifyFinishedRace, and RemoveItemFromInventory always sets the flag
of the fields DLU fills. The old SendMoveInventoryBatch was never called
and wrote one flag bit fewer than the client reads (it had no moveSubkey);
the struct follows the client's layout (1.10.64,
LWOInventoryComponent_Common::msgMoveInventoryBatch at 00ce1310) and has no
oracle. UnEquipInventory still ignores the trailing replacementObjectID the
client sends, as before.
Verified byte for byte against a frozen verbatim copy of the old functions
over an input grid (AddItemToInventoryClientSync with real Items, extra info
and bind flags), to one client and broadcast; received messages compared
with the old handlers' read sequences and every truncated payload rejected;
hand computed golden bytes; round trips; a deliberate width mutation made
the tests fail.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -146,7 +146,6 @@ namespace GameMessages {
|
||||
void SendGMLevelBroadcast(const LWOOBJID& objectID, eGameMasterLevel level);
|
||||
void SendChatModeUpdate(const LWOOBJID& objectID, eGameMasterLevel level);
|
||||
|
||||
void SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey = LWOOBJID_EMPTY, eLootSourceType lootSourceType = eLootSourceType::NONE);
|
||||
void SendChangeObjectWorldState(const LWOOBJID& objectID, eObjectWorldState state, const SystemAddress& sysAddr);
|
||||
|
||||
void SendModifyLEGOScore(Entity* entity, const SystemAddress& sysAddr, int64_t score, eLootSourceType sourceType);
|
||||
@@ -161,8 +160,6 @@ namespace GameMessages {
|
||||
void SendDieNoImplCode(Entity* entity, const LWOOBJID& killerID, const LWOOBJID& lootOwnerID, eKillType killType, std::u16string deathType, float directionRelative_AngleY, float directionRelative_AngleXZ, float directionRelative_Force, bool bClientDeath, bool bSpawnLoot);
|
||||
void SendDie(Entity* entity, const LWOOBJID& killerID, const LWOOBJID& lootOwnerID, bool bDieAccepted, eKillType killType, std::u16string deathType, float directionRelative_AngleY, float directionRelative_AngleXZ, float directionRelative_Force, bool bClientDeath, bool bSpawnLoot, float coinSpawnTime);
|
||||
|
||||
void SendSetInventorySize(Entity* entity, int invType, int size);
|
||||
|
||||
void SendSetGravityScale(const LWOOBJID& target, const float effectScale, const SystemAddress& sysAddr);
|
||||
|
||||
void SendSetJetPackMode(Entity* entity, bool use, bool bypassChecks = false, bool doHover = false, int effectID = -1, float airspeed = 10, float maxAirspeed = 15, float verticalVelocity = 1, int warningEffectID = -1);
|
||||
@@ -179,11 +176,6 @@ namespace GameMessages {
|
||||
void SendVendorStatusUpdate(Entity* entity, const SystemAddress& sysAddr, bool bUpdateOnly = false);
|
||||
void SendVendorTransactionResult(Entity* entity, const SystemAddress& sysAddr, eVendorTransactionResult result);
|
||||
|
||||
void SendRemoveItemFromInventory(Entity* entity, const SystemAddress& sysAddr, LWOOBJID iObjID, LOT templateID, int inventoryType, uint32_t stackCount, uint32_t stackRemaining);
|
||||
void SendConsumeClientItem(Entity* entity, bool bSuccess, LWOOBJID item);
|
||||
void SendUseItemResult(Entity* entity, LOT templateID, bool useItemResult);
|
||||
void SendMoveInventoryBatch(Entity* entity, uint32_t stackCount, int srcInv, int dstInv, const LWOOBJID& iObjID);
|
||||
|
||||
void SendMatchResponse(Entity* entity, const SystemAddress& sysAddr, int response);
|
||||
void SendMatchUpdate(Entity* entity, const SystemAddress& sysAddr, std::string data, eMatchUpdate type);
|
||||
|
||||
@@ -240,8 +232,6 @@ namespace GameMessages {
|
||||
|
||||
void SendLockNodeRotation(Entity* entity, std::string nodeName);
|
||||
|
||||
void HandleSetConsumableItem(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
void SendSetStunned(LWOOBJID objectId, eStateChangeType stateChangeType, const SystemAddress& sysAddr,
|
||||
LWOOBJID originator = LWOOBJID_EMPTY, bool bCantAttack = false, bool bCantEquip = false,
|
||||
bool bCantInteract = false, bool bCantJump = false, bool bCantMove = false, bool bCantTurn = false,
|
||||
@@ -314,13 +304,9 @@ namespace GameMessages {
|
||||
void HandleClientTradeUpdate(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
//Pets:
|
||||
void SendMarkInventoryItemAsActive(LWOOBJID objectId, bool bActive, eUnequippableActiveType iType, LWOOBJID itemID, const SystemAddress& sysAddr);
|
||||
|
||||
void SendDisplayZoneSummary(LWOOBJID objectId, const SystemAddress& sysAddr, bool isPropertyMap = false, bool isZoneStart = false, LWOOBJID sender = LWOOBJID_EMPTY);
|
||||
|
||||
//UI:
|
||||
void SendNotifyNotEnoughInvSpace(LWOOBJID objectId, uint32_t freeSlotsNeeded, eInventoryType inventoryType, const SystemAddress& sysAddr);
|
||||
|
||||
// Mounts
|
||||
/**
|
||||
* @brief Set the Inventory LWOOBJID of the mount
|
||||
@@ -352,8 +338,6 @@ namespace GameMessages {
|
||||
//Racing:
|
||||
void HandleRequestDie(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
void SendUseItemRequirementsResponse(LWOOBJID objectID, const SystemAddress& sysAddr, eUseItemResponse itemResponse);
|
||||
|
||||
// SG:
|
||||
|
||||
void SendSetShootingGalleryParams(LWOOBJID objectId, const SystemAddress& sysAddr,
|
||||
@@ -391,9 +375,6 @@ namespace GameMessages {
|
||||
|
||||
//NT:
|
||||
|
||||
void HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void SendResponseMoveItemBetweenInventoryTypes(LWOOBJID objectId, const SystemAddress& sysAddr, eInventoryType inventoryTypeDestination, eInventoryType inventoryTypeSource, eReponseMoveItemBetweenInventoryTypeCode response);
|
||||
|
||||
//Handlers:
|
||||
|
||||
void HandleToggleGhostReferenceOverride(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
@@ -411,24 +392,11 @@ namespace GameMessages {
|
||||
void HandleNotifyServerLevelProcessingComplete(RakNet::BitStream& inStream, Entity* entity);
|
||||
void HandlePickupCurrency(RakNet::BitStream& inStream, Entity* entity);
|
||||
void HandleRequestDie(RakNet::BitStream& inStream, Entity* entity);
|
||||
void HandleEquipItem(RakNet::BitStream& inStream, Entity* entity);
|
||||
void HandleUnequipItem(RakNet::BitStream& inStream, Entity* entity);
|
||||
void HandleRemoveItemFromInventory(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void HandleMoveItemInInventory(RakNet::BitStream& inStream, Entity* entity);
|
||||
void HandleMoveItemBetweenInventoryTypes(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void HandlePickupItem(RakNet::BitStream& inStream, Entity* entity);
|
||||
void HandleResurrect(RakNet::BitStream& inStream, Entity* entity);
|
||||
void HandleModifyPlayerZoneStatistic(RakNet::BitStream& inStream, Entity* entity);
|
||||
void HandleUpdatePlayerStatistic(RakNet::BitStream& inStream, Entity* entity);
|
||||
|
||||
void HandlePushEquippedItemsState(RakNet::BitStream& inStream, Entity* entity);
|
||||
|
||||
void HandlePopEquippedItemsState(RakNet::BitStream& inStream, Entity* entity);
|
||||
|
||||
void HandleClientItemConsumed(RakNet::BitStream& inStream, Entity* entity);
|
||||
|
||||
void HandleUseNonEquipmentItem(RakNet::BitStream& inStream, Entity* entity);
|
||||
|
||||
void HandleMatchRequest(RakNet::BitStream& inStream, Entity* entity);
|
||||
|
||||
void HandleReportBug(RakNet::BitStream& inStream, Entity* entity);
|
||||
@@ -452,13 +420,8 @@ namespace GameMessages {
|
||||
void HandleConfirmDonationOnPlayer(RakNet::BitStream& inStream, Entity* entity);
|
||||
void HandleCancelDonationOnPlayer(RakNet::BitStream& inStream, Entity* entity);
|
||||
|
||||
void HandleUpdateInventoryGroup(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void HandleUpdateInventoryGroupContents(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void SendForceCameraTargetCycle(Entity* entity, bool bForceCycling, eCameraTargetCyclingMode cyclingMode, LWOOBJID optionalTargetID);
|
||||
|
||||
// This is a client gm however its default values are exactly what we need to get around the invisible inventory item issues.
|
||||
void SendUpdateInventoryUi(LWOOBJID objectId, const SystemAddress& sysAddr);
|
||||
|
||||
struct DisplayTooltip : public NetGameMsg {
|
||||
DisplayTooltip() : NetGameMsg(MessageType::Game::DISPLAY_TOOLTIP) {}
|
||||
bool doOrDie{};
|
||||
|
||||
Reference in New Issue
Block a user