diff options
| author | megamage <none@none> | 2009-01-08 22:12:09 -0600 | 
|---|---|---|
| committer | megamage <none@none> | 2009-01-08 22:12:09 -0600 | 
| commit | ea0421919a86e3d803a86d78c102c1a2567630a1 (patch) | |
| tree | 9db1ac1075141ad0e864f570f014f60740fbeddc | |
| parent | 2377f49ea86b5c6a7f29b5d1949cd90b1594b660 (diff) | |
*Try to fix the bug of visibility update.
--HG--
branch : trunk
| -rw-r--r-- | src/game/Player.cpp | 3 | ||||
| -rw-r--r-- | src/game/Unit.cpp | 40 | ||||
| -rw-r--r-- | src/game/Unit.h | 1 | ||||
| -rw-r--r-- | src/game/WorldSession.cpp | 2 | 
4 files changed, 25 insertions, 21 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 5dfc9a412b1..daf589dd9aa 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1735,6 +1735,9 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati              ResetContestedPvP(); +            DestroyForNearbyPlayers(); +            m_clientGUIDs.clear(); +              // remove player from battleground on far teleport (when changing maps)              if(BattleGround const* bg = GetBattleGround())              { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0bf8faa5bb2..e6661145439 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9967,6 +9967,24 @@ bool Unit::canDetectStealthOf(Unit const* target, float distance) const      return distance < visibleDistance;  } +void Unit::DestroyForNearbyPlayers() +{ +    if(!IsInWorld()) +        return; + +    std::list<Unit*> targets; +    Trinity::AnyUnitInObjectRangeCheck check(this, World::GetMaxVisibleDistance()); +    Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck> searcher(targets, check); +    VisitNearbyWorldObject(World::GetMaxVisibleDistance(), searcher); +    for(std::list<Unit*>::iterator iter = targets.begin(); iter != targets.end(); ++iter) +        if(*iter != this && (*iter)->GetTypeId() == TYPEID_PLAYER +            && ((Player*)(*iter))->HaveAtClient(this)) +        { +            DestroyForPlayer((Player*)(*iter)); +            ((Player*)(*iter))->m_clientGUIDs.erase(GetGUID()); +        } +} +  void Unit::SetVisibility(UnitVisibility x)  {      m_Visibility = x; @@ -9975,27 +9993,7 @@ void Unit::SetVisibility(UnitVisibility x)          SetToNotify();      if(x == VISIBILITY_GROUP_STEALTH) -    { -        std::list<Unit*> targets; -        Trinity::AnyUnitInObjectRangeCheck check(this, World::GetMaxVisibleDistance()); -        Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck> searcher(targets, check); -        VisitNearbyWorldObject(World::GetMaxVisibleDistance(), searcher); -        for(std::list<Unit*>::iterator iter = targets.begin(); iter != targets.end(); ++iter) -            if(*iter != this && (*iter)->GetTypeId() == TYPEID_PLAYER -                && ((Player*)(*iter))->HaveAtClient(this)) -            { -                DestroyForPlayer((Player*)(*iter)); -                ((Player*)(*iter))->m_clientGUIDs.erase(GetGUID()); -            } -    } -    /*{ -        Map *m = GetMap(); - -        if(GetTypeId()==TYPEID_PLAYER) -            m->PlayerRelocation((Player*)this,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); -        else -            m->CreatureRelocation((Creature*)this,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); -    }*/ +        DestroyForNearbyPlayers();  }  void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) diff --git a/src/game/Unit.h b/src/game/Unit.h index da85bd53d1a..85de2c871ef 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1214,6 +1214,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject          // Visibility system          UnitVisibility GetVisibility() const { return m_Visibility; }          void SetVisibility(UnitVisibility x); +        void DestroyForNearbyPlayers();          // common function for visibility checks for player/creatures with detection code          virtual bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const; diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index eb2612a1543..c3ec18ae1b7 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -255,6 +255,8 @@ void WorldSession::LogoutPlayer(bool Save)          // Remove any possession of this player on logout          _player->RemoveCharmedOrPossessedBy(NULL); +        _player->DestroyForNearbyPlayers(); +          if (uint64 lguid = GetPlayer()->GetLootGUID())              DoLootRelease(lguid);  | 
