mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Show online player equipment
This commit is contained in:
parent
6af9d6ba2d
commit
d3211f5493
4 changed files with 345 additions and 0 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <array>
|
||||
|
||||
namespace wowee {
|
||||
|
||||
|
|
@ -96,6 +97,9 @@ private:
|
|||
uint32_t appearanceBytes,
|
||||
uint8_t facialFeatures,
|
||||
float x, float y, float z, float orientation);
|
||||
void setOnlinePlayerEquipment(uint64_t guid,
|
||||
const std::array<uint32_t, 19>& displayInfoIds,
|
||||
const std::array<uint8_t, 19>& inventoryTypes);
|
||||
void despawnOnlinePlayer(uint64_t guid);
|
||||
void buildCreatureDisplayLookups();
|
||||
std::string getModelPathForDisplayId(uint32_t displayId) const;
|
||||
|
|
@ -228,6 +232,18 @@ private:
|
|||
|
||||
// Online player instances (separate from creatures so we can apply per-player skin/hair textures).
|
||||
std::unordered_map<uint64_t, uint32_t> playerInstances_; // guid → render instanceId
|
||||
struct OnlinePlayerAppearanceState {
|
||||
uint32_t instanceId = 0;
|
||||
uint32_t modelId = 0;
|
||||
uint8_t raceId = 0;
|
||||
uint8_t genderId = 0;
|
||||
uint32_t appearanceBytes = 0;
|
||||
uint8_t facialFeatures = 0;
|
||||
std::string bodySkinPath;
|
||||
std::vector<std::string> underwearPaths;
|
||||
};
|
||||
std::unordered_map<uint64_t, OnlinePlayerAppearanceState> onlinePlayerAppearance_;
|
||||
std::unordered_map<uint64_t, std::pair<std::array<uint32_t, 19>, std::array<uint8_t, 19>>> pendingOnlinePlayerEquipment_;
|
||||
// Cache base player model geometry by (raceId, genderId)
|
||||
std::unordered_map<uint32_t, uint32_t> playerModelCache_; // key=(race<<8)|gender → modelId
|
||||
struct PlayerTextureSlots { int skin = -1; int hair = -1; int underwear = -1; };
|
||||
|
|
|
|||
|
|
@ -494,6 +494,14 @@ public:
|
|||
using PlayerDespawnCallback = std::function<void(uint64_t guid)>;
|
||||
void setPlayerDespawnCallback(PlayerDespawnCallback cb) { playerDespawnCallback_ = std::move(cb); }
|
||||
|
||||
// Online player equipment visuals callback.
|
||||
// Sends a best-effort view of equipped items for players in view using ItemDisplayInfo IDs.
|
||||
// Arrays are indexed by EquipSlot (0..18). Values are 0 when unknown/unavailable.
|
||||
using PlayerEquipmentCallback = std::function<void(uint64_t guid,
|
||||
const std::array<uint32_t, 19>& displayInfoIds,
|
||||
const std::array<uint8_t, 19>& inventoryTypes)>;
|
||||
void setPlayerEquipmentCallback(PlayerEquipmentCallback cb) { playerEquipmentCallback_ = std::move(cb); }
|
||||
|
||||
// GameObject spawn callback (online mode - triggered when gameobject enters view)
|
||||
// Parameters: guid, entry, displayId, x, y, z (canonical), orientation
|
||||
using GameObjectSpawnCallback = std::function<void(uint64_t guid, uint32_t entry, uint32_t displayId, float x, float y, float z, float orientation)>;
|
||||
|
|
@ -831,6 +839,10 @@ private:
|
|||
void handleItemQueryResponse(network::Packet& packet);
|
||||
void queryItemInfo(uint32_t entry, uint64_t guid);
|
||||
void rebuildOnlineInventory();
|
||||
void maybeDetectVisibleItemLayout();
|
||||
void updateOtherPlayerVisibleItems(uint64_t guid, const std::map<uint16_t, uint32_t>& fields);
|
||||
void emitOtherPlayerEquipment(uint64_t guid);
|
||||
void emitAllOtherPlayerEquipment();
|
||||
void detectInventorySlotBases(const std::map<uint16_t, uint32_t>& fields);
|
||||
bool applyInventoryFields(const std::map<uint16_t, uint32_t>& fields);
|
||||
uint64_t resolveOnlineItemGuid(uint32_t itemId) const;
|
||||
|
|
@ -1065,6 +1077,13 @@ private:
|
|||
std::map<uint16_t, uint32_t> lastPlayerFields_;
|
||||
bool onlineEquipDirty_ = false;
|
||||
|
||||
// Visible equipment for other players: detect the update-field layout (base + stride)
|
||||
// using the local player's own equipped items, then decode other players by index.
|
||||
int visibleItemEntryBase_ = -1;
|
||||
int visibleItemStride_ = 2;
|
||||
std::unordered_map<uint64_t, std::array<uint32_t, 19>> otherPlayerVisibleItemEntries_;
|
||||
std::unordered_set<uint64_t> otherPlayerVisibleDirty_;
|
||||
|
||||
// ---- Phase 2: Combat ----
|
||||
bool autoAttacking = false;
|
||||
uint64_t autoAttackTarget = 0;
|
||||
|
|
@ -1081,6 +1100,7 @@ private:
|
|||
CreatureDespawnCallback creatureDespawnCallback_;
|
||||
PlayerSpawnCallback playerSpawnCallback_;
|
||||
PlayerDespawnCallback playerDespawnCallback_;
|
||||
PlayerEquipmentCallback playerEquipmentCallback_;
|
||||
CreatureMoveCallback creatureMoveCallback_;
|
||||
TransportMoveCallback transportMoveCallback_;
|
||||
TransportSpawnCallback transportSpawnCallback_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue