mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 10:37:01 +00:00
[7311] Divide MessageChatLocaleCacheDo to specialized helper classes
1) LocalizedPacketDo (allocate and cache packets for locale indexes) 2) MonsterChatBuilder (prepare monster chat message packet for specific locale index)
This commit is contained in:
parent
1ccafb2fc9
commit
34a9f0302e
5 changed files with 95 additions and 52 deletions
|
|
@ -479,6 +479,26 @@ namespace MaNGOS
|
|||
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
|
||||
};
|
||||
|
||||
template<class Do>
|
||||
struct MANGOS_DLL_DECL PlayerDistWorker
|
||||
{
|
||||
WorldObject const* i_searcher;
|
||||
float i_dist;
|
||||
Do& i_do;
|
||||
|
||||
PlayerDistWorker(WorldObject const* searcher, float _dist, Do& _do)
|
||||
: i_searcher(searcher), i_dist(_dist), i_do(_do) {}
|
||||
|
||||
void Visit(PlayerMapType &m)
|
||||
{
|
||||
for(PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if(itr->getSource()->InSamePhase(i_searcher) && itr->getSource()->GetDistance(i_searcher) <= i_dist)
|
||||
i_do(itr->getSource());
|
||||
}
|
||||
|
||||
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
|
||||
};
|
||||
|
||||
// CHECKS && DO classes
|
||||
|
||||
// WorldObject check classes
|
||||
|
|
@ -819,6 +839,28 @@ namespace MaNGOS
|
|||
float i_range;
|
||||
};
|
||||
|
||||
// Player checks and do
|
||||
|
||||
// Prepare using Builder localized packets with caching and send to player
|
||||
template<class Builder>
|
||||
class LocalizedPacketDo
|
||||
{
|
||||
public:
|
||||
explicit LocalizedPacketDo(Builder& builder) : i_builder(builder) {}
|
||||
|
||||
LocalizedPacketDo::~LocalizedPacketDo()
|
||||
{
|
||||
for(int i = 0; i < i_data_cache.size(); ++i)
|
||||
delete i_data_cache[i];
|
||||
}
|
||||
void operator()( Player* p );
|
||||
|
||||
private:
|
||||
Builder& i_builder;
|
||||
std::vector<WorldPacket*> i_data_cache; // 0 = default, i => i-1 locale index
|
||||
};
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
template<> void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType &);
|
||||
template<> void PlayerRelocationNotifier::Visit<Player>(PlayerMapType &);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue