mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 17:43:52 +00:00
Add mount system and crash mouse-release handler
Render mount M2 model under player with seated animation, apply creature skin textures, server-driven speed via SMSG_FORCE_RUN_SPEED_CHANGE, and /dismount command. X11 XUngrabPointer on crash/hang to always release mouse.
This commit is contained in:
parent
4a932dd8cd
commit
643611ee79
13 changed files with 363 additions and 3 deletions
|
|
@ -150,6 +150,10 @@ private:
|
|||
std::unordered_map<uint64_t, uint32_t> creatureModelIds_; // guid → loaded modelId
|
||||
std::unordered_map<uint32_t, uint32_t> displayIdModelCache_; // displayId → modelId (model caching)
|
||||
uint32_t nextCreatureModelId_ = 5000; // Model IDs for online creatures
|
||||
|
||||
// Mount model tracking
|
||||
uint32_t mountInstanceId_ = 0;
|
||||
uint32_t mountModelId_ = 0;
|
||||
bool creatureLookupsBuilt_ = false;
|
||||
|
||||
// Deferred creature spawn queue (throttles spawning to avoid hangs)
|
||||
|
|
|
|||
|
|
@ -189,6 +189,10 @@ public:
|
|||
uint32_t getDisplayId() const { return displayId; }
|
||||
void setDisplayId(uint32_t id) { displayId = id; }
|
||||
|
||||
// Mount display ID (UNIT_FIELD_MOUNTDISPLAYID, index 69)
|
||||
uint32_t getMountDisplayId() const { return mountDisplayId; }
|
||||
void setMountDisplayId(uint32_t id) { mountDisplayId = id; }
|
||||
|
||||
// Unit flags (UNIT_FIELD_FLAGS, index 59)
|
||||
uint32_t getUnitFlags() const { return unitFlags; }
|
||||
void setUnitFlags(uint32_t f) { unitFlags = f; }
|
||||
|
|
@ -216,6 +220,7 @@ protected:
|
|||
uint32_t level = 1;
|
||||
uint32_t entry = 0;
|
||||
uint32_t displayId = 0;
|
||||
uint32_t mountDisplayId = 0;
|
||||
uint32_t unitFlags = 0;
|
||||
uint32_t npcFlags = 0;
|
||||
uint32_t factionTemplate = 0;
|
||||
|
|
|
|||
|
|
@ -455,6 +455,13 @@ public:
|
|||
}
|
||||
const std::unordered_map<uint64_t, QuestGiverStatus>& getNpcQuestStatuses() const { return npcQuestStatus_; }
|
||||
|
||||
// Mount state
|
||||
using MountCallback = std::function<void(uint32_t mountDisplayId)>; // 0 = dismount
|
||||
void setMountCallback(MountCallback cb) { mountCallback_ = std::move(cb); }
|
||||
bool isMounted() const { return currentMountDisplayId_ != 0; }
|
||||
float getServerRunSpeed() const { return serverRunSpeed_; }
|
||||
void dismount();
|
||||
|
||||
// Taxi / Flight Paths
|
||||
bool isTaxiWindowOpen() const { return taxiWindowOpen_; }
|
||||
void closeTaxi();
|
||||
|
|
@ -630,6 +637,9 @@ private:
|
|||
// ---- Teleport handler ----
|
||||
void handleTeleportAck(network::Packet& packet);
|
||||
|
||||
// ---- Speed change handler ----
|
||||
void handleForceRunSpeedChange(network::Packet& packet);
|
||||
|
||||
// ---- Taxi handlers ----
|
||||
void handleShowTaxiNodes(network::Packet& packet);
|
||||
void handleActivateTaxiReply(network::Packet& packet);
|
||||
|
|
@ -844,6 +854,8 @@ private:
|
|||
ShowTaxiNodesData currentTaxiData_;
|
||||
uint64_t taxiNpcGuid_ = 0;
|
||||
bool onTaxiFlight_ = false;
|
||||
uint32_t knownTaxiMask_[12] = {}; // Track previously known nodes for discovery alerts
|
||||
bool taxiMaskInitialized_ = false; // First SMSG_SHOWTAXINODES seeds mask without alerts
|
||||
|
||||
// Vendor
|
||||
bool vendorWindowOpen = false;
|
||||
|
|
@ -877,6 +889,9 @@ private:
|
|||
NpcRespawnCallback npcRespawnCallback_;
|
||||
MeleeSwingCallback meleeSwingCallback_;
|
||||
NpcSwingCallback npcSwingCallback_;
|
||||
MountCallback mountCallback_;
|
||||
uint32_t currentMountDisplayId_ = 0;
|
||||
float serverRunSpeed_ = 7.0f;
|
||||
bool playerDead_ = false;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -241,9 +241,16 @@ enum class Opcode : uint16_t {
|
|||
MSG_MOVE_TELEPORT_ACK = 0x0C7,
|
||||
SMSG_TRANSFER_PENDING = 0x003F,
|
||||
|
||||
// ---- Speed Changes ----
|
||||
SMSG_FORCE_RUN_SPEED_CHANGE = 0x00E2,
|
||||
|
||||
// ---- Mount ----
|
||||
CMSG_CANCEL_MOUNT_AURA = 0x0375,
|
||||
|
||||
// ---- Taxi / Flight Paths ----
|
||||
SMSG_SHOWTAXINODES = 0x01A9,
|
||||
SMSG_ACTIVATETAXIREPLY = 0x01AE,
|
||||
SMSG_NEW_TAXI_PATH = 0x01AF,
|
||||
CMSG_ACTIVATETAXIEXPRESS = 0x0312,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ public:
|
|||
using MovementCallback = std::function<void(uint32_t opcode)>;
|
||||
void setMovementCallback(MovementCallback cb) { movementCallback = std::move(cb); }
|
||||
void setUseWoWSpeed(bool use) { useWoWSpeed = use; }
|
||||
void setRunSpeedOverride(float speed) { runSpeedOverride_ = speed; }
|
||||
void setMounted(bool m) { mounted_ = m; }
|
||||
|
||||
// For first-person player hiding
|
||||
void setCharacterRenderer(class CharacterRenderer* cr, uint32_t playerId) {
|
||||
|
|
@ -188,6 +190,10 @@ private:
|
|||
static constexpr float WOW_GRAVITY = -19.29f;
|
||||
static constexpr float WOW_JUMP_VELOCITY = 7.96f;
|
||||
|
||||
// Server-driven run speed override (0 = use default WOW_RUN_SPEED)
|
||||
float runSpeedOverride_ = 0.0f;
|
||||
bool mounted_ = false;
|
||||
|
||||
// Online mode: trust server position, don't prefer outdoors over WMO floors
|
||||
bool onlineMode = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,11 @@ public:
|
|||
void triggerMeleeSwing();
|
||||
void setEquippedWeaponType(uint32_t inventoryType) { equippedWeaponInvType_ = inventoryType; meleeAnimId = 0; }
|
||||
|
||||
// Mount rendering
|
||||
void setMounted(uint32_t mountInstId, float heightOffset);
|
||||
void clearMount();
|
||||
bool isMounted() const { return mountInstanceId_ != 0; }
|
||||
|
||||
// Selection circle for targeted entity
|
||||
void setSelectionCircle(const glm::vec3& pos, float radius, const glm::vec3& color);
|
||||
void clearSelectionCircle();
|
||||
|
|
@ -214,7 +219,7 @@ private:
|
|||
float characterYaw = 0.0f;
|
||||
|
||||
// Character animation state
|
||||
enum class CharAnimState { IDLE, WALK, RUN, JUMP_START, JUMP_MID, JUMP_END, SIT_DOWN, SITTING, EMOTE, SWIM_IDLE, SWIM, MELEE_SWING };
|
||||
enum class CharAnimState { IDLE, WALK, RUN, JUMP_START, JUMP_MID, JUMP_END, SIT_DOWN, SITTING, EMOTE, SWIM_IDLE, SWIM, MELEE_SWING, MOUNT };
|
||||
CharAnimState charAnimState = CharAnimState::IDLE;
|
||||
void updateCharacterAnimation();
|
||||
bool isFootstepAnimationState() const;
|
||||
|
|
@ -259,6 +264,10 @@ private:
|
|||
uint32_t meleeAnimId = 0;
|
||||
uint32_t equippedWeaponInvType_ = 0;
|
||||
|
||||
// Mount state
|
||||
uint32_t mountInstanceId_ = 0;
|
||||
float mountHeightOffset_ = 0.0f;
|
||||
|
||||
bool terrainEnabled = true;
|
||||
bool terrainLoaded = false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue