diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 2b91dbf92d5..22ced0bc16b 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -764,7 +764,7 @@ bool Creature::isCanTrainingAndResetTalentsOf(Player* pPlayer) const && pPlayer->getClass() == GetCreatureInfo()->trainer_class; } -void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, SplineFlags flags, uint8 type) +void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, SplineFlags flags, SplineType type) { /* uint32 timeElap = getMSTime(); if ((timeElap - m_startMove) < m_moveTime) @@ -2057,25 +2057,6 @@ void Creature::SendMonsterMoveWithSpeedToCurrentDestination(Player* player) SendMonsterMoveWithSpeed(x, y, z, 0, player); } -void Creature::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime, Player* player) -{ - if (!transitTime) - { - if(GetTypeId()==TYPEID_PLAYER) - { - Traveller traveller(*(Player*)this); - transitTime = traveller.GetTotalTrevelTimeTo(x, y, z); - } - else - { - Traveller traveller(*(Creature*)this); - transitTime = traveller.GetTotalTrevelTimeTo(x, y, z); - } - } - //float orientation = (float)atan2((double)dy, (double)dx); - SendMonsterMove(x, y, z, 0, GetSplineFlags(), transitTime, player); -} - void Creature::SendAreaSpiritHealerQueryOpcode(Player *pl) { uint32 next_resurrect = 0; diff --git a/src/game/Creature.h b/src/game/Creature.h index 6bba03dbe42..788082cd351 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -438,7 +438,7 @@ class MANGOS_DLL_SPEC Creature : public Unit bool AIM_Initialize(); - void AI_SendMoveToPacket(float x, float y, float z, uint32 time, SplineFlags MovementFlags, uint8 type); + void AI_SendMoveToPacket(float x, float y, float z, uint32 time, SplineFlags MovementFlags, SplineType type); CreatureAI* AI() { return i_AI; } void AddSplineFlag(SplineFlags f) @@ -465,7 +465,6 @@ class MANGOS_DLL_SPEC Creature : public Unit UpdateWalkMode(this, false); } - void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL); void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL); uint32 GetShieldBlockValue() const //dunno mob block value diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 6e50fae3b8e..71afd30746c 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -35,7 +35,6 @@ #include "Group.h" #include "MapRefManager.h" #include "DBCEnums.h" -#include "MovementGenerator.h" #include "MapInstanced.h" #include "InstanceSaveMgr.h" @@ -891,11 +890,6 @@ Map::PlayerRelocation(Player *player, float x, float y, float z, float orientati void Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang) { - // Creature relocation acts like instant movement generator, so current generator expects interrupt/reset calls to react properly - if (!creature->GetMotionMaster()->empty()) - if (MovementGenerator *movgen = creature->GetMotionMaster()->top()) - movgen->Interrupt(*creature); - assert(CheckGridIntegrity(creature,false)); Cell old_cell = creature->GetCurrentCell(); @@ -920,12 +914,6 @@ Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang } assert(CheckGridIntegrity(creature,true)); - - // finished relocation, movegen can different from top before creature relocation, - // but apply Reset expected to be safe in any case - if (!creature->GetMotionMaster()->empty()) - if (MovementGenerator *movgen = creature->GetMotionMaster()->top()) - movgen->Reset(*creature); } void Map::AddCreatureToMoveList(Creature *c, float x, float y, float z, float ang) @@ -2998,8 +2986,7 @@ void Map::ScriptsProcess() sLog.outError("SCRIPT_COMMAND_MOVE_TO call for non-creature (TypeId: %u), skipping.",source->GetTypeId()); break; } - ((Creature*)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, step.script->datalong2 ); - ((Creature*)source)->GetMap()->CreatureRelocation(((Creature*)source), step.script->x, step.script->y, step.script->z, 0); + ((Unit*)source)->MonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, step.script->datalong2 ); break; case SCRIPT_COMMAND_FLAG_SET: if(!source) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 1a511d15b11..c317ce03852 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -6428,10 +6428,7 @@ void Spell::EffectCharge(uint32 /*i*/) ((Creature *)unitTarget)->StopMoving(); // Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags - m_caster->SendMonsterMove(x, y, z, 0, m_caster->GetTypeId() == TYPEID_PLAYER ? SPLINEFLAG_WALKMODE : ((Creature*)m_caster)->GetSplineFlags(), 1); - - if (m_caster->GetTypeId() != TYPEID_PLAYER) - m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, x, y, z, m_caster->GetOrientation()); + m_caster->MonsterMove(x, y, z, 1); // not all charge effects used in negative spells if (unitTarget != m_caster && !IsPositiveSpell(m_spellInfo->Id)) @@ -6456,10 +6453,7 @@ void Spell::EffectCharge2(uint32 /*i*/) return; // Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags - m_caster->SendMonsterMove(x, y, z, 0, m_caster->GetTypeId() == TYPEID_PLAYER ? SPLINEFLAG_WALKMODE : ((Creature*)m_caster)->GetSplineFlags(), 1); - - if (m_caster->GetTypeId() != TYPEID_PLAYER) - m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, x, y, z, m_caster->GetOrientation()); + m_caster->MonsterMove(x, y, z, 1); // not all charge effects used in negative spells if (unitTarget && unitTarget != m_caster && !IsPositiveSpell(m_spellInfo->Id)) diff --git a/src/game/Traveller.h b/src/game/Traveller.h index 9300041232d..ea0d7ca17ee 100644 --- a/src/game/Traveller.h +++ b/src/game/Traveller.h @@ -102,7 +102,7 @@ inline float Traveller::GetMoveDestinationTo(float x, float y, float z template<> inline void Traveller::MoveTo(float x, float y, float z, uint32 t) { - i_traveller.AI_SendMoveToPacket(x, y, z, t, i_traveller.GetSplineFlags(), 0); + i_traveller.AI_SendMoveToPacket(x, y, z, t, i_traveller.GetSplineFlags(), SPLINETYPE_NORMAL); } // specialization for players @@ -138,7 +138,7 @@ template<> inline void Traveller::MoveTo(float x, float y, float z, uint32 t) { //Only send SPLINEFLAG_WALKMODE, client has strange issues with other move flags - i_traveller.SendMonsterMove(x, y, z, 0, SPLINEFLAG_WALKMODE, t); + i_traveller.SendMonsterMove(x, y, z, SPLINETYPE_NORMAL, SPLINEFLAG_WALKMODE, t); } typedef Traveller CreatureTraveller; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index f1b3058169a..11c235bc461 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -47,6 +47,7 @@ #include "Path.h" #include "Traveller.h" #include "VMapFactory.h" +#include "MovementGenerator.h" #include @@ -364,7 +365,7 @@ bool Unit::haveOffhandWeapon() const return false; } -void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, SplineFlags flags, uint32 Time, Player* player) +void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, SplineType type, SplineFlags flags, uint32 Time, Player* player) { float moveTime = (float)Time; @@ -431,6 +432,26 @@ void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, Spl SendMessageToSet(&data, true); } +void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime, Player* player) +{ + if (!transitTime) + { + if(GetTypeId()==TYPEID_PLAYER) + { + Traveller traveller(*(Player*)this); + transitTime = traveller.GetTotalTrevelTimeTo(x, y, z); + } + else + { + Traveller traveller(*(Creature*)this); + transitTime = traveller.GetTotalTrevelTimeTo(x, y, z); + } + } + //float orientation = (float)atan2((double)dy, (double)dx); + SplineFlags flags = GetTypeId() == TYPEID_PLAYER ? SPLINEFLAG_WALKMODE : ((Creature*)this)->GetSplineFlags(); + SendMonsterMove(x, y, z, SPLINETYPE_NORMAL, flags, transitTime, player); +} + void Unit::BuildHeartBeatMsg(WorldPacket *data) const { MovementFlags move_flags = GetTypeId()==TYPEID_PLAYER @@ -12475,7 +12496,7 @@ void Unit::StopMoving() // send explicit stop packet // player expected for correct work SPLINEFLAG_WALKMODE - SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), 0, GetTypeId() == TYPEID_PLAYER ? SPLINEFLAG_WALKMODE : SPLINEFLAG_NONE, 0); + SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), SPLINETYPE_NORMAL, GetTypeId() == TYPEID_PLAYER ? SPLINEFLAG_WALKMODE : SPLINEFLAG_NONE, 0); // update position and orientation for near players WorldPacket data; @@ -13228,11 +13249,67 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca ((Player*)this)->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0)); else { + Creature* c = (Creature*)this; + // Creature relocation acts like instant movement generator, so current generator expects interrupt/reset calls to react properly + if (!c->GetMotionMaster()->empty()) + if (MovementGenerator *movgen = c->GetMotionMaster()->top()) + movgen->Interrupt(*c); + GetMap()->CreatureRelocation((Creature*)this, x, y, z, orientation); WorldPacket data; BuildHeartBeatMsg(&data); SendMessageToSet(&data, false); + // finished relocation, movegen can different from top before creature relocation, + // but apply Reset expected to be safe in any case + if (!c->GetMotionMaster()->empty()) + if (MovementGenerator *movgen = c->GetMotionMaster()->top()) + movgen->Reset(*c); + } +} + +void Unit::MonsterMove(float x, float y, float z, uint32 transitTime) +{ + SplineFlags flags = GetTypeId() == TYPEID_PLAYER ? SPLINEFLAG_WALKMODE : ((Creature*)this)->GetSplineFlags(); + SendMonsterMove(x, y, z, SPLINETYPE_NORMAL, flags, transitTime); + + if (GetTypeId() != TYPEID_PLAYER) + { + Creature* c = (Creature*)this; + // Creature relocation acts like instant movement generator, so current generator expects interrupt/reset calls to react properly + if (!c->GetMotionMaster()->empty()) + if (MovementGenerator *movgen = c->GetMotionMaster()->top()) + movgen->Interrupt(*c); + + GetMap()->CreatureRelocation((Creature*)this, x, y, z, 0.0f); + + // finished relocation, movegen can different from top before creature relocation, + // but apply Reset expected to be safe in any case + if (!c->GetMotionMaster()->empty()) + if (MovementGenerator *movgen = c->GetMotionMaster()->top()) + movgen->Reset(*c); + } +} + +void Unit::MonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime) +{ + SendMonsterMoveWithSpeed(x, y, z, transitTime ); + + if (GetTypeId() != TYPEID_PLAYER) + { + Creature* c = (Creature*)this; + // Creature relocation acts like instant movement generator, so current generator expects interrupt/reset calls to react properly + if (!c->GetMotionMaster()->empty()) + if (MovementGenerator *movgen = c->GetMotionMaster()->top()) + movgen->Interrupt(*c); + + GetMap()->CreatureRelocation((Creature*)this, x, y, z, 0.0f); + + // finished relocation, movegen can different from top before creature relocation, + // but apply Reset expected to be safe in any case + if (!c->GetMotionMaster()->empty()) + if (MovementGenerator *movgen = c->GetMotionMaster()->top()) + movgen->Reset(*c); } } diff --git a/src/game/Unit.h b/src/game/Unit.h index dff9adc420a..54e2e9f5a33 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1357,8 +1357,13 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false); - void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, SplineFlags flags, uint32 Time, Player* player = NULL); + void MonsterMove(float x, float y, float z, uint32 transitTime); + void MonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0); + + // recommend use MonsterMove/MonsterMoveWithSpeed for most case that correctly work with movegens + void SendMonsterMove(float x, float y, float z, SplineType type, SplineFlags flags, uint32 Time, Player* player = NULL); void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, SplineFlags flags); + void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL); void SendHighestThreatUpdate(HostileReference* pHostileReference); void SendThreatClear(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 2d81e23a09d..b9873e646a1 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 "9400" + #define REVISION_NR "9401" #endif // __REVISION_NR_H__