mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
Move visibility update functions to more appropriate classes.
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
4041121fd8
commit
63897d56d7
10 changed files with 47 additions and 44 deletions
|
|
@ -159,7 +159,7 @@ void Creature::RemoveCorpse()
|
|||
|
||||
m_deathTimer = 0;
|
||||
setDeathState(DEAD);
|
||||
ObjectAccessor::UpdateObjectVisibility(this);
|
||||
UpdateObjectVisibility();
|
||||
loot.clear();
|
||||
uint32 respawnDelay = m_respawnDelay;
|
||||
if (AI())
|
||||
|
|
@ -1585,9 +1585,9 @@ void Creature::Respawn()
|
|||
// forced recreate creature object at clients
|
||||
UnitVisibility currentVis = GetVisibility();
|
||||
SetVisibility(VISIBILITY_RESPAWN);
|
||||
ObjectAccessor::UpdateObjectVisibility(this);
|
||||
UpdateObjectVisibility();
|
||||
SetVisibility(currentVis); // restore visibility state
|
||||
ObjectAccessor::UpdateObjectVisibility(this);
|
||||
UpdateObjectVisibility();
|
||||
|
||||
if(getDeathState()==DEAD)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ void GameObject::Update(uint32 /*p_time*/)
|
|||
if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY))
|
||||
SaveRespawnTime();
|
||||
|
||||
ObjectAccessor::UpdateObjectVisibility(this);
|
||||
UpdateObjectVisibility();
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -372,11 +372,11 @@ void WorldSession::SendSpiritResurrect()
|
|||
_player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation());
|
||||
// or update at original position
|
||||
else
|
||||
ObjectAccessor::UpdateVisibilityForPlayer(_player);
|
||||
_player->UpdateVisibilityForPlayer();
|
||||
}
|
||||
// or update at original position
|
||||
else
|
||||
ObjectAccessor::UpdateVisibilityForPlayer(_player);
|
||||
_player->UpdateVisibilityForPlayer();
|
||||
|
||||
_player->SaveToDB();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1852,7 +1852,7 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
|
|||
m_phaseMask = newPhaseMask;
|
||||
|
||||
if(update && IsInWorld())
|
||||
ObjectAccessor::UpdateObjectVisibility(this);
|
||||
UpdateObjectVisibility();
|
||||
}
|
||||
|
||||
void WorldObject::PlayDistanceSound( uint32 sound_id, Player* target /*= NULL*/ )
|
||||
|
|
@ -1875,3 +1875,12 @@ void WorldObject::PlayDirectSound( uint32 sound_id, Player* target /*= NULL*/ )
|
|||
else
|
||||
SendMessageToSet( &data, true );
|
||||
}
|
||||
|
||||
void WorldObject::UpdateObjectVisibility()
|
||||
{
|
||||
CellPair p = MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY());
|
||||
Cell cell(p);
|
||||
|
||||
GetMap()->UpdateObjectVisibility(this, cell, p);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -474,6 +474,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object
|
|||
virtual void SaveRespawnTime() {}
|
||||
void AddObjectToRemoveList();
|
||||
|
||||
void UpdateObjectVisibility();
|
||||
|
||||
// main visibility check function in normal case (ignore grey zone distance check)
|
||||
bool isVisibleFor(Player const* u, WorldObject const* viewPoint) const { return isVisibleForInState(u,viewPoint,false); }
|
||||
|
||||
|
|
|
|||
|
|
@ -442,36 +442,6 @@ ObjectAccessor::WorldObjectChangeAccumulator::Visit(PlayerMapType &m)
|
|||
ObjectAccessor::_buildPacket(iter->getSource(), &i_object, i_updateDatas);
|
||||
}
|
||||
|
||||
void
|
||||
ObjectAccessor::UpdateObjectVisibility(WorldObject *obj)
|
||||
{
|
||||
CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
|
||||
Cell cell(p);
|
||||
|
||||
obj->GetMap()->UpdateObjectVisibility(obj, cell, p);
|
||||
}
|
||||
|
||||
void ObjectAccessor::UpdateVisibilityForPlayer( Player* player )
|
||||
{
|
||||
WorldObject const* viewPoint = player->GetViewPoint();
|
||||
Map* m = player->GetMap();
|
||||
|
||||
CellPair p(MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()));
|
||||
Cell cell(p);
|
||||
|
||||
m->UpdatePlayerVisibility(player, cell, p);
|
||||
|
||||
if (player!=viewPoint)
|
||||
{
|
||||
CellPair pView(MaNGOS::ComputeCellPair(viewPoint->GetPositionX(), viewPoint->GetPositionY()));
|
||||
Cell cellView(pView);
|
||||
|
||||
m->UpdateObjectsVisibilityFor(player, cellView, pView);
|
||||
}
|
||||
else
|
||||
m->UpdateObjectsVisibilityFor(player, cell, p);
|
||||
}
|
||||
|
||||
/// Define the static member of HashMapHolder
|
||||
|
||||
template <class T> UNORDERED_MAP< uint64, T* > HashMapHolder<T>::m_objectMap;
|
||||
|
|
|
|||
|
|
@ -202,8 +202,6 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
|
|||
static void UpdateObject(Object* obj, Player* exceptPlayer);
|
||||
static void _buildUpdateObject(Object* obj, UpdateDataMapType &);
|
||||
|
||||
static void UpdateObjectVisibility(WorldObject* obj);
|
||||
static void UpdateVisibilityForPlayer(Player* player);
|
||||
private:
|
||||
struct WorldObjectChangeAccumulator
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2229,7 +2229,7 @@ void Player::SetGameMaster(bool on)
|
|||
getHostilRefManager().setOnlineOfflineState(true);
|
||||
}
|
||||
|
||||
ObjectAccessor::UpdateVisibilityForPlayer(this);
|
||||
UpdateVisibilityForPlayer();
|
||||
}
|
||||
|
||||
void Player::SetGMVisible(bool on)
|
||||
|
|
@ -4142,7 +4142,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
|
|||
UpdateZone(newzone,newarea);
|
||||
|
||||
// update visibility
|
||||
ObjectAccessor::UpdateVisibilityForPlayer(this);
|
||||
UpdateVisibilityForPlayer();
|
||||
|
||||
if(!applySickness)
|
||||
return;
|
||||
|
|
@ -4195,7 +4195,7 @@ void Player::KillPlayer()
|
|||
// don't create corpse at this moment, player might be falling
|
||||
|
||||
// update visibility
|
||||
ObjectAccessor::UpdateObjectVisibility(this);
|
||||
UpdateObjectVisibility();
|
||||
}
|
||||
|
||||
void Player::CreateCorpse()
|
||||
|
|
@ -20616,5 +20616,27 @@ void Player::SetFarSightGUID( uint64 guid )
|
|||
SetUInt64Value(PLAYER_FARSIGHT, guid);
|
||||
|
||||
// need triggering load grids around new view point
|
||||
ObjectAccessor::UpdateVisibilityForPlayer(this);
|
||||
UpdateVisibilityForPlayer();
|
||||
}
|
||||
|
||||
void Player::UpdateVisibilityForPlayer()
|
||||
{
|
||||
WorldObject const* viewPoint = GetViewPoint();
|
||||
Map* m = GetMap();
|
||||
|
||||
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
|
||||
Cell cell(p);
|
||||
|
||||
m->UpdatePlayerVisibility(this, cell, p);
|
||||
|
||||
if (this != viewPoint)
|
||||
{
|
||||
CellPair pView(MaNGOS::ComputeCellPair(viewPoint->GetPositionX(), viewPoint->GetPositionY()));
|
||||
Cell cellView(pView);
|
||||
|
||||
m->UpdateObjectsVisibilityFor(this, cellView, pView);
|
||||
}
|
||||
else
|
||||
m->UpdateObjectsVisibilityFor(this, cell, p);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1033,6 +1033,8 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
bool CanInteractWithNPCs(bool alive = true) const;
|
||||
GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const;
|
||||
|
||||
void UpdateVisibilityForPlayer();
|
||||
|
||||
bool ToggleAFK();
|
||||
bool ToggleDND();
|
||||
bool isAFK() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_AFK); };
|
||||
|
|
|
|||
|
|
@ -3910,7 +3910,7 @@ void Aura::HandleInvisibilityDetect(bool apply, bool Real)
|
|||
m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
|
||||
}
|
||||
if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
|
||||
ObjectAccessor::UpdateVisibilityForPlayer((Player*)m_target);
|
||||
((Player*)m_target)->UpdateVisibilityForPlayer();
|
||||
}
|
||||
|
||||
void Aura::HandleAuraModRoot(bool apply, bool Real)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue