aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-05-27 09:09:22 -0500
committermegamage <none@none>2009-05-27 09:09:22 -0500
commitcb72853dc6a9e7aa5301c1ab4e7fccbe1f34d2f4 (patch)
tree444980914b091b9add534251af6815452bda76bd /src
parent1497d8f3914177fff8a4ce0a69fb33ac2263b3c5 (diff)
*Cleanup message deliver functions. Remove unused parameters.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/GridNotifiers.cpp94
-rw-r--r--src/game/GridNotifiers.h50
-rw-r--r--src/game/Map.cpp20
-rw-r--r--src/game/Map.h8
-rw-r--r--src/game/Object.cpp8
-rw-r--r--src/game/Object.h4
-rw-r--r--src/game/Player.cpp14
-rw-r--r--src/game/Player.h6
8 files changed, 80 insertions, 124 deletions
diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp
index 091fb1c293a..5158f51d695 100644
--- a/src/game/GridNotifiers.cpp
+++ b/src/game/GridNotifiers.cpp
@@ -104,102 +104,73 @@ PlayerVisibilityNotifier::Notify()
}
void
-Deliverer::Visit(PlayerMapType &m)
+MessageDistDeliverer::Visit(PlayerMapType &m)
{
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
- //if (!i_source.InSamePhase(iter->getSource()))
- // continue;
if(!iter->getSource()->InSamePhase(i_phaseMask))
continue;
- if (!i_dist || iter->getSource()->GetDistance(&i_source) < i_dist)
- {
- // Send packet to all who are sharing the player's vision
- if (!iter->getSource()->GetSharedVisionList().empty())
- {
- SharedVisionList::const_iterator i = iter->getSource()->GetSharedVisionList().begin();
- for ( ; i != iter->getSource()->GetSharedVisionList().end(); ++i)
- if((*i)->m_seer == iter->getSource())
- SendPacket(*i);
- }
+ if(iter->getSource()->GetDistanceSq(&i_source) > i_distSq)
+ continue;
- VisitObject(iter->getSource());
+ // Send packet to all who are sharing the player's vision
+ if (!iter->getSource()->GetSharedVisionList().empty())
+ {
+ SharedVisionList::const_iterator i = iter->getSource()->GetSharedVisionList().begin();
+ for ( ; i != iter->getSource()->GetSharedVisionList().end(); ++i)
+ if((*i)->m_seer == iter->getSource())
+ SendPacket(*i);
}
+
+ SendPacket(iter->getSource());
}
}
void
-Deliverer::Visit(CreatureMapType &m)
+MessageDistDeliverer::Visit(CreatureMapType &m)
{
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
if(!iter->getSource()->InSamePhase(i_phaseMask))
continue;
- if (!i_dist || iter->getSource()->GetDistance(&i_source) < i_dist)
+ if(iter->getSource()->GetDistanceSq(&i_source) > i_distSq)
+ continue;
+
+ // Send packet to all who are sharing the creature's vision
+ if (!iter->getSource()->GetSharedVisionList().empty())
{
- // Send packet to all who are sharing the creature's vision
- if (!iter->getSource()->GetSharedVisionList().empty())
- {
- SharedVisionList::const_iterator i = iter->getSource()->GetSharedVisionList().begin();
- for ( ; i != iter->getSource()->GetSharedVisionList().end(); ++i)
- if((*i)->m_seer == iter->getSource())
- SendPacket(*i);
- }
+ SharedVisionList::const_iterator i = iter->getSource()->GetSharedVisionList().begin();
+ for ( ; i != iter->getSource()->GetSharedVisionList().end(); ++i)
+ if((*i)->m_seer == iter->getSource())
+ SendPacket(*i);
}
}
}
void
-Deliverer::Visit(DynamicObjectMapType &m)
+MessageDistDeliverer::Visit(DynamicObjectMapType &m)
{
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
if(!iter->getSource()->InSamePhase(i_phaseMask))
continue;
- if (!i_dist || iter->getSource()->GetDistance(&i_source) < i_dist)
+ if(iter->getSource()->GetDistanceSq(&i_source) > i_distSq)
+ continue;
+
+ if (IS_PLAYER_GUID(iter->getSource()->GetCasterGUID()))
{
- if (IS_PLAYER_GUID(iter->getSource()->GetCasterGUID()))
- {
- // Send packet back to the caster if the caster has vision of dynamic object
- Player* caster = (Player*)iter->getSource()->GetCaster();
- if (caster && caster->m_seer == iter->getSource())
- SendPacket(caster);
- }
+ // Send packet back to the caster if the caster has vision of dynamic object
+ Player* caster = (Player*)iter->getSource()->GetCaster();
+ if (caster && caster->m_seer == iter->getSource())
+ SendPacket(caster);
}
}
}
-void
-Deliverer::SendPacket(Player* plr)
-{
- if (!plr)
- return;
-
- // Don't send the packet to self if not supposed to
- if (!i_toSelf && plr == &i_source)
- return;
-
- // Don't send the packet to possesor if not supposed to
- if (!i_toPossessor && plr->isPossessing() && plr->GetCharmGUID() == i_source.GetGUID())
- return;
-
- if (plr_list.find(plr->GetGUID()) == plr_list.end())
- {
- if (WorldSession* session = plr->GetSession())
- session->SendPacket(i_message);
- plr_list.insert(plr->GetGUID());
- }
-}
-
-void
-MessageDeliverer::VisitObject(Player* plr)
-{
- SendPacket(plr);
-}
-
+/*
void
MessageDistDeliverer::VisitObject(Player* plr)
{
@@ -208,6 +179,7 @@ MessageDistDeliverer::VisitObject(Player* plr)
SendPacket(plr);
}
}
+*/
template<class T> void
ObjectUpdater::Visit(GridRefManager<T> &m)
diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h
index 138807674ae..87b0a11a226 100644
--- a/src/game/GridNotifiers.h
+++ b/src/game/GridNotifiers.h
@@ -101,48 +101,32 @@ namespace Trinity
void Visit(CorpseMapType &m) { updateObjects<Corpse>(m); }
};
- struct TRINITY_DLL_DECL Deliverer
+ struct TRINITY_DLL_DECL MessageDistDeliverer
{
WorldObject &i_source;
WorldPacket *i_message;
- std::set<uint64> plr_list;
- bool i_toPossessor;
- bool i_toSelf;
+ std::set<Player*> plr_list;
uint32 i_phaseMask;
- float i_dist;
- Deliverer(WorldObject &src, WorldPacket *msg, bool to_possessor, bool to_self, float dist = 0.0f)
- : i_source(src), i_message(msg), i_toPossessor(to_possessor), i_toSelf(to_self), i_dist(dist), i_phaseMask(src.GetPhaseMask()) {}
+ float i_distSq;
+ MessageDistDeliverer(WorldObject &src, WorldPacket *msg, bool to_self, float dist)
+ : i_source(src), i_message(msg), i_distSq(dist * dist), i_phaseMask(src.GetPhaseMask())
+ {
+ if(!to_self)
+ plr_list.insert((Player*)&i_source);
+ }
void Visit(PlayerMapType &m);
void Visit(CreatureMapType &m);
void Visit(DynamicObjectMapType &m);
- virtual void VisitObject(Player* plr) = 0;
- void SendPacket(Player* plr);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
- };
-
- struct TRINITY_DLL_DECL MessageDeliverer : public Deliverer
- {
- MessageDeliverer(Player &pl, WorldPacket *msg, bool to_possessor, bool to_self) : Deliverer(pl, msg, to_possessor, to_self) {}
- void VisitObject(Player* plr);
- };
-
- struct TRINITY_DLL_DECL ObjectMessageDeliverer : public Deliverer
- {
- explicit ObjectMessageDeliverer(WorldObject &src, WorldPacket *msg, bool to_possessor) : Deliverer(src, msg, to_possessor, false) {}
- void VisitObject(Player* plr) { SendPacket(plr); }
- };
- struct TRINITY_DLL_DECL MessageDistDeliverer : public Deliverer
- {
- bool i_ownTeamOnly;
- MessageDistDeliverer(Player &pl, WorldPacket *msg, bool to_possessor, float dist, bool to_self, bool ownTeamOnly) : Deliverer(pl, msg, to_possessor, to_self, dist), i_ownTeamOnly(ownTeamOnly) {}
- void VisitObject(Player* plr);
- };
-
- struct TRINITY_DLL_DECL ObjectMessageDistDeliverer : public Deliverer
- {
- ObjectMessageDistDeliverer(WorldObject &obj, WorldPacket *msg, bool to_possessor, float dist) : Deliverer(obj, msg, to_possessor, false, dist) {}
- void VisitObject(Player* plr) { SendPacket(plr); }
+ void SendPacket(Player* plr)
+ {
+ if (plr_list.find(plr) == plr_list.end())
+ {
+ plr->GetSession()->SendPacket(i_message);
+ plr_list.insert(plr);
+ }
+ }
};
struct TRINITY_DLL_DECL ObjectUpdater
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 9e107af5b86..8efba9785c2 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -530,28 +530,28 @@ Map::Add(T *obj)
AddNotifier(obj);
}
-void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self, bool to_possessor)
+void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self)
{
- Trinity::MessageDeliverer post_man(*player, msg, to_possessor, to_self);
+ Trinity::MessageDistDeliverer post_man(*player, msg, to_self, World::GetMaxVisibleDistance());
VisitWorld(player->GetPositionX(), player->GetPositionY(), World::GetMaxVisibleDistance(), post_man);
}
-void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg, bool to_possessor)
+void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg)
{
- Trinity::ObjectMessageDeliverer post_man(*obj, msg, to_possessor);
+ Trinity::MessageDistDeliverer post_man(*obj, msg, true, World::GetMaxVisibleDistance());
VisitWorld(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), post_man);
}
-void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool to_possessor, bool own_team_only)
+void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only)
{
- Trinity::MessageDistDeliverer post_man(*player, msg, to_possessor, dist, to_self, own_team_only);
- VisitWorld(player->GetPositionX(), player->GetPositionY(), World::GetMaxVisibleDistance(), post_man);
+ Trinity::MessageDistDeliverer post_man(*player, msg, to_self, dist/*, own_team_only*/);
+ VisitWorld(player->GetPositionX(), player->GetPositionY(), dist, post_man);
}
-void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist, bool to_possessor)
+void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist)
{
- Trinity::ObjectMessageDistDeliverer post_man(*obj, msg, to_possessor, dist);
- VisitWorld(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), post_man);
+ Trinity::MessageDistDeliverer post_man(*obj, msg, true, dist);
+ VisitWorld(obj->GetPositionX(), obj->GetPositionY(), dist, post_man);
}
bool Map::loaded(const GridPair &p) const
diff --git a/src/game/Map.h b/src/game/Map.h
index 241a836d249..9e9f7a9d402 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -270,10 +270,10 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
virtual void Update(const uint32&);
- void MessageBroadcast(Player *, WorldPacket *, bool to_self, bool to_possessor);
- void MessageBroadcast(WorldObject *, WorldPacket *, bool to_possessor);
- void MessageDistBroadcast(Player *, WorldPacket *, float dist, bool to_self, bool to_possessor, bool own_team_only = false);
- void MessageDistBroadcast(WorldObject *, WorldPacket *, float dist, bool to_possessor);
+ void MessageBroadcast(Player *, WorldPacket *, bool to_self);
+ void MessageBroadcast(WorldObject *, WorldPacket *);
+ void MessageDistBroadcast(Player *, WorldPacket *, float dist, bool to_self, bool own_team_only = false);
+ void MessageDistBroadcast(WorldObject *, WorldPacket *, float dist);
void PlayerRelocation(Player *, float x, float y, float z, float angl);
void CreatureRelocation(Creature *creature, float x, float y, float, float);
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index cd7b902ceca..2a38a63d457 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1707,14 +1707,14 @@ void WorldObject::BuildTeleportAckMsg(WorldPacket *data, float x, float y, float
((Unit*)this)->BuildMovementPacket(data);
}
-void WorldObject::SendMessageToSet(WorldPacket *data, bool /*fake*/, bool bToPossessor)
+void WorldObject::SendMessageToSet(WorldPacket *data, bool /*fake*/)
{
- MapManager::Instance().GetMap(m_mapId, this)->MessageBroadcast(this, data, bToPossessor);
+ GetMap()->MessageBroadcast(this, data);
}
-void WorldObject::SendMessageToSetInRange(WorldPacket *data, float dist, bool /*bToSelf*/, bool bToPossessor)
+void WorldObject::SendMessageToSetInRange(WorldPacket *data, float dist, bool /*bToSelf*/)
{
- MapManager::Instance().GetMap(m_mapId, this)->MessageDistBroadcast(this, data, dist, bToPossessor);
+ GetMap()->MessageDistBroadcast(this, data, dist);
}
void WorldObject::SendObjectDeSpawnAnim(uint64 guid)
diff --git a/src/game/Object.h b/src/game/Object.h
index 699cdca6b7f..b8dde77ae57 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -499,8 +499,8 @@ class TRINITY_DLL_SPEC WorldObject : public Object
bool HasInArc( const float arcangle, const WorldObject* obj ) const;
bool IsInBetween(const WorldObject *obj1, const WorldObject *obj2, float size = 0) const;
- virtual void SendMessageToSet(WorldPacket *data, bool self, bool to_possessor = true);
- virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool to_possessor = true);
+ virtual void SendMessageToSet(WorldPacket *data, bool self);
+ virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self);
void BuildHeartBeatMsg( WorldPacket *data ) const;
void BuildTeleportAckMsg( WorldPacket *data, float x, float y, float z, float ang) const;
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index c1e75451547..55def579532 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -5626,19 +5626,19 @@ void Player::SaveRecallPosition()
m_recallO = GetOrientation();
}
-void Player::SendMessageToSet(WorldPacket *data, bool self, bool to_possessor)
+void Player::SendMessageToSet(WorldPacket *data, bool self)
{
- GetMap()->MessageBroadcast(this, data, self, to_possessor);
+ GetMap()->MessageBroadcast(this, data, self);
}
-void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool to_possessor)
+void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
{
- GetMap()->MessageDistBroadcast(this, data, dist, self, to_possessor);
+ GetMap()->MessageDistBroadcast(this, data, dist, self);
}
-void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool to_possessor, bool own_team_only)
+void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only)
{
- GetMap()->MessageDistBroadcast(this, data, dist, self, to_possessor, own_team_only);
+ GetMap()->MessageDistBroadcast(this, data, dist, self, own_team_only);
}
void Player::SendDirectMessage(WorldPacket *data)
@@ -16730,7 +16730,7 @@ void Player::TextEmote(const std::string& text)
{
WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildPlayerChat(&data, CHAT_MSG_EMOTE, text, LANG_UNIVERSAL);
- SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT), true );
+ SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT));
if(sWorld.getConfig(CONFIG_CHATLOG_PUBLIC))
sLog.outChat("[TEXTEMOTE] Player %s emotes: %s",
diff --git a/src/game/Player.h b/src/game/Player.h
index aee7cd14991..db30ae4941c 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1585,9 +1585,9 @@ class TRINITY_DLL_SPEC Player : public Unit
bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
void UpdateUnderwaterState( Map * m, float x, float y, float z );
- void SendMessageToSet(WorldPacket *data, bool self, bool to_possessor = true);// overwrite Object::SendMessageToSet
- void SendMessageToSetInRange(WorldPacket *data, float fist, bool self, bool to_possessor = true);// overwrite Object::SendMessageToSetInRange
- void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool to_possessor, bool own_team_only);
+ void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet
+ void SendMessageToSetInRange(WorldPacket *data, float fist, bool self);// overwrite Object::SendMessageToSetInRange
+ void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only);
static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true);