Files
WoW-Hybrid-gateway/native/inventory_translation.hpp

58 lines
3.6 KiB
C++

#pragma once
#include "gateway/object_updates.hpp"
#include "entity_translation.hpp"
#include <deque>
// Authenticated owned-item state only. No database, UI, socket or engine pointer.
struct NativeInventoryPosition {uint8_t bag,slot;uint64_t item;};
struct NativeInventoryTranslation {
std::map<uint64_t,gateway::LegacyObjectUpdate> items;
std::map<uint16_t,uint32_t> player_fields;
// Source keyring references are needed for quest counts, not native slot routing.
std::map<uint16_t,uint32_t> quest_keyring_fields;
std::map<uint64_t,uint32_t> applied_appearances;
std::set<uint8_t> applied_transmog_slots;
std::map<uint32_t,gateway::ItemTemplateReply> templates;
std::set<uint32_t> queries;
// A pending template completed during an owned world transfer. Delay
// equipment presentation until the original SELF is created again.
bool deferred_template_projection=false;
std::deque<gateway::LegacyPacket> requests;
uint32_t profile_replies=0,profile_missing=0,last_profile=0,cooldown_packets=0,cooldown_modifier_blocks=0;
uint32_t value_updates=0,creates=0,removals=0;
NativeInventoryPosition position(uint8_t bag,uint8_t slot) const;
using OwnedBindings = std::map<uint64_t,gateway::Guid128>;
const OwnedBindings& owned_bindings() const &;
OwnedBindings owned_bindings() const && = delete;
uint8_t buyback_slot(uint32_t modern_slot) const;
gateway::Bytes snapshot() const;
std::map<uint32_t, uint64_t> quest_item_counts(uint64_t self) const;
// Whole stacks of one item in the backpack and equipped bags: {item guid, stack count}.
std::vector<std::pair<uint64_t,uint32_t>> carried_stacks(uint64_t self, uint32_t entry) const;
gateway::LegacyPacket gameplay(uint32_t,std::span<const uint8_t>) const;
// Native SortBags/SortBankBags: an ordered list of Turtle CMSG_SWAP_ITEM (0x10c)
// over owned general-purpose storage (special-family bags untouched). Stacks are
// first merged with Turtle's own swap-onto-partial rule, then placed in order.
std::vector<gateway::LegacyPacket> sort_plan(bool bank) const;
// gameobject_target: the caller already qualified a 0x800 target against the current object binding.
gateway::LegacyPacket use_item(std::span<const uint8_t>,const std::map<uint64_t,gateway::Guid128>&,bool gameobject_target=false) const;
std::vector<gateway::LegacyPacket> translate(const gateway::LegacyPacket&,uint64_t self,uint16_t realm,uint32_t map,bool initial,const NativeEntityTranslation::Codec&,bool project_staged_initial_items=false);
// queries contains all outstanding entries. This subset has only peer-presentation consumers.
std::set<uint32_t> peer_template_queries;
static constexpr size_t PeerTemplateCapacity=3072;
std::map<uint32_t,gateway::ItemTemplateReply> peer_templates;
std::deque<uint32_t> peer_template_order;
const gateway::ItemTemplateReply* peer_template(uint32_t entry) const;
void request_owned_template(uint32_t entry);
bool peer_queries_deferred=false;
void request_peer_template(uint32_t entry);
bool cache_pending_template_reply(std::span<const uint8_t> body,bool* peer_requested=nullptr);
bool equipped_entry(uint32_t entry) const;
struct QuestStarter {gateway::Guid128 modern{};uint64_t generation=0;uint32_t quest=0;};
std::map<uint64_t,QuestStarter> quest_starters(uint64_t self) const;
// A recreated Source GUID cannot inherit a previous item's dialogue offer.
std::map<uint64_t,uint64_t> item_generations;
uint64_t item_generation=0;
private:
mutable OwnedBindings owned_binding_cache_;
};