diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 0a93ced64..4528ae0ca 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -300,27 +300,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) plMover->HandleFall(movementInfo); if ((opcode == MSG_MOVE_SET_WALK_MODE || opcode == MSG_MOVE_SET_RUN_MODE) && plMover) - { - Pet* pPet = plMover->GetPet(); - Pet* pMiniPet = plMover->GetMiniPet(); - - if (movementInfo.HasMovementFlag(MOVEMENTFLAG_WALK_MODE)) - { - if (pPet && !pPet->isInCombat()) - pPet->SetMonsterMoveFlags(MONSTER_MOVE_WALK); - - if (pMiniPet) - pMiniPet->SetMonsterMoveFlags(MONSTER_MOVE_WALK); - } - else - { - if (pPet) - pPet->RemoveMonsterMoveFlag(MONSTER_MOVE_WALK); - - if (pMiniPet) - pMiniPet->RemoveMonsterMoveFlag(MONSTER_MOVE_WALK); - } - } + plMover->UpdateWalkModeForPets(movementInfo.HasMovementFlag(MOVEMENTFLAG_WALK_MODE)); if (plMover && (movementInfo.HasMovementFlag(MOVEMENTFLAG_SWIMMING) != plMover->IsInWater())) { diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 5283be352..dabf4ca23 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -293,6 +293,8 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana); } + UpdateWalkModeForPets(owner->HasMovementFlag(MOVEMENTFLAG_WALK_MODE)); + AIM_Initialize(); map->Add((Creature*)this); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 3c111978d..6d1f501ce 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3548,6 +3548,9 @@ void Spell::EffectSummon(uint32 i) spawnCreature->InitStatsForLevel(level, m_caster); spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false); + + if (m_caster->GetTypeId() == TYPEID_PLAYER) + spawnCreature->UpdateWalkModeForPets(((Player*)m_caster)->HasMovementFlag(MOVEMENTFLAG_WALK_MODE)); spawnCreature->AIM_Initialize(); spawnCreature->InitPetCreateSpells(); @@ -4415,6 +4418,9 @@ void Spell::EffectSummonPet(uint32 i) NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + if (m_caster->GetTypeId() == TYPEID_PLAYER) + NewSummon->UpdateWalkModeForPets(((Player*)m_caster)->HasMovementFlag(MOVEMENTFLAG_WALK_MODE)); + NewSummon->GetCharmInfo()->SetPetNumber(pet_number, true); // this enables pet details window (Shift+P) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index b4113eab0..5f8f180f2 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3347,10 +3347,10 @@ void Unit::SetInFront(Unit const* target) SetOrientation(GetAngle(target)); } -void Unit::SetFacingToObject(WorldObject* pObject) +void Unit::SetFacingTo(float ori) { // update orientation at server - SetOrientation(GetAngle(pObject)); + SetOrientation(ori); // and client WorldPacket data; @@ -10394,6 +10394,34 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const return false; } +struct UpdateWalkModeForPetsHelper +{ + explicit UpdateWalkModeForPetsHelper(bool _on) : on(_on) {} + void operator()(Unit* unit) const { unit->UpdateWalkModeForPets(on); } + bool on; +}; + +void Unit::UpdateWalkModeForPets(bool on) +{ + if (GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->CallForAllControlledUnits(UpdateWalkModeForPetsHelper(on),false,true,true,true); + else + { + if (on) + { + if (((Creature*)this)->isPet() && hasUnitState(UNIT_STAT_FOLLOW)) + ((Creature*)this)->AddMonsterMoveFlag(MONSTER_MOVE_WALK); + } + else + { + if (((Creature*)this)->isPet()) + ((Creature*)this)->RemoveMonsterMoveFlag(MONSTER_MOVE_WALK); + } + + CallForAllControlledUnits(UpdateWalkModeForPetsHelper(on),false,true,true); + } +} + void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) { int32 main_speed_mod = 0; diff --git a/src/game/Unit.h b/src/game/Unit.h index f5c915479..06513fdf8 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1376,7 +1376,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SetBaseWeaponDamage(WeaponAttackType attType ,WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; } void SetInFront(Unit const* target); - void SetFacingToObject(WorldObject* pObject); + void SetFacingTo(float ori); + void SetFacingToObject(WorldObject* pObject) { SetFacingTo(GetAngle(pObject)); } // Visibility system UnitVisibility GetVisibility() const { return m_Visibility; } @@ -1523,6 +1524,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage); void CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, bool canReflect = false); + void UpdateWalkModeForPets(bool on); void UpdateSpeed(UnitMoveType mtype, bool forced); float GetSpeed( UnitMoveType mtype ) const; float GetSpeedRate( UnitMoveType mtype ) const { return m_speed_rate[mtype]; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ab370e841..8c4b87edf 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9196" + #define REVISION_NR "9197" #endif // __REVISION_NR_H__