Fix the relocation of creatures across cells. Try to fix #3054.

This commit is contained in:
megamage
2011-10-07 17:36:23 -04:00
parent 381cf2f9d3
commit eb8cbae0d5
6 changed files with 99 additions and 53 deletions

View File

@@ -57,20 +57,8 @@ ObjectGridRespawnMover::Visit(CreatureMapType &m)
Creature* c = iter->getSource();
++iter;
ASSERT(!c->isPet() && "ObjectGridRespawnMover don't must be called for pets");
Cell const& cur_cell = c->GetCurrentCell();
float resp_x, resp_y, resp_z;
c->GetRespawnCoord(resp_x, resp_y, resp_z);
CellPair resp_val = Trinity::ComputeCellPair(resp_x, resp_y);
Cell resp_cell(resp_val);
if (cur_cell.DiffGrid(resp_cell))
{
c->GetMap()->CreatureRespawnRelocation(c);
// false result ignored: will be unload with other creatures at grid
}
ASSERT(!c->isPet() && "ObjectGridRespawnMover must not be called for pets");
c->GetMap()->CreatureRespawnRelocation(c, true);
}
}
@@ -94,11 +82,11 @@ class ObjectWorldLoader
uint32 i_corpses;
};
template<class T> void AddUnitState(T* /*obj*/, CellPair const& /*cell_pair*/)
template<class T> static void ObjectGridLoader::SetObjectCell(T* /*obj*/, CellPair const& /*cell_pair*/)
{
}
template<> void AddUnitState(Creature* obj, CellPair const& cell_pair)
template<> static void ObjectGridLoader::SetObjectCell(Creature* obj, CellPair const& cell_pair)
{
Cell cell(cell_pair);
@@ -109,7 +97,7 @@ template <class T>
void AddObjectHelper(CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* map, T *obj)
{
obj->GetGridRef().link(&m, obj);
AddUnitState(obj, cell);
ObjectGridLoader::SetObjectCell(obj, cell);
obj->AddToWorld();
if (obj->isActiveObject())
map->AddToActive(obj);