[9400] Creature relocation acts like instant movement generator, so current generator expects interrupt/reset calls to react properly.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
Lynx3d 2010-02-16 23:08:00 +03:00 committed by VladimirMangos
parent d536661cbf
commit c044d64618
2 changed files with 16 additions and 3 deletions

View file

@ -35,6 +35,7 @@
#include "Group.h"
#include "MapRefManager.h"
#include "DBCEnums.h"
#include "MovementGenerator.h"
#include "MapInstanced.h"
#include "InstanceSaveMgr.h"
@ -890,6 +891,11 @@ 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();
@ -912,7 +918,14 @@ Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang
creature->Relocate(x, y, z, ang);
CreatureRelocationNotify(creature, new_cell, new_val);
}
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)

View file

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