mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[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:
parent
c044d64618
commit
54559b5c03
8 changed files with 93 additions and 50 deletions
|
|
@ -764,7 +764,7 @@ bool Creature::isCanTrainingAndResetTalentsOf(Player* pPlayer) const
|
||||||
&& pPlayer->getClass() == GetCreatureInfo()->trainer_class;
|
&& 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();
|
/* uint32 timeElap = getMSTime();
|
||||||
if ((timeElap - m_startMove) < m_moveTime)
|
if ((timeElap - m_startMove) < m_moveTime)
|
||||||
|
|
@ -2057,25 +2057,6 @@ void Creature::SendMonsterMoveWithSpeedToCurrentDestination(Player* player)
|
||||||
SendMonsterMoveWithSpeed(x, y, z, 0, 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)
|
void Creature::SendAreaSpiritHealerQueryOpcode(Player *pl)
|
||||||
{
|
{
|
||||||
uint32 next_resurrect = 0;
|
uint32 next_resurrect = 0;
|
||||||
|
|
|
||||||
|
|
@ -438,7 +438,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||||
|
|
||||||
bool AIM_Initialize();
|
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; }
|
CreatureAI* AI() { return i_AI; }
|
||||||
|
|
||||||
void AddSplineFlag(SplineFlags f)
|
void AddSplineFlag(SplineFlags f)
|
||||||
|
|
@ -465,7 +465,6 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||||
UpdateWalkMode(this, false);
|
UpdateWalkMode(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
|
|
||||||
void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
|
void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
|
||||||
|
|
||||||
uint32 GetShieldBlockValue() const //dunno mob block value
|
uint32 GetShieldBlockValue() const //dunno mob block value
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
#include "MapRefManager.h"
|
#include "MapRefManager.h"
|
||||||
#include "DBCEnums.h"
|
#include "DBCEnums.h"
|
||||||
#include "MovementGenerator.h"
|
|
||||||
|
|
||||||
#include "MapInstanced.h"
|
#include "MapInstanced.h"
|
||||||
#include "InstanceSaveMgr.h"
|
#include "InstanceSaveMgr.h"
|
||||||
|
|
@ -891,11 +890,6 @@ Map::PlayerRelocation(Player *player, float x, float y, float z, float orientati
|
||||||
void
|
void
|
||||||
Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang)
|
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));
|
assert(CheckGridIntegrity(creature,false));
|
||||||
|
|
||||||
Cell old_cell = creature->GetCurrentCell();
|
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));
|
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)
|
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());
|
sLog.outError("SCRIPT_COMMAND_MOVE_TO call for non-creature (TypeId: %u), skipping.",source->GetTypeId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
((Creature*)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, step.script->datalong2 );
|
((Unit*)source)->MonsterMoveWithSpeed(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);
|
|
||||||
break;
|
break;
|
||||||
case SCRIPT_COMMAND_FLAG_SET:
|
case SCRIPT_COMMAND_FLAG_SET:
|
||||||
if(!source)
|
if(!source)
|
||||||
|
|
|
||||||
|
|
@ -6428,10 +6428,7 @@ void Spell::EffectCharge(uint32 /*i*/)
|
||||||
((Creature *)unitTarget)->StopMoving();
|
((Creature *)unitTarget)->StopMoving();
|
||||||
|
|
||||||
// Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags
|
// 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);
|
m_caster->MonsterMove(x, y, z, 1);
|
||||||
|
|
||||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
|
||||||
m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, x, y, z, m_caster->GetOrientation());
|
|
||||||
|
|
||||||
// not all charge effects used in negative spells
|
// not all charge effects used in negative spells
|
||||||
if (unitTarget != m_caster && !IsPositiveSpell(m_spellInfo->Id))
|
if (unitTarget != m_caster && !IsPositiveSpell(m_spellInfo->Id))
|
||||||
|
|
@ -6456,10 +6453,7 @@ void Spell::EffectCharge2(uint32 /*i*/)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags
|
// 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);
|
m_caster->MonsterMove(x, y, z, 1);
|
||||||
|
|
||||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
|
||||||
m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, x, y, z, m_caster->GetOrientation());
|
|
||||||
|
|
||||||
// not all charge effects used in negative spells
|
// not all charge effects used in negative spells
|
||||||
if (unitTarget && unitTarget != m_caster && !IsPositiveSpell(m_spellInfo->Id))
|
if (unitTarget && unitTarget != m_caster && !IsPositiveSpell(m_spellInfo->Id))
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ inline float Traveller<Creature>::GetMoveDestinationTo(float x, float y, float z
|
||||||
template<>
|
template<>
|
||||||
inline void Traveller<Creature>::MoveTo(float x, float y, float z, uint32 t)
|
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
|
// specialization for players
|
||||||
|
|
@ -138,7 +138,7 @@ template<>
|
||||||
inline void Traveller<Player>::MoveTo(float x, float y, float z, uint32 t)
|
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
|
//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;
|
typedef Traveller<Creature> CreatureTraveller;
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
#include "Path.h"
|
#include "Path.h"
|
||||||
#include "Traveller.h"
|
#include "Traveller.h"
|
||||||
#include "VMapFactory.h"
|
#include "VMapFactory.h"
|
||||||
|
#include "MovementGenerator.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
@ -364,7 +365,7 @@ bool Unit::haveOffhandWeapon() const
|
||||||
return false;
|
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;
|
float moveTime = (float)Time;
|
||||||
|
|
||||||
|
|
@ -431,6 +432,26 @@ void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, Spl
|
||||||
SendMessageToSet(&data, true);
|
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
|
void Unit::BuildHeartBeatMsg(WorldPacket *data) const
|
||||||
{
|
{
|
||||||
MovementFlags move_flags = GetTypeId()==TYPEID_PLAYER
|
MovementFlags move_flags = GetTypeId()==TYPEID_PLAYER
|
||||||
|
|
@ -12475,7 +12496,7 @@ void Unit::StopMoving()
|
||||||
|
|
||||||
// send explicit stop packet
|
// send explicit stop packet
|
||||||
// player expected for correct work SPLINEFLAG_WALKMODE
|
// 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
|
// update position and orientation for near players
|
||||||
WorldPacket data;
|
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));
|
((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
|
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);
|
GetMap()->CreatureRelocation((Creature*)this, x, y, z, orientation);
|
||||||
|
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
BuildHeartBeatMsg(&data);
|
BuildHeartBeatMsg(&data);
|
||||||
SendMessageToSet(&data, false);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 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 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 SendHighestThreatUpdate(HostileReference* pHostileReference);
|
||||||
void SendThreatClear();
|
void SendThreatClear();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9400"
|
#define REVISION_NR "9401"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue