aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2018-01-22 14:13:46 -0300
committerShauren <shauren.trinity@gmail.com>2021-06-16 20:38:56 +0200
commit29bfa32fc39de1d93fbdb272d48689174c547725 (patch)
tree4e7524f720a8740cbb9e05be82f6475f4dcba39a /src
parentb46d899ef16ce15e1f8403be076993545035cddc (diff)
Core/Entities: don't allow client control if player is still affected by any lose of control state
(cherry picked from commit e315e41d36061fc88dfa09bfa0da1fbc0c00826f)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Battlegrounds/Battleground.cpp3
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp43
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
3 files changed, 30 insertions, 18 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index e492847827a..25a9f200606 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -860,7 +860,8 @@ uint32 Battleground::GetBonusHonorFromKill(uint32 kills) const
void Battleground::BlockMovement(Player* player)
{
- player->SetClientControl(player, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave()
+ // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave()
+ player->SetClientControl(player, false);
}
void Battleground::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool SendPacket)
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 280ecf86d33..8902b480c90 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -11672,12 +11672,14 @@ void Unit::SetControlled(bool apply, UnitState state)
if (HasAuraType(SPELL_AURA_MOD_STUN))
return;
+ ClearUnitState(state);
SetStunned(false);
break;
case UNIT_STATE_ROOT:
if (HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOT_2) || GetVehicle())
return;
+ ClearUnitState(state);
if (!HasUnitState(UNIT_STATE_STUNNED))
SetRooted(false);
break;
@@ -11685,33 +11687,32 @@ void Unit::SetControlled(bool apply, UnitState state)
if (HasAuraType(SPELL_AURA_MOD_CONFUSE))
return;
+ ClearUnitState(state);
SetConfused(false);
break;
case UNIT_STATE_FLEEING:
if (HasAuraType(SPELL_AURA_MOD_FEAR))
return;
+ ClearUnitState(state);
SetFeared(false);
break;
default:
return;
}
- ClearUnitState(state);
-
// Unit States might have been already cleared but auras still present. I need to check with HasAuraType
if (HasAuraType(SPELL_AURA_MOD_STUN))
SetStunned(true);
- else
- {
- if (HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOT_2))
- SetRooted(true);
- if (HasAuraType(SPELL_AURA_MOD_CONFUSE))
- SetConfused(true);
- else if (HasAuraType(SPELL_AURA_MOD_FEAR))
- SetFeared(true);
- }
+ if (HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOT_2))
+ SetRooted(true);
+
+ if (HasAuraType(SPELL_AURA_MOD_CONFUSE))
+ SetConfused(true);
+
+ if (HasAuraType(SPELL_AURA_MOD_FEAR))
+ SetFeared(true);
}
}
@@ -11815,8 +11816,12 @@ void Unit::SetFeared(bool apply)
}
if (Player* player = ToPlayer())
- if (!player->HasUnitState(UNIT_STATE_POSSESSED))
- player->SetClientControl(this, !apply);
+ {
+ if (apply)
+ player->SetClientControl(this, false);
+ else if (!HasUnitState(UNIT_STATE_LOST_CONTROL))
+ player->SetClientControl(this, true);
+ }
}
void Unit::SetConfused(bool apply)
@@ -11838,8 +11843,12 @@ void Unit::SetConfused(bool apply)
}
if (Player* player = ToPlayer())
- if (!player->HasUnitState(UNIT_STATE_POSSESSED))
- player->SetClientControl(this, !apply);
+ {
+ if (apply)
+ player->SetClientControl(this, false);
+ else if (!HasUnitState(UNIT_STATE_LOST_CONTROL))
+ player->SetClientControl(this, true);
+ }
}
bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* aurApp)
@@ -12106,7 +12115,9 @@ void Unit::RemoveCharmedBy(Unit* charmer)
NeedChangeAI = true;
IsAIEnabled = false;
}
- player->SetClientControl(this, true);
+
+ if (!HasUnitState(UNIT_STATE_LOST_CONTROL))
+ player->SetClientControl(this, true);
}
EngageWithTarget(charmer);
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index f1948da6223..9dc7b800b02 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -281,7 +281,7 @@ enum UnitState : uint32
UNIT_STATE_UNATTACKABLE = UNIT_STATE_IN_FLIGHT,
UNIT_STATE_MOVING = UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE | UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE,
UNIT_STATE_CONTROLLED = UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING,
- UNIT_STATE_LOST_CONTROL = UNIT_STATE_CONTROLLED | UNIT_STATE_JUMPING | UNIT_STATE_CHARGING,
+ UNIT_STATE_LOST_CONTROL = UNIT_STATE_CONTROLLED | UNIT_STATE_POSSESSED | UNIT_STATE_JUMPING | UNIT_STATE_CHARGING,
UNIT_STATE_SIGHTLESS = UNIT_STATE_LOST_CONTROL | UNIT_STATE_EVADE,
UNIT_STATE_CANNOT_AUTOATTACK = UNIT_STATE_LOST_CONTROL | UNIT_STATE_CASTING,
UNIT_STATE_CANNOT_TURN = UNIT_STATE_LOST_CONTROL | UNIT_STATE_ROTATING,