1 | /* |
---|
2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
3 | * |
---|
4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
19 | */ |
---|
20 | |
---|
21 | #include "Common.h" |
---|
22 | #include "Log.h" |
---|
23 | #include "WorldPacket.h" |
---|
24 | #include "WorldSession.h" |
---|
25 | #include "World.h" |
---|
26 | #include "Opcodes.h" |
---|
27 | #include "ObjectMgr.h" |
---|
28 | #include "Chat.h" |
---|
29 | #include "Database/DatabaseEnv.h" |
---|
30 | #include "ChannelMgr.h" |
---|
31 | #include "Group.h" |
---|
32 | #include "Guild.h" |
---|
33 | #include "MapManager.h" |
---|
34 | #include "ObjectAccessor.h" |
---|
35 | #include "ScriptCalls.h" |
---|
36 | #include "Player.h" |
---|
37 | #include "SpellAuras.h" |
---|
38 | #include "Language.h" |
---|
39 | #include "Util.h" |
---|
40 | |
---|
41 | void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) |
---|
42 | { |
---|
43 | CHECK_PACKET_SIZE(recv_data,4+4+1); |
---|
44 | |
---|
45 | uint32 type; |
---|
46 | uint32 lang; |
---|
47 | |
---|
48 | recv_data >> type; |
---|
49 | recv_data >> lang; |
---|
50 | |
---|
51 | if(type >= MAX_CHAT_MSG_TYPE) |
---|
52 | { |
---|
53 | sLog.outError("CHAT: Wrong message type received: %u", type); |
---|
54 | return; |
---|
55 | } |
---|
56 | |
---|
57 | //sLog.outDebug("CHAT: packet received. type %u, lang %u", type, lang ); |
---|
58 | |
---|
59 | // prevent talking at unknown language (cheating) |
---|
60 | LanguageDesc const* langDesc = GetLanguageDescByID(lang); |
---|
61 | if(!langDesc) |
---|
62 | { |
---|
63 | SendNotification(LANG_UNKNOWN_LANGUAGE); |
---|
64 | return; |
---|
65 | } |
---|
66 | if(langDesc->skill_id != 0 && !_player->HasSkill(langDesc->skill_id)) |
---|
67 | { |
---|
68 | // also check SPELL_AURA_COMPREHEND_LANGUAGE (client offers option to speak in that language) |
---|
69 | Unit::AuraList const& langAuras = _player->GetAurasByType(SPELL_AURA_COMPREHEND_LANGUAGE); |
---|
70 | bool foundAura = false; |
---|
71 | for(Unit::AuraList::const_iterator i = langAuras.begin();i != langAuras.end(); ++i) |
---|
72 | { |
---|
73 | if((*i)->GetModifier()->m_miscvalue == lang) |
---|
74 | { |
---|
75 | foundAura = true; |
---|
76 | break; |
---|
77 | } |
---|
78 | } |
---|
79 | if(!foundAura) |
---|
80 | { |
---|
81 | SendNotification(LANG_NOT_LEARNED_LANGUAGE); |
---|
82 | return; |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | if(lang == LANG_ADDON) |
---|
87 | { |
---|
88 | // Disabled addon channel? |
---|
89 | if(!sWorld.getConfig(CONFIG_ADDON_CHANNEL)) |
---|
90 | return; |
---|
91 | } |
---|
92 | // LANG_ADDON should not be changed nor be affected by flood control |
---|
93 | else |
---|
94 | { |
---|
95 | // send in universal language if player in .gmon mode (ignore spell effects) |
---|
96 | if (_player->isGameMaster()) |
---|
97 | lang = LANG_UNIVERSAL; |
---|
98 | else |
---|
99 | { |
---|
100 | // send in universal language in two side iteration allowed mode |
---|
101 | if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT)) |
---|
102 | lang = LANG_UNIVERSAL; |
---|
103 | else |
---|
104 | { |
---|
105 | switch(type) |
---|
106 | { |
---|
107 | case CHAT_MSG_PARTY: |
---|
108 | case CHAT_MSG_RAID: |
---|
109 | case CHAT_MSG_RAID_LEADER: |
---|
110 | case CHAT_MSG_RAID_WARNING: |
---|
111 | // allow two side chat at group channel if two side group allowed |
---|
112 | if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP)) |
---|
113 | lang = LANG_UNIVERSAL; |
---|
114 | break; |
---|
115 | case CHAT_MSG_GUILD: |
---|
116 | case CHAT_MSG_OFFICER: |
---|
117 | // allow two side chat at guild channel if two side guild allowed |
---|
118 | if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD)) |
---|
119 | lang = LANG_UNIVERSAL; |
---|
120 | break; |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | // but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used) |
---|
125 | Unit::AuraList const& ModLangAuras = _player->GetAurasByType(SPELL_AURA_MOD_LANGUAGE); |
---|
126 | if(!ModLangAuras.empty()) |
---|
127 | lang = ModLangAuras.front()->GetModifier()->m_miscvalue; |
---|
128 | } |
---|
129 | |
---|
130 | if (!_player->CanSpeak()) |
---|
131 | { |
---|
132 | std::string timeStr = secsToTimeString(m_muteTime - time(NULL)); |
---|
133 | SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING),timeStr.c_str()); |
---|
134 | return; |
---|
135 | } |
---|
136 | |
---|
137 | if (type != CHAT_MSG_AFK && type != CHAT_MSG_DND) |
---|
138 | GetPlayer()->UpdateSpeakTime(); |
---|
139 | } |
---|
140 | |
---|
141 | switch(type) |
---|
142 | { |
---|
143 | case CHAT_MSG_SAY: |
---|
144 | case CHAT_MSG_EMOTE: |
---|
145 | case CHAT_MSG_YELL: |
---|
146 | { |
---|
147 | std::string msg = ""; |
---|
148 | recv_data >> msg; |
---|
149 | |
---|
150 | if(msg.empty()) |
---|
151 | break; |
---|
152 | |
---|
153 | if (ChatHandler(this).ParseCommands(msg.c_str()) > 0) |
---|
154 | break; |
---|
155 | |
---|
156 | // strip invisible characters for non-addon messages |
---|
157 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
158 | stripLineInvisibleChars(msg); |
---|
159 | |
---|
160 | if(msg.empty()) |
---|
161 | break; |
---|
162 | |
---|
163 | if(type == CHAT_MSG_SAY) |
---|
164 | GetPlayer()->Say(msg, lang); |
---|
165 | else if(type == CHAT_MSG_EMOTE) |
---|
166 | GetPlayer()->TextEmote(msg); |
---|
167 | else if(type == CHAT_MSG_YELL) |
---|
168 | GetPlayer()->Yell(msg, lang); |
---|
169 | } break; |
---|
170 | |
---|
171 | case CHAT_MSG_WHISPER: |
---|
172 | { |
---|
173 | std::string to, msg; |
---|
174 | recv_data >> to; |
---|
175 | CHECK_PACKET_SIZE(recv_data,4+4+(to.size()+1)+1); |
---|
176 | recv_data >> msg; |
---|
177 | |
---|
178 | // strip invisible characters for non-addon messages |
---|
179 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
180 | stripLineInvisibleChars(msg); |
---|
181 | |
---|
182 | if(msg.empty()) |
---|
183 | break; |
---|
184 | |
---|
185 | if(!normalizePlayerName(to)) |
---|
186 | { |
---|
187 | WorldPacket data(SMSG_CHAT_PLAYER_NOT_FOUND, (to.size()+1)); |
---|
188 | data<<to; |
---|
189 | SendPacket(&data); |
---|
190 | break; |
---|
191 | } |
---|
192 | |
---|
193 | Player *player = objmgr.GetPlayer(to.c_str()); |
---|
194 | uint32 tSecurity = GetSecurity(); |
---|
195 | uint32 pSecurity = player ? player->GetSession()->GetSecurity() : 0; |
---|
196 | if(!player || tSecurity == SEC_PLAYER && pSecurity > SEC_PLAYER && !player->isAcceptWhispers()) |
---|
197 | { |
---|
198 | WorldPacket data(SMSG_CHAT_PLAYER_NOT_FOUND, (to.size()+1)); |
---|
199 | data<<to; |
---|
200 | SendPacket(&data); |
---|
201 | return; |
---|
202 | } |
---|
203 | |
---|
204 | if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT) && tSecurity == SEC_PLAYER && pSecurity == SEC_PLAYER ) |
---|
205 | { |
---|
206 | uint32 sidea = GetPlayer()->GetTeam(); |
---|
207 | uint32 sideb = player->GetTeam(); |
---|
208 | if( sidea != sideb ) |
---|
209 | { |
---|
210 | WorldPacket data(SMSG_CHAT_PLAYER_NOT_FOUND, (to.size()+1)); |
---|
211 | data<<to; |
---|
212 | SendPacket(&data); |
---|
213 | return; |
---|
214 | } |
---|
215 | } |
---|
216 | |
---|
217 | GetPlayer()->Whisper(msg, lang,player->GetGUID()); |
---|
218 | } break; |
---|
219 | |
---|
220 | case CHAT_MSG_PARTY: |
---|
221 | { |
---|
222 | std::string msg = ""; |
---|
223 | recv_data >> msg; |
---|
224 | |
---|
225 | if(msg.empty()) |
---|
226 | break; |
---|
227 | |
---|
228 | if (ChatHandler(this).ParseCommands(msg.c_str()) > 0) |
---|
229 | break; |
---|
230 | |
---|
231 | // strip invisible characters for non-addon messages |
---|
232 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
233 | stripLineInvisibleChars(msg); |
---|
234 | |
---|
235 | if(msg.empty()) |
---|
236 | break; |
---|
237 | |
---|
238 | Group *group = GetPlayer()->GetGroup(); |
---|
239 | if(!group) |
---|
240 | return; |
---|
241 | |
---|
242 | WorldPacket data; |
---|
243 | ChatHandler::FillMessageData(&data, this, CHAT_MSG_PARTY, lang, NULL, 0, msg.c_str(),NULL); |
---|
244 | group->BroadcastPacket(&data, group->GetMemberGroup(GetPlayer()->GetGUID())); |
---|
245 | } |
---|
246 | break; |
---|
247 | case CHAT_MSG_GUILD: |
---|
248 | { |
---|
249 | std::string msg = ""; |
---|
250 | recv_data >> msg; |
---|
251 | |
---|
252 | if(msg.empty()) |
---|
253 | break; |
---|
254 | |
---|
255 | if (ChatHandler(this).ParseCommands(msg.c_str()) > 0) |
---|
256 | break; |
---|
257 | |
---|
258 | // strip invisible characters for non-addon messages |
---|
259 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
260 | stripLineInvisibleChars(msg); |
---|
261 | |
---|
262 | if(msg.empty()) |
---|
263 | break; |
---|
264 | |
---|
265 | if (GetPlayer()->GetGuildId()) |
---|
266 | { |
---|
267 | Guild *guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); |
---|
268 | if (guild) |
---|
269 | guild->BroadcastToGuild(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL); |
---|
270 | } |
---|
271 | |
---|
272 | break; |
---|
273 | } |
---|
274 | case CHAT_MSG_OFFICER: |
---|
275 | { |
---|
276 | std::string msg = ""; |
---|
277 | recv_data >> msg; |
---|
278 | |
---|
279 | if(msg.empty()) |
---|
280 | break; |
---|
281 | |
---|
282 | if (ChatHandler(this).ParseCommands(msg.c_str()) > 0) |
---|
283 | break; |
---|
284 | |
---|
285 | // strip invisible characters for non-addon messages |
---|
286 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
287 | stripLineInvisibleChars(msg); |
---|
288 | |
---|
289 | if(msg.empty()) |
---|
290 | break; |
---|
291 | |
---|
292 | if (GetPlayer()->GetGuildId()) |
---|
293 | { |
---|
294 | Guild *guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); |
---|
295 | if (guild) |
---|
296 | guild->BroadcastToOfficers(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL); |
---|
297 | } |
---|
298 | break; |
---|
299 | } |
---|
300 | case CHAT_MSG_RAID: |
---|
301 | { |
---|
302 | std::string msg=""; |
---|
303 | recv_data >> msg; |
---|
304 | |
---|
305 | if(msg.empty()) |
---|
306 | break; |
---|
307 | |
---|
308 | if (ChatHandler(this).ParseCommands(msg.c_str()) > 0) |
---|
309 | break; |
---|
310 | |
---|
311 | // strip invisible characters for non-addon messages |
---|
312 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
313 | stripLineInvisibleChars(msg); |
---|
314 | |
---|
315 | if(msg.empty()) |
---|
316 | break; |
---|
317 | |
---|
318 | Group *group = GetPlayer()->GetGroup(); |
---|
319 | if(!group || !group->isRaidGroup()) |
---|
320 | return; |
---|
321 | |
---|
322 | WorldPacket data; |
---|
323 | ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID, lang, "", 0, msg.c_str(),NULL); |
---|
324 | group->BroadcastPacket(&data); |
---|
325 | } break; |
---|
326 | case CHAT_MSG_RAID_LEADER: |
---|
327 | { |
---|
328 | std::string msg=""; |
---|
329 | recv_data >> msg; |
---|
330 | |
---|
331 | if(msg.empty()) |
---|
332 | break; |
---|
333 | |
---|
334 | if (ChatHandler(this).ParseCommands(msg.c_str()) > 0) |
---|
335 | break; |
---|
336 | |
---|
337 | // strip invisible characters for non-addon messages |
---|
338 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
339 | stripLineInvisibleChars(msg); |
---|
340 | |
---|
341 | if(msg.empty()) |
---|
342 | break; |
---|
343 | |
---|
344 | Group *group = GetPlayer()->GetGroup(); |
---|
345 | if(!group || !group->isRaidGroup() || !group->IsLeader(GetPlayer()->GetGUID())) |
---|
346 | return; |
---|
347 | |
---|
348 | WorldPacket data; |
---|
349 | ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_LEADER, lang, "", 0, msg.c_str(),NULL); |
---|
350 | group->BroadcastPacket(&data); |
---|
351 | } break; |
---|
352 | case CHAT_MSG_RAID_WARNING: |
---|
353 | { |
---|
354 | std::string msg=""; |
---|
355 | recv_data >> msg; |
---|
356 | |
---|
357 | // strip invisible characters for non-addon messages |
---|
358 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
359 | stripLineInvisibleChars(msg); |
---|
360 | |
---|
361 | if(msg.empty()) |
---|
362 | break; |
---|
363 | |
---|
364 | Group *group = GetPlayer()->GetGroup(); |
---|
365 | if(!group || !group->isRaidGroup() || !(group->IsLeader(GetPlayer()->GetGUID()) || group->IsAssistant(GetPlayer()->GetGUID()))) |
---|
366 | return; |
---|
367 | |
---|
368 | WorldPacket data; |
---|
369 | ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_WARNING, lang, "", 0, msg.c_str(),NULL); |
---|
370 | group->BroadcastPacket(&data); |
---|
371 | } break; |
---|
372 | |
---|
373 | case CHAT_MSG_BATTLEGROUND: |
---|
374 | { |
---|
375 | std::string msg=""; |
---|
376 | recv_data >> msg; |
---|
377 | |
---|
378 | // strip invisible characters for non-addon messages |
---|
379 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
380 | stripLineInvisibleChars(msg); |
---|
381 | |
---|
382 | if(msg.empty()) |
---|
383 | break; |
---|
384 | |
---|
385 | Group *group = GetPlayer()->GetGroup(); |
---|
386 | if(!group || !group->isRaidGroup()) |
---|
387 | return; |
---|
388 | |
---|
389 | WorldPacket data; |
---|
390 | ChatHandler::FillMessageData(&data, this, CHAT_MSG_BATTLEGROUND, lang, "", 0, msg.c_str(),NULL); |
---|
391 | group->BroadcastPacket(&data); |
---|
392 | } break; |
---|
393 | |
---|
394 | case CHAT_MSG_BATTLEGROUND_LEADER: |
---|
395 | { |
---|
396 | std::string msg=""; |
---|
397 | recv_data >> msg; |
---|
398 | |
---|
399 | // strip invisible characters for non-addon messages |
---|
400 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
401 | stripLineInvisibleChars(msg); |
---|
402 | |
---|
403 | if(msg.empty()) |
---|
404 | break; |
---|
405 | |
---|
406 | Group *group = GetPlayer()->GetGroup(); |
---|
407 | if(!group || !group->isRaidGroup() || !group->IsLeader(GetPlayer()->GetGUID())) |
---|
408 | return; |
---|
409 | |
---|
410 | WorldPacket data; |
---|
411 | ChatHandler::FillMessageData(&data, this, CHAT_MSG_BATTLEGROUND_LEADER, lang, "", 0, msg.c_str(),NULL); |
---|
412 | group->BroadcastPacket(&data); |
---|
413 | } break; |
---|
414 | |
---|
415 | case CHAT_MSG_CHANNEL: |
---|
416 | { |
---|
417 | std::string channel = "", msg = ""; |
---|
418 | recv_data >> channel; |
---|
419 | |
---|
420 | // recheck |
---|
421 | CHECK_PACKET_SIZE(recv_data,4+4+(channel.size()+1)+1); |
---|
422 | |
---|
423 | recv_data >> msg; |
---|
424 | |
---|
425 | // strip invisible characters for non-addon messages |
---|
426 | if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) |
---|
427 | stripLineInvisibleChars(msg); |
---|
428 | |
---|
429 | if(msg.empty()) |
---|
430 | break; |
---|
431 | |
---|
432 | if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) |
---|
433 | { |
---|
434 | if(Channel *chn = cMgr->GetChannel(channel,_player)) |
---|
435 | chn->Say(_player->GetGUID(),msg.c_str(),lang); |
---|
436 | } |
---|
437 | } break; |
---|
438 | |
---|
439 | case CHAT_MSG_AFK: |
---|
440 | { |
---|
441 | std::string msg; |
---|
442 | recv_data >> msg; |
---|
443 | |
---|
444 | if((msg.empty() || !_player->isAFK()) && !_player->isInCombat() ) |
---|
445 | { |
---|
446 | if(!_player->isAFK()) |
---|
447 | { |
---|
448 | if(msg.empty()) |
---|
449 | msg = GetTrinityString(LANG_PLAYER_AFK_DEFAULT); |
---|
450 | _player->afkMsg = msg; |
---|
451 | } |
---|
452 | _player->ToggleAFK(); |
---|
453 | if(_player->isAFK() && _player->isDND()) |
---|
454 | _player->ToggleDND(); |
---|
455 | } |
---|
456 | } break; |
---|
457 | |
---|
458 | case CHAT_MSG_DND: |
---|
459 | { |
---|
460 | std::string msg; |
---|
461 | recv_data >> msg; |
---|
462 | |
---|
463 | if(msg.empty() || !_player->isDND()) |
---|
464 | { |
---|
465 | if(!_player->isDND()) |
---|
466 | { |
---|
467 | if(msg.empty()) |
---|
468 | msg = GetTrinityString(LANG_PLAYER_DND_DEFAULT); |
---|
469 | _player->dndMsg = msg; |
---|
470 | } |
---|
471 | _player->ToggleDND(); |
---|
472 | if(_player->isDND() && _player->isAFK()) |
---|
473 | _player->ToggleAFK(); |
---|
474 | } |
---|
475 | } break; |
---|
476 | |
---|
477 | default: |
---|
478 | sLog.outError("CHAT: unknown message type %u, lang: %u", type, lang); |
---|
479 | break; |
---|
480 | } |
---|
481 | } |
---|
482 | |
---|
483 | void WorldSession::HandleEmoteOpcode( WorldPacket & recv_data ) |
---|
484 | { |
---|
485 | if(!GetPlayer()->isAlive()) |
---|
486 | return; |
---|
487 | CHECK_PACKET_SIZE(recv_data,4); |
---|
488 | |
---|
489 | uint32 emote; |
---|
490 | recv_data >> emote; |
---|
491 | GetPlayer()->HandleEmoteCommand(emote); |
---|
492 | } |
---|
493 | |
---|
494 | void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data ) |
---|
495 | { |
---|
496 | if(!GetPlayer()->isAlive()) |
---|
497 | return; |
---|
498 | |
---|
499 | if (!GetPlayer()->CanSpeak()) |
---|
500 | { |
---|
501 | std::string timeStr = secsToTimeString(m_muteTime - time(NULL)); |
---|
502 | SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING),timeStr.c_str()); |
---|
503 | return; |
---|
504 | } |
---|
505 | |
---|
506 | CHECK_PACKET_SIZE(recv_data,4+4+8); |
---|
507 | |
---|
508 | uint32 text_emote, emoteNum; |
---|
509 | uint64 guid; |
---|
510 | |
---|
511 | recv_data >> text_emote; |
---|
512 | recv_data >> emoteNum; |
---|
513 | recv_data >> guid; |
---|
514 | |
---|
515 | const char *nam = 0; |
---|
516 | uint32 namlen = 1; |
---|
517 | |
---|
518 | Unit* unit = ObjectAccessor::GetUnit(*_player, guid); |
---|
519 | Creature *pCreature = dynamic_cast<Creature *>(unit); |
---|
520 | if(unit) |
---|
521 | { |
---|
522 | nam = unit->GetName(); |
---|
523 | namlen = (nam ? strlen(nam) : 0) + 1; |
---|
524 | } |
---|
525 | |
---|
526 | EmotesTextEntry const *em = sEmotesTextStore.LookupEntry(text_emote); |
---|
527 | if (em) |
---|
528 | { |
---|
529 | uint32 emote_anim = em->textid; |
---|
530 | |
---|
531 | WorldPacket data; |
---|
532 | |
---|
533 | switch(emote_anim) |
---|
534 | { |
---|
535 | case EMOTE_STATE_SLEEP: |
---|
536 | case EMOTE_STATE_SIT: |
---|
537 | case EMOTE_STATE_KNEEL: |
---|
538 | case EMOTE_ONESHOT_NONE: |
---|
539 | break; |
---|
540 | default: |
---|
541 | GetPlayer()->HandleEmoteCommand(emote_anim); |
---|
542 | break; |
---|
543 | } |
---|
544 | |
---|
545 | data.Initialize(SMSG_TEXT_EMOTE, (20+namlen)); |
---|
546 | data << GetPlayer()->GetGUID(); |
---|
547 | data << (uint32)text_emote; |
---|
548 | data << emoteNum; |
---|
549 | data << (uint32)namlen; |
---|
550 | if( namlen > 1 ) |
---|
551 | { |
---|
552 | data.append(nam, namlen); |
---|
553 | } |
---|
554 | else |
---|
555 | { |
---|
556 | data << (uint8)0x00; |
---|
557 | } |
---|
558 | |
---|
559 | GetPlayer()->SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),true); |
---|
560 | |
---|
561 | //Send scripted event call |
---|
562 | if (pCreature && Script) |
---|
563 | Script->ReceiveEmote(GetPlayer(),pCreature,text_emote); |
---|
564 | } |
---|
565 | } |
---|
566 | |
---|
567 | void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data ) |
---|
568 | { |
---|
569 | CHECK_PACKET_SIZE(recv_data, 8+1); |
---|
570 | |
---|
571 | uint64 iguid; |
---|
572 | uint8 unk; |
---|
573 | //sLog.outDebug("WORLD: Received CMSG_CHAT_IGNORED"); |
---|
574 | |
---|
575 | recv_data >> iguid; |
---|
576 | recv_data >> unk; // probably related to spam reporting |
---|
577 | |
---|
578 | Player *player = objmgr.GetPlayer(iguid); |
---|
579 | if(!player || !player->GetSession()) |
---|
580 | return; |
---|
581 | |
---|
582 | WorldPacket data; |
---|
583 | ChatHandler::FillMessageData(&data, this, CHAT_MSG_IGNORED, LANG_UNIVERSAL, NULL, GetPlayer()->GetGUID(), GetPlayer()->GetName(),NULL); |
---|
584 | player->GetSession()->SendPacket(&data); |
---|
585 | } |
---|