mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Fix auto-attack stalling after SMSG_ATTACKSTOP and remove stale comments
Re-send CMSG_ATTACKSWING every second while auto-attacking so combat resumes automatically when the server pauses the attack loop (out of range, etc). Previously the client kept autoAttacking=true but never re-engaged, requiring the player to manually right-click again. Also remove leftover single-player/offline references from comments.
This commit is contained in:
parent
22648870f3
commit
bd70ca17ca
5 changed files with 14 additions and 4 deletions
|
|
@ -522,6 +522,7 @@ void GameHandler::update(float deltaTime) {
|
|||
auto distanceStart = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// Leave combat if auto-attack target is too far away (leash range)
|
||||
// Also re-send CMSG_ATTACKSWING every second to resume after server SMSG_ATTACKSTOP
|
||||
if (autoAttacking && autoAttackTarget != 0) {
|
||||
auto targetEntity = entityManager.getEntity(autoAttackTarget);
|
||||
if (targetEntity) {
|
||||
|
|
@ -531,6 +532,13 @@ void GameHandler::update(float deltaTime) {
|
|||
if (dist > 40.0f) {
|
||||
stopAutoAttack();
|
||||
LOG_INFO("Left combat: target too far (", dist, " yards)");
|
||||
} else if (state == WorldState::IN_WORLD && socket) {
|
||||
autoAttackResendTimer_ += deltaTime;
|
||||
if (autoAttackResendTimer_ >= 1.0f) {
|
||||
autoAttackResendTimer_ = 0.0f;
|
||||
auto pkt = AttackSwingPacket::build(autoAttackTarget);
|
||||
socket->send(pkt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6382,6 +6390,7 @@ void GameHandler::startAutoAttack(uint64_t targetGuid) {
|
|||
autoAttacking = true;
|
||||
autoAttackTarget = targetGuid;
|
||||
autoAttackOutOfRange_ = false;
|
||||
autoAttackResendTimer_ = 0.0f;
|
||||
if (state == WorldState::IN_WORLD && socket) {
|
||||
auto packet = AttackSwingPacket::build(targetGuid);
|
||||
socket->send(packet);
|
||||
|
|
@ -6394,6 +6403,7 @@ void GameHandler::stopAutoAttack() {
|
|||
autoAttacking = false;
|
||||
autoAttackTarget = 0;
|
||||
autoAttackOutOfRange_ = false;
|
||||
autoAttackResendTimer_ = 0.0f;
|
||||
if (state == WorldState::IN_WORLD && socket) {
|
||||
auto packet = AttackStopPacket::build();
|
||||
socket->send(packet);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue