[9401] Resolve porblems with waypoints moved/etc after [9400]

* Move movegen Interrupt/Reset calls from CreatureRelocation that called and from another movegens.
* Add this called to NearTeleportTo creature case and new MonsterMove* functions that considered
  as special moves similar instant movegens.
* NearTeleportTo/MonsterMove functions recomended used instead explicit use CreatureReolcation+SendMosterMOve pairs
  for proper reaction at movement from creature movement generators.
This commit is contained in:
VladimirMangos 2010-02-17 16:59:53 +03:00
parent c044d64618
commit 54559b5c03
8 changed files with 93 additions and 50 deletions

View file

@ -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<Player> traveller(*(Player*)this);
transitTime = traveller.GetTotalTrevelTimeTo(x, y, z);
}
else
{
Traveller<Creature> 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;

View file

@ -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

View file

@ -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)

View file

@ -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))

View file

@ -102,7 +102,7 @@ inline float Traveller<Creature>::GetMoveDestinationTo(float x, float y, float z
template<>
inline void Traveller<Creature>::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<Player>::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<Creature> CreatureTraveller;

View file

@ -47,6 +47,7 @@
#include "Path.h"
#include "Traveller.h"
#include "VMapFactory.h"
#include "MovementGenerator.h"
#include <math.h>
@ -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<Player> traveller(*(Player*)this);
transitTime = traveller.GetTotalTrevelTimeTo(x, y, z);
}
else
{
Traveller<Creature> 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);
}
}

View file

@ -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();

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9400"
#define REVISION_NR "9401"
#endif // __REVISION_NR_H__