mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[11721] Simplify walk/run movement mode selection code
This commit is contained in:
parent
9d566398ad
commit
fc0eb7e9fa
10 changed files with 10 additions and 54 deletions
|
|
@ -8122,36 +8122,6 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
|
|||
return false;
|
||||
}
|
||||
|
||||
struct UpdateWalkModeHelper
|
||||
{
|
||||
explicit UpdateWalkModeHelper(Unit* _source) : source(_source) {}
|
||||
void operator()(Unit* unit) const { unit->UpdateWalkMode(source, true); }
|
||||
Unit* source;
|
||||
};
|
||||
|
||||
void Unit::UpdateWalkMode(Unit* source, bool self)
|
||||
{
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
CallForAllControlledUnits(UpdateWalkModeHelper(source), CONTROLLED_PET|CONTROLLED_GUARDIANS|CONTROLLED_CHARM|CONTROLLED_MINIPET);
|
||||
else if (self)
|
||||
{
|
||||
bool on = source->m_movementInfo.HasMovementFlag(MOVEFLAG_WALK_MODE);
|
||||
|
||||
if (on)
|
||||
{
|
||||
if (((Creature*)this)->IsPet() && hasUnitState(UNIT_STAT_FOLLOW))
|
||||
((Creature*)this)->SetWalk(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((Creature*)this)->IsPet())
|
||||
((Creature*)this)->SetWalk(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
CallForAllControlledUnits(UpdateWalkModeHelper(source), CONTROLLED_PET|CONTROLLED_GUARDIANS|CONTROLLED_CHARM|CONTROLLED_MINIPET);
|
||||
}
|
||||
|
||||
void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio)
|
||||
{
|
||||
// not in combat pet have same speed as owner
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue