mirror of
https://github.com/mangosfour/server.git
synced 2025-12-21 01:37:05 +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
|
|
@ -537,4 +537,29 @@ void MaNGOS::PlayerSearcher<Check>::Visit(PlayerMapType &m)
|
|||
}
|
||||
}
|
||||
|
||||
template<class Builder>
|
||||
void MaNGOS::LocalizedPacketDo<Builder>::operator()( Player* p )
|
||||
{
|
||||
uint32 loc_idx = p->GetSession()->GetSessionDbLocaleIndex();
|
||||
uint32 cache_idx = loc_idx+1;
|
||||
WorldPacket* data;
|
||||
|
||||
// create if not cached yet
|
||||
if(i_data_cache.size() < cache_idx+1 || !i_data_cache[cache_idx])
|
||||
{
|
||||
if(i_data_cache.size() < cache_idx+1)
|
||||
i_data_cache.resize(cache_idx+1);
|
||||
|
||||
data = new WorldPacket(SMSG_MESSAGECHAT, 200);
|
||||
|
||||
i_builder(*data,loc_idx);
|
||||
|
||||
i_data_cache[cache_idx] = data;
|
||||
}
|
||||
else
|
||||
data = i_data_cache[cache_idx];
|
||||
|
||||
p->SendDirectMessage(data);
|
||||
}
|
||||
|
||||
#endif // MANGOS_GRIDNOTIFIERSIMPL_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue