[9209] Finish synchonization walk mode for pets.

* Re-sync at follow mode switches
* Support sync for creature pets

Also
* Attempt fix build at *nix
* Drop unused unut state mask with typo in name.
This commit is contained in:
VladimirMangos 2010-01-18 14:27:38 +03:00
parent 6a2e8064f1
commit e1d0c1cdba
9 changed files with 62 additions and 27 deletions

View file

@ -10394,19 +10394,23 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
return false;
}
struct UpdateWalkModeForPetsHelper
struct UpdateWalkModeHelper
{
explicit UpdateWalkModeForPetsHelper(bool _on) : on(_on) {}
void operator()(Unit* unit) const { unit->UpdateWalkModeForPets(on); }
bool on;
explicit UpdateWalkModeHelper(Unit* _source) : source(_source) {}
void operator()(Unit* unit) const { unit->UpdateWalkMode(source, true); }
Unit* source;
};
void Unit::UpdateWalkModeForPets(bool on)
void Unit::UpdateWalkMode(Unit* source, bool self)
{
if (GetTypeId() == TYPEID_PLAYER)
((Player*)this)->CallForAllControlledUnits(UpdateWalkModeForPetsHelper(on),false,true,true,true);
else
((Player*)this)->CallForAllControlledUnits(UpdateWalkModeHelper(source),false,true,true,true);
else if (self)
{
bool on = source->GetTypeId() == TYPEID_PLAYER
? ((Player*)source)->HasMovementFlag(MOVEMENTFLAG_WALK_MODE)
: ((Creature*)source)->HasMonsterMoveFlag(MONSTER_MOVE_WALK);
if (on)
{
if (((Creature*)this)->isPet() && hasUnitState(UNIT_STAT_FOLLOW))
@ -10417,9 +10421,9 @@ void Unit::UpdateWalkModeForPets(bool on)
if (((Creature*)this)->isPet())
((Creature*)this)->RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
}
CallForAllControlledUnits(UpdateWalkModeForPetsHelper(on),false,true,true);
}
else
CallForAllControlledUnits(UpdateWalkModeHelper(source),false,true,true);
}
void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)