Skip to content

Commit

Permalink
Adjustments to spell facing
Browse files Browse the repository at this point in the history
 - Adjusted HaveAtClient to accept Object* (still accepts all
   subordinates)
 - Use grid searcher to find players in visibility range for unit
 - Use client cache instead of "See or Detect" to decide who to send
   updates to
 - Adjusted SendUpdateToPlayer to send createobject packet only if not
   known to client
  • Loading branch information
r00ty-tc committed Mar 22, 2016
1 parent ecf15a1 commit c0693a6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/server/game/Entities/Creature/Creature.cpp
Expand Up @@ -2786,12 +2786,13 @@ bool Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target)
)
)
{
const MapRefManager& mapPlayers = GetMap()->GetPlayers();
for (MapRefManager::const_iterator it = mapPlayers.begin(); it != mapPlayers.end(); ++it)
if (Player* player = (*it).GetSource())
std::list<Player*> targets;
this->GetPlayerListInGrid(targets, GetVisibilityRange());
for (std::list<Player*>::const_iterator it = targets.begin(); it != targets.end(); ++it)
if (Player* player = *it)
{
// only update players that can both see us, and are actually in combat with us (this is a performance tradeoff)
if (player->CanSeeOrDetect(this, false, true) && IsInCombatWith(player))
// only update players that are known to the client (have already been created), and are actually in combat with us
if (player->HaveAtClient(this) && IsInCombatWith(player))
{
SendUpdateToPlayer(player);
shouldDelay = true;
Expand Down
5 changes: 4 additions & 1 deletion src/server/game/Entities/Object/Object.cpp
Expand Up @@ -221,7 +221,10 @@ void Object::SendUpdateToPlayer(Player* player)
UpdateData upd;
WorldPacket packet;

BuildCreateUpdateBlockForPlayer(&upd, player);
if (player->HaveAtClient(this))
BuildValuesUpdateBlockForPlayer(&upd, player);
else
BuildCreateUpdateBlockForPlayer(&upd, player);
upd.BuildPacket(&packet);
player->GetSession()->SendPacket(&packet);
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/Player/Player.cpp
Expand Up @@ -21943,7 +21943,7 @@ WorldLocation Player::GetStartPosition() const
return WorldLocation(mapId, info->positionX, info->positionY, info->positionZ, 0);
}

bool Player::HaveAtClient(WorldObject const* u) const
bool Player::HaveAtClient(Object const* u) const
{
return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end();
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/Player/Player.h
Expand Up @@ -2097,7 +2097,7 @@ class Player : public Unit, public GridObject<Player>
// currently visible objects at player client
GuidUnorderedSet m_clientGUIDs;

bool HaveAtClient(WorldObject const* u) const;
bool HaveAtClient(Object const* u) const;

bool IsNeverVisible() const override;

Expand Down

0 comments on commit c0693a6

Please sign in to comment.