aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2018-01-22 14:13:46 -0300
committerariel- <ariel-@users.noreply.github.com>2018-01-22 14:13:46 -0300
commite315e41d36061fc88dfa09bfa0da1fbc0c00826f (patch)
treee4548b272bf79444edf4a200abc883717ade0741
parent590d2518820d45e54a4a31cc554af18c0695bcd0 (diff)
Core/Entities: don't allow client control if player is still affected by any lose of control state
-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 96d91da4330..173b6c8fd21 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -821,7 +821,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 ec8c3290e16..ea78cfd468d 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -12072,45 +12072,46 @@ 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) || GetVehicle())
return;
+ ClearUnitState(state);
SetRooted(false);
break;
case UNIT_STATE_CONFUSED:
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))
- 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))
+ SetRooted(true);
+
+ if (HasAuraType(SPELL_AURA_MOD_CONFUSE))
+ SetConfused(true);
+
+ if (HasAuraType(SPELL_AURA_MOD_FEAR))
+ SetFeared(true);
}
}
@@ -12237,8 +12238,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)
@@ -12260,8 +12265,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)
@@ -12528,7 +12537,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 f4271b0c38c..59ee716729b 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -248,7 +248,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,