From f52a5a6dc722bcb54df57d6ae0a879457689de3e Mon Sep 17 00:00:00 2001 From: megamage Date: Sat, 20 Dec 2008 12:27:55 -0600 Subject: [PATCH] *Fix a bug that stealth causes nearby players lag. --HG-- branch : trunk --- src/game/Player.cpp | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index e3e98805ce..9bbd48e186 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -16686,33 +16686,14 @@ void Player::SetRestBonus (float rest_bonus_new) void Player::HandleStealthedUnitsDetection() { std::list stealthedUnits; - - CellPair p(Trinity::ComputeCellPair(GetPositionX(),GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - Trinity::AnyStealthedCheck u_check; Trinity::UnitListSearcher searcher(stealthedUnits, u_check); + VisitNearbyObject(World::GetMaxVisibleDistance(), searcher); - TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); - - for (std::list::iterator i = stealthedUnits.begin(); i != stealthedUnits.end();) + for (std::list::iterator i = stealthedUnits.begin(); i != stealthedUnits.end(); ++i) { - if((*i)==this) + if (!HaveAtClient(*i) && canSeeOrDetect(*i, true)) { - i = stealthedUnits.erase(i); - continue; - } - - if ((*i)->isVisibleForOrDetect(this,true)) - { - (*i)->SendUpdateToPlayer(this); m_clientGUIDs.insert((*i)->GetGUID()); @@ -16734,12 +16715,7 @@ void Player::HandleStealthedUnitsDetection() ((Unit*)(*i))->SendAttackStart(((Unit*)(*i))->getVictim()); } } - - i = stealthedUnits.erase(i); - continue; } - - ++i; } }