*Use unified function in loadhelper.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-11 11:11:22 -05:00
parent a51cc015fa
commit d4165ac36e

View File

@@ -109,6 +109,18 @@ template<> void addUnitState(Creature *obj, CellPair const& cell_pair)
obj->setDeathState(DEAD);
}
template <class T>
void AddObjectHelper(CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* map, T *obj)
{
obj->GetGridRef().link(&m, obj);
addUnitState(obj,cell);
obj->AddToWorld();
if(obj->isActiveObject())
map->AddToActive(obj);
++count;
}
template <class T>
void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* map)
{
@@ -123,14 +135,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &
continue;
}
obj->GetGridRef().link(&m, obj);
addUnitState(obj,cell);
obj->AddToWorld();
if(obj->isActiveObject())
map->AddToActive(obj);
++count;
AddObjectHelper(cell, m, count, map, obj);
}
}
@@ -152,14 +157,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, CreatureMapType &m,
}
}
obj->GetGridRef().link(&m, obj);
addUnitState(obj,cell);
obj->AddToWorld();
if(obj->isActiveObject())
map->AddToActive(obj);
++count;
AddObjectHelper(cell, m, count, map, obj);
}
}
@@ -179,13 +177,7 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType
if(!obj)
continue;
obj->GetGridRef().link(&m, obj);
addUnitState(obj,cell);
obj->AddToWorld();
if(obj->isActiveObject())
map->AddToActive(obj);
++count;
AddObjectHelper(cell, m, count, map, obj);
}
}