From 5d9d64e6f048298a19f4c80795f05e31facb2318 Mon Sep 17 00:00:00 2001 From: megamage Date: Thu, 30 Jul 2009 10:38:53 +0800 Subject: [8229] Improve stealth detection code for player case. Author: Ambal --HG-- branch : trunk --- src/game/Player.cpp | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'src/game/Player.cpp') diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 1535290af27..5659f14f28a 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1329,8 +1329,8 @@ void Player::Update( uint32 p_time ) { if (p_time >= m_DetectInvTimer) { - m_DetectInvTimer = 3000; HandleStealthedUnitsDetection(); + m_DetectInvTimer = 3000; } else m_DetectInvTimer -= p_time; @@ -17552,19 +17552,38 @@ void Player::HandleStealthedUnitsDetection() Trinity::UnitListSearcher searcher(this, stealthedUnits, u_check); VisitNearbyObject(World::GetMaxVisibleDistance(), searcher); - for (std::list::iterator i = stealthedUnits.begin(); i != stealthedUnits.end(); ++i) + for (std::list::const_iterator i = stealthedUnits.begin(); i != stealthedUnits.end(); ++i) { - if (!HaveAtClient(*i) && canSeeOrDetect(*i, true)) + if((*i)==this) + continue; + + bool hasAtClient = HaveAtClient((*i)); + bool hasDetected = canSeeOrDetect(*i, true); + + if (hasDetected) { - (*i)->SendUpdateToPlayer(this); - m_clientGUIDs.insert((*i)->GetGUID()); + if(!hasAtClient) + { + (*i)->SendUpdateToPlayer(this); + m_clientGUIDs.insert((*i)->GetGUID()); - #ifdef TRINITY_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) - sLog.outDebug("Object %u (Type: %u) is detected in stealth by player %u. Distance = %f",(*i)->GetGUIDLow(),(*i)->GetTypeId(),GetGUIDLow(),GetDistance(*i)); - #endif + #ifdef MANGOS_DEBUG + if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) + sLog.outDebug("Object %u (Type: %u) is detected in stealth by player %u. Distance = %f",(*i)->GetGUIDLow(),(*i)->GetTypeId(),GetGUIDLow(),GetDistance(*i)); + #endif - SendInitialVisiblePackets(*i); + // target aura duration for caster show only if target exist at caster client + // send data at target visibility change (adding to client) + SendInitialVisiblePackets(*i); + } + } + else + { + if(hasAtClient) + { + (*i)->DestroyForPlayer(this); + m_clientGUIDs.erase((*i)->GetGUID()); + } } } } -- cgit v1.2.3