[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

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