mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Maps: Removed dbguid/spawnid grid searchers, they are no longer neccessary
This commit is contained in:
@@ -177,33 +177,25 @@ class SmartScript
|
||||
|
||||
GameObject* FindGameObjectNear(WorldObject* searchObject, ObjectGuid::LowType guid) const
|
||||
{
|
||||
GameObject* gameObject = NULL;
|
||||
auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
|
||||
if (bounds.first == bounds.second)
|
||||
return nullptr;
|
||||
|
||||
CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
|
||||
Cell cell(p);
|
||||
|
||||
Trinity::GameObjectWithDbGUIDCheck goCheck(*searchObject, guid);
|
||||
Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(searchObject, gameObject, goCheck);
|
||||
|
||||
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker);
|
||||
cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
|
||||
|
||||
return gameObject;
|
||||
return bounds.first->second;
|
||||
}
|
||||
|
||||
Creature* FindCreatureNear(WorldObject* searchObject, ObjectGuid::LowType guid) const
|
||||
{
|
||||
Creature* creature = NULL;
|
||||
CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
|
||||
Cell cell(p);
|
||||
auto bounds = searchObject->GetMap()->GetCreatureBySpawnIdStore().equal_range(guid);
|
||||
if (bounds.first == bounds.second)
|
||||
return nullptr;
|
||||
|
||||
Trinity::CreatureWithDbGUIDCheck target_check(searchObject, guid);
|
||||
Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(searchObject, creature, target_check);
|
||||
auto creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair)
|
||||
{
|
||||
return pair.second->IsAlive();
|
||||
});
|
||||
|
||||
TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);
|
||||
cell.Visit(p, unit_checker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
|
||||
|
||||
return creature;
|
||||
return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
|
||||
}
|
||||
|
||||
ObjectListMap* mTargetStorage;
|
||||
|
||||
@@ -796,15 +796,11 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(ObjectGuid::Lo
|
||||
|
||||
if (!obj && sObjectMgr->GetGOData(lowguid)) // guid is DB guid of object
|
||||
{
|
||||
// search near player then
|
||||
CellCoord p(Trinity::ComputeCellCoord(pl->GetPositionX(), pl->GetPositionY()));
|
||||
Cell cell(p);
|
||||
auto bounds = pl->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
|
||||
if (bounds.first == bounds.second)
|
||||
return nullptr;
|
||||
|
||||
Trinity::GameObjectWithDbGUIDCheck go_check(*pl, lowguid);
|
||||
Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(pl, obj, go_check);
|
||||
|
||||
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);
|
||||
cell.Visit(p, object_checker, *pl->GetMap(), *pl, pl->GetGridActivationRange());
|
||||
return bounds.first->second;
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
||||
@@ -736,18 +736,6 @@ namespace Trinity
|
||||
NearestGameObjectTypeInObjectRangeCheck(NearestGameObjectTypeInObjectRangeCheck const&);
|
||||
};
|
||||
|
||||
class GameObjectWithDbGUIDCheck
|
||||
{
|
||||
public:
|
||||
GameObjectWithDbGUIDCheck(WorldObject const& /*obj*/, ObjectGuid::LowType db_guid) : i_db_guid(db_guid) { }
|
||||
bool operator()(GameObject const* go) const
|
||||
{
|
||||
return go->GetSpawnId() == i_db_guid;
|
||||
}
|
||||
private:
|
||||
ObjectGuid::LowType i_db_guid;
|
||||
};
|
||||
|
||||
// Unit checks
|
||||
|
||||
class MostHPMissingInRange
|
||||
@@ -849,18 +837,6 @@ namespace Trinity
|
||||
float i_range;
|
||||
};
|
||||
|
||||
class CreatureWithDbGUIDCheck
|
||||
{
|
||||
public:
|
||||
CreatureWithDbGUIDCheck(WorldObject const* /*obj*/, ObjectGuid::LowType lowguid) : i_lowguid(lowguid) { }
|
||||
bool operator()(Creature* u)
|
||||
{
|
||||
return u->GetSpawnId() == i_lowguid;
|
||||
}
|
||||
private:
|
||||
ObjectGuid::LowType i_lowguid;
|
||||
};
|
||||
|
||||
class AnyFriendlyUnitInObjectRangeCheck
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -283,18 +283,11 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script
|
||||
|
||||
inline GameObject* Map::_FindGameObject(WorldObject* searchObject, ObjectGuid::LowType guid) const
|
||||
{
|
||||
GameObject* gameobject = NULL;
|
||||
auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
|
||||
if (bounds.first == bounds.second)
|
||||
return nullptr;
|
||||
|
||||
CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
|
||||
Cell cell(p);
|
||||
|
||||
Trinity::GameObjectWithDbGUIDCheck goCheck(*searchObject, guid);
|
||||
Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(searchObject, gameobject, goCheck);
|
||||
|
||||
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker);
|
||||
cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
|
||||
|
||||
return gameobject;
|
||||
return bounds.first->second;
|
||||
}
|
||||
|
||||
/// Process queued scripts
|
||||
@@ -806,26 +799,17 @@ void Map::ScriptsProcess()
|
||||
}
|
||||
|
||||
Creature* cTarget = NULL;
|
||||
WorldObject* wSource = dynamic_cast <WorldObject*> (source);
|
||||
if (wSource) //using grid searcher
|
||||
WorldObject* wSource = dynamic_cast<WorldObject*>(source);
|
||||
auto creatureBounds = _creatureBySpawnIdStore.equal_range(step.script->CallScript.CreatureEntry);
|
||||
if (creatureBounds.first != creatureBounds.second)
|
||||
{
|
||||
CellCoord p(Trinity::ComputeCellCoord(wSource->GetPositionX(), wSource->GetPositionY()));
|
||||
Cell cell(p);
|
||||
|
||||
Trinity::CreatureWithDbGUIDCheck target_check(wSource, uint64(step.script->CallScript.CreatureEntry));
|
||||
Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(wSource, cTarget, target_check);
|
||||
|
||||
TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);
|
||||
cell.Visit(p, unit_checker, *wSource->GetMap(), *wSource, wSource->GetGridActivationRange());
|
||||
}
|
||||
else //check hashmap holders
|
||||
{
|
||||
if (sObjectMgr->GetCreatureData(step.script->CallScript.CreatureEntry))
|
||||
// Prefer alive (last respawned) creature
|
||||
auto creatureItr = std::find_if(creatureBounds.first, creatureBounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair)
|
||||
{
|
||||
auto creatureBounds = _creatureBySpawnIdStore.equal_range(step.script->CallScript.CreatureEntry);
|
||||
if (creatureBounds.first != creatureBounds.second)
|
||||
cTarget = creatureBounds.first->second;
|
||||
}
|
||||
return pair.second->IsAlive();
|
||||
});
|
||||
|
||||
cTarget = creatureItr != creatureBounds.second ? creatureItr->second : creatureBounds.first->second;
|
||||
}
|
||||
|
||||
if (!cTarget)
|
||||
|
||||
Reference in New Issue
Block a user