Advertisement
Guest User

Untitled

a guest
Jun 11th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.41 KB | None | 0 0
  1. diff -r c7781fec4099 -r 154cbf33d79a src/game/ChatHandler.cpp
  2. --- a/src/game/ChatHandler.cpp Mon Mar 11 00:57:51 2013 +0400
  3. +++ b/src/game/ChatHandler.cpp Mon May 07 07:39:09 2012 +0300
  4. @@ -30,6 +30,7 @@
  5. #include "Guild.h"
  6. #include "Language.h"
  7. #include "Log.h"
  8. +#include "ChatLog.h"
  9. #include "Opcodes.h"
  10. #include "MapManager.h"
  11. #include "Player.h"
  12. @@ -205,11 +206,20 @@
  13. break;
  14.  
  15. if (type == CHAT_MSG_SAY)
  16. + {
  17. + sChatLog.ChatMsg(GetPlayer(), msg, type);
  18. GetPlayer()->Say(msg, lang);
  19. + }
  20. else if (type == CHAT_MSG_EMOTE)
  21. + {
  22. + sChatLog.ChatMsg(GetPlayer(), msg, type);
  23. GetPlayer()->TextEmote(msg);
  24. + }
  25. else if (type == CHAT_MSG_YELL)
  26. + {
  27. + sChatLog.ChatMsg(GetPlayer(), msg, type);
  28. GetPlayer()->Yell(msg, lang);
  29. + }
  30. } break;
  31.  
  32. case CHAT_MSG_WHISPER:
  33. @@ -224,6 +234,8 @@
  34. if (msg.empty())
  35. break;
  36.  
  37. + sChatLog.WhisperMsg(GetPlayer(), to, msg);
  38. +
  39. if (!normalizePlayerName(to))
  40. {
  41. SendPlayerNotFoundNotice(to);
  42. @@ -276,6 +288,8 @@
  43. if (msg.empty())
  44. break;
  45.  
  46. + sChatLog.PartyMsg(GetPlayer(), msg);
  47. +
  48. // if player is in battleground, he cannot say to battleground members by /p
  49. Group *group = GetPlayer()->GetOriginalGroup();
  50. // so if player hasn't OriginalGroup and his player->GetGroup() is BG raid, then return
  51. @@ -308,6 +322,8 @@
  52. if (msg.empty())
  53. break;
  54.  
  55. + sChatLog.GuildMsg(GetPlayer(), msg, true);
  56. +
  57. if (GetPlayer()->GetGuildId())
  58. {
  59. Guild *guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
  60. @@ -345,6 +361,8 @@
  61. if (msg.empty())
  62. break;
  63.  
  64. + sChatLog.GuildMsg(GetPlayer(), msg, false);
  65. +
  66. if (GetPlayer()->GetGuildId())
  67. {
  68. Guild *guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
  69. @@ -374,6 +392,8 @@
  70. if (msg.empty())
  71. break;
  72.  
  73. + sChatLog.RaidMsg(GetPlayer(), msg, type);
  74. +
  75. // if player is in battleground, he cannot say to battleground members by /ra
  76. Group *group = GetPlayer()->GetOriginalGroup();
  77. // so if player hasn't OriginalGroup and his player->GetGroup() is BG raid or his group isn't raid, then return
  78. @@ -405,6 +425,8 @@
  79. if (msg.empty())
  80. break;
  81.  
  82. + sChatLog.RaidMsg(GetPlayer(), msg, type);
  83. +
  84. // if player is in battleground, he cannot say to battleground members by /ra
  85. Group *group = GetPlayer()->GetOriginalGroup();
  86. if (!group && !(group = GetPlayer()->GetGroup()) || group->isBGGroup() || !group->isRaidGroup() || !group->IsLeader(GetPlayer()->GetGUID()))
  87. @@ -429,6 +451,8 @@
  88. if (msg.empty())
  89. break;
  90.  
  91. + sChatLog.RaidMsg(GetPlayer(), msg, type);
  92. +
  93. Group *group = GetPlayer()->GetGroup();
  94. if (!group || !group->isRaidGroup() || !(group->IsLeader(GetPlayer()->GetGUID()) || group->IsAssistant(GetPlayer()->GetGUID())) || group->isBGGroup())
  95. return;
  96. @@ -454,6 +478,8 @@
  97. if (msg.empty())
  98. break;
  99.  
  100. + sChatLog.BattleGroundMsg(GetPlayer(), msg, type);
  101. +
  102. //battleground raid is always in Player->GetGroup(), never in GetOriginalGroup()
  103. Group *group = GetPlayer()->GetGroup();
  104. if (!group || !group->isBGGroup())
  105. @@ -479,6 +505,8 @@
  106. if (msg.empty())
  107. break;
  108.  
  109. + sChatLog.BattleGroundMsg(GetPlayer(), msg, type);
  110. +
  111. //battleground raid is always in Player->GetGroup(), never in GetOriginalGroup()
  112. Group *group = GetPlayer()->GetGroup();
  113. if (!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetGUID()))
  114. @@ -505,6 +533,8 @@
  115. if (msg.empty())
  116. break;
  117.  
  118. + sChatLog.ChatMsg(GetPlayer(), msg, type);
  119. +
  120. if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
  121. {
  122. if (Channel *chn = cMgr->GetChannel(channel, _player))
  123. diff -r c7781fec4099 -r 154cbf33d79a src/game/ChatLexicsCutter.cpp
  124. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  125. +++ b/src/game/ChatLexicsCutter.cpp Mon May 07 07:39:09 2012 +0300
  126. @@ -0,0 +1,274 @@
  127. +/*
  128. + * Copyright (C) 2005,2006,2007 MaNGOS <http://www.oregonproject.org/>
  129. + *
  130. + * This program is free software; you can redistribute it and/or modify
  131. + * it under the terms of the GNU General Public License as published by
  132. + * the Free Software Foundation; either version 2 of the License, or
  133. + * (at your option) any later version.
  134. + *
  135. + * This program is distributed in the hope that it will be useful,
  136. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  137. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  138. + * GNU General Public License for more details.
  139. + *
  140. + * You should have received a copy of the GNU General Public License
  141. + * along with this program; if not, write to the Free Software
  142. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  143. + */
  144. +
  145. +#include "Common.h"
  146. +#include "ChatLexicsCutter.h"
  147. +
  148. +LexicsCutter::LexicsCutter()
  149. +{
  150. + InvalidChars = "~`!@#$%^&*()-_+=[{]}|\\;:'\",<.>/?";
  151. +}
  152. +
  153. +bool LexicsCutter::ReadUTF8(std::string& in, std::string& out, unsigned int& pos)
  154. +{
  155. + if (pos >= in.length()) return false;
  156. +
  157. + out = "";
  158. + unsigned char c = in[pos++];
  159. + out += c;
  160. + int toread = trailingBytesForUTF8[(int) c];
  161. + while ((pos < in.length()) && (toread > 0))
  162. + {
  163. + out += in[pos++];
  164. + toread--;
  165. + }
  166. +
  167. + return true;
  168. +}
  169. +
  170. +std::string LexicsCutter::trim(std::string& s, const std::string& drop)
  171. +{
  172. + std::string r = s.erase(s.find_last_not_of(drop) + 1);
  173. + return r.erase(0, r.find_first_not_of(drop));
  174. +}
  175. +
  176. +bool LexicsCutter::Read_Letter_Analogs(std::string& FileName)
  177. +{
  178. + FILE *ma_file;
  179. + char line[1024];
  180. + unsigned int pos;
  181. + std::string line_s;
  182. + std::string lchar;
  183. + std::string lanalog;
  184. +
  185. + ma_file = fopen(FileName.c_str(), "rb");
  186. +
  187. + while (!feof(ma_file))
  188. + {
  189. + line[0] = 0x0;
  190. + fgets(line, 1020, ma_file);
  191. +
  192. + // check for UTF8 prefix and comments
  193. + if (strlen(line) >= 3)
  194. + {
  195. + if (line[0] == '\xEF' && line[1] == '\xBB' && line[2] == '\xBF')
  196. + {
  197. + strncpy(&line[0], &line[3], strlen(line) - 3);
  198. + }
  199. + }
  200. +
  201. + if (strlen(line) >= 2)
  202. + {
  203. + if (line[0] == '/' && line[1] == '/') continue;
  204. + }
  205. +
  206. + // check for empty string
  207. + line_s = line;
  208. + line_s = trim(line_s, "\x0A\x0D\x20");
  209. + if (line_s == "") continue;
  210. +
  211. + // process line without CR/LF
  212. + line_s = line;
  213. + line_s = trim(line_s, "\x0A\x0D");
  214. +
  215. + pos = 0;
  216. + if (ReadUTF8(line_s, lchar, pos))
  217. + {
  218. + // create analogs vector
  219. + LC_AnalogVector av;
  220. + while (ReadUTF8(line_s, lanalog, pos))
  221. + {
  222. + av.push_back(lanalog);
  223. + }
  224. +
  225. + // store vector in hash map
  226. + AnalogMap[lchar] = av;
  227. + }
  228. + }
  229. +
  230. + fclose(ma_file);
  231. +
  232. + return true;
  233. +}
  234. +
  235. +bool LexicsCutter::Read_Innormative_Words(std::string& FileName)
  236. +{
  237. + FILE *ma_file;
  238. + char line[1024];
  239. + unsigned int pos;
  240. + std::string line_s;
  241. + std::string lchar;
  242. +
  243. + ma_file = fopen(FileName.c_str(), "rb");
  244. +
  245. + while (!feof(ma_file))
  246. + {
  247. + line[0] = 0x0;
  248. + fgets(line, 1020, ma_file);
  249. +
  250. + // check for UTF8 prefix and comment
  251. + if (strlen(line) >= 3)
  252. + {
  253. + if (line[0] == '\xEF' && line[1] == '\xBB' && line[2] == '\xBF')
  254. + {
  255. + strncpy(&line[0], &line[3], strlen(line) - 3);
  256. + }
  257. + }
  258. +
  259. + if (strlen(line) >= 2)
  260. + {
  261. + if (line[0] == '/' && line[1] == '/') continue;
  262. + }
  263. +
  264. + // check for empty string
  265. + line_s = line;
  266. + line_s = trim(line_s, "\x0A\x0D\x20");
  267. + if (line_s == "") continue;
  268. +
  269. + // process line without CR/LF
  270. + line_s = line;
  271. + line_s = trim(line_s, "\x0A\x0D");
  272. +
  273. + // create word vector of vectors
  274. + LC_WordVector vw;
  275. + pos = 0;
  276. + while (ReadUTF8(line_s, lchar, pos))
  277. + {
  278. + // create letter set
  279. + LC_LetterSet vl;
  280. +
  281. + // initialize letter set with letter read
  282. + vl.insert(lchar);
  283. +
  284. + // find letter analogs and push them onto the vector
  285. + LC_AnalogMap::iterator itr = AnalogMap.find(lchar);
  286. + if (itr != AnalogMap.end())
  287. + {
  288. + // analogs present, iterate
  289. + for (LC_AnalogVector::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); itr2++)
  290. + {
  291. + vl.insert(*itr2);
  292. + }
  293. + }
  294. +
  295. + // add letter vector to word vector
  296. + vw.push_back(vl);
  297. + }
  298. +
  299. + // push new word to words list
  300. + WordList.push_back(vw);
  301. + }
  302. +
  303. + fclose(ma_file);
  304. +
  305. + return true;
  306. +}
  307. +
  308. +void LexicsCutter::Map_Innormative_Words()
  309. +{
  310. + // process all the words in the vector
  311. + for (unsigned int i = 0; i < WordList.size(); i++)
  312. + {
  313. + // parse all analogs in the first word letter
  314. + for (LC_LetterSet::iterator itr = (*WordList[i].begin()).begin(); itr != (*WordList[i].begin()).end(); itr++)
  315. + {
  316. + // map the word to its first letter variants
  317. + WordMap.insert(std::pair< std::string, unsigned int >(*itr, i));
  318. + }
  319. + }
  320. +}
  321. +
  322. +bool LexicsCutter::Compare_Word(std::string& str, unsigned int pos, LC_WordVector word)
  323. +{
  324. + std::string lchar_prev;
  325. + std::string lchar;
  326. +
  327. + // read first letter of the word into lchar_prev
  328. + ReadUTF8(str, lchar, pos);
  329. +
  330. + // okay, here we go, comparing word
  331. + // first letter is already okay, we do begin from second and go on
  332. + LC_WordVector::iterator i = word.begin();
  333. + i++;
  334. + while (i != word.end())
  335. + {
  336. + // get letter from word, return false if the string is shorter
  337. + if (!ReadUTF8(str, lchar, pos)) return(false);
  338. + // check, if the letter is in the set
  339. + LC_LetterSet ls = *i;
  340. + if (ls.count(lchar) == 0)
  341. + {
  342. + // letter is not in set, but we must check, if it is not space or repeat
  343. + if ( (!(IgnoreMiddleSpaces && (lchar == " "))) &&
  344. + (!(IgnoreLetterRepeat && (lchar == lchar_prev))) )
  345. + {
  346. + // no checks viable
  347. + return(false);
  348. + }
  349. + }
  350. + else
  351. + {
  352. + // next word letter
  353. + i++;
  354. + }
  355. + // set previous string letter to compare if needed (this check can really conserve time)
  356. + if (IgnoreLetterRepeat) lchar_prev = lchar;
  357. + }
  358. +
  359. + return(true);
  360. +}
  361. +
  362. +bool LexicsCutter::Check_Lexics(std::string& Phrase)
  363. +{
  364. + std::string lchar;
  365. + LC_WordMap::iterator i;
  366. + std::pair< LC_WordMap::iterator, LC_WordMap::iterator > ii;
  367. +
  368. + if (Phrase.size() == 0) return(false);
  369. +
  370. + // first, convert the string, adding spaces and removing invalid characters
  371. + // also create fast position vector for the new positions
  372. + std::string str = " ";
  373. + unsigned int pos = 0;
  374. + while (ReadUTF8(Phrase, lchar, pos))
  375. + {
  376. + if (InvalidChars.find(lchar) == std::string::npos)
  377. + {
  378. + str.append(lchar);
  379. + }
  380. + }
  381. +
  382. + // string prepared, now parse it and scan for all the words
  383. + unsigned int pos_prev = 0;
  384. + pos = 0;
  385. + while (ReadUTF8(str, lchar, pos))
  386. + {
  387. + // got character, now try to find wordmap for it
  388. + ii = WordMap.equal_range(lchar);
  389. + // iterate over all found words
  390. + for (i = ii.first; i != ii.second; i++)
  391. + {
  392. + // compare word at initial position
  393. + if (Compare_Word(str, pos_prev, WordList[i->second])) return(true);
  394. + }
  395. + // set initial position to the current position
  396. + pos_prev = pos;
  397. + }
  398. +
  399. + return(false);
  400. +}
  401. \ No newline at end of file
  402. diff -r c7781fec4099 -r 154cbf33d79a src/game/ChatLexicsCutter.h
  403. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  404. +++ b/src/game/ChatLexicsCutter.h Mon May 07 07:39:09 2012 +0300
  405. @@ -0,0 +1,66 @@
  406. +/*
  407. + * Copyright (C) 2005,2006,2007 MaNGOS <http://www.oregonproject.org/>
  408. + *
  409. + * This program is free software; you can redistribute it and/or modify
  410. + * it under the terms of the GNU General Public License as published by
  411. + * the Free Software Foundation; either version 2 of the License, or
  412. + * (at your option) any later version.
  413. + *
  414. + * This program is distributed in the hope that it will be useful,
  415. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  416. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  417. + * GNU General Public License for more details.
  418. + *
  419. + * You should have received a copy of the GNU General Public License
  420. + * along with this program; if not, write to the Free Software
  421. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  422. + */
  423. +
  424. +#ifndef OREGONSERVER_CHATLEXICSCUTTER_H
  425. +#define OREGONSERVER_CHATLEXICSCUTTER_H
  426. +
  427. +typedef std::vector< std::string > LC_AnalogVector;
  428. +typedef std::map< std::string, LC_AnalogVector > LC_AnalogMap;
  429. +typedef std::set< std::string > LC_LetterSet;
  430. +typedef std::vector< LC_LetterSet > LC_WordVector;
  431. +typedef std::vector< LC_WordVector > LC_WordList;
  432. +typedef std::multimap< std::string, unsigned int > LC_WordMap;
  433. +
  434. +static int trailingBytesForUTF8[256] = {
  435. + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  436. + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  437. + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  438. + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  439. + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  440. + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  441. + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  442. + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
  443. +};
  444. +
  445. +class LexicsCutter
  446. +{
  447. + protected:
  448. + LC_AnalogMap AnalogMap;
  449. + LC_WordList WordList;
  450. + LC_WordMap WordMap;
  451. +
  452. + std::string InvalidChars;
  453. +
  454. + public:
  455. + LexicsCutter();
  456. +
  457. + static bool ReadUTF8(std::string& in, std::string& out, unsigned int& pos);
  458. +
  459. + std::string trim(std::string& s, const std::string& drop = " ");
  460. + bool Read_Letter_Analogs(std::string& FileName);
  461. + bool Read_Innormative_Words(std::string& FileName);
  462. + void Map_Innormative_Words();
  463. + bool Compare_Word(std::string& str, unsigned int pos, LC_WordVector word);
  464. + bool Check_Lexics(std::string& Phrase);
  465. +
  466. + std::vector< std::pair< unsigned int, unsigned int > > Found;
  467. + bool IgnoreMiddleSpaces;
  468. + bool IgnoreLetterRepeat;
  469. +};
  470. +
  471. +#endif
  472. diff -r c7781fec4099 -r 154cbf33d79a src/game/ChatLog.cpp
  473. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  474. +++ b/src/game/ChatLog.cpp Mon May 07 07:39:09 2012 +0300
  475. @@ -0,0 +1,784 @@
  476. +/*
  477. + * Copyright (C) 2005,2006,2007 MaNGOS <http://www.oregonproject.org/>
  478. + *
  479. + * This program is free software; you can redistribute it and/or modify
  480. + * it under the terms of the GNU General Public License as published by
  481. + * the Free Software Foundation; either version 2 of the License, or
  482. + * (at your option) any later version.
  483. + *
  484. + * This program is distributed in the hope that it will be useful,
  485. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  486. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  487. + * GNU General Public License for more details.
  488. + *
  489. + * You should have received a copy of the GNU General Public License
  490. + * along with this program; if not, write to the Free Software
  491. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  492. + */
  493. +
  494. +#include "Common.h"
  495. +#include "ChatLexicsCutter.h"
  496. +#include "ChatLog.h"
  497. +#include "Chat.h"
  498. +#include "Group.h"
  499. +#include "Guild.h"
  500. +#include "ObjectMgr.h"
  501. +#include "SpellAuras.h"
  502. +#include "Policies/SingletonImp.h"
  503. +#include "Config/Config.h"
  504. +
  505. +INSTANTIATE_SINGLETON_1( ChatLog );
  506. +
  507. +ChatLog::ChatLog()
  508. +{
  509. + for (int i = 0; i <= CHATLOG_CHAT_TYPES_COUNT - 1; i++)
  510. + {
  511. + names[i] = "";
  512. + files[i] = NULL;
  513. + }
  514. +
  515. + Lexics = NULL;
  516. + fn_innormative = "";
  517. + f_innormative = NULL;
  518. +
  519. + Initialize();
  520. +}
  521. +
  522. +ChatLog::~ChatLog()
  523. +{
  524. + // close all files (avoiding double-close)
  525. + CloseAllFiles();
  526. +
  527. + if (Lexics)
  528. + {
  529. + delete Lexics;
  530. + Lexics = NULL;
  531. + }
  532. +}
  533. +
  534. +void ChatLog::Initialize()
  535. +{
  536. + // determine, if the chat logs are enabled
  537. + ChatLogEnable = sConfig.GetBoolDefault("ChatLogEnable", false);
  538. + ChatLogDateSplit = sConfig.GetBoolDefault("ChatLogDateSplit", false);
  539. + ChatLogUTFHeader = sConfig.GetBoolDefault("ChatLogUTFHeader", false);
  540. + ChatLogIgnoreUnprintable = sConfig.GetBoolDefault("ChatLogIgnoreUnprintable", false);
  541. +
  542. + if (ChatLogEnable)
  543. + {
  544. + // read chat log file names
  545. + names[CHAT_LOG_CHAT] = sConfig.GetStringDefault("ChatLogChatFile", "");
  546. + names[CHAT_LOG_PARTY] = sConfig.GetStringDefault("ChatLogPartyFile", "");
  547. + names[CHAT_LOG_GUILD] = sConfig.GetStringDefault("ChatLogGuildFile", "");
  548. + names[CHAT_LOG_WHISPER] = sConfig.GetStringDefault("ChatLogWhisperFile", "");
  549. + names[CHAT_LOG_CHANNEL] = sConfig.GetStringDefault("ChatLogChannelFile", "");
  550. + names[CHAT_LOG_RAID] = sConfig.GetStringDefault("ChatLogRaidFile", "");
  551. + names[CHAT_LOG_BATTLEGROUND] = sConfig.GetStringDefault("ChatLogBattleGroundFile", "");
  552. +
  553. + // read screen log flags
  554. + screenflag[CHAT_LOG_CHAT] = sConfig.GetBoolDefault("ChatLogChatScreen", false);
  555. + screenflag[CHAT_LOG_PARTY] = sConfig.GetBoolDefault("ChatLogPartyScreen", false);
  556. + screenflag[CHAT_LOG_GUILD] = sConfig.GetBoolDefault("ChatLogGuildScreen", false);
  557. + screenflag[CHAT_LOG_WHISPER] = sConfig.GetBoolDefault("ChatLogWhisperScreen", false);
  558. + screenflag[CHAT_LOG_CHANNEL] = sConfig.GetBoolDefault("ChatLogChannelScreen", false);
  559. + screenflag[CHAT_LOG_RAID] = sConfig.GetBoolDefault("ChatLogRaidScreen", false);
  560. + screenflag[CHAT_LOG_BATTLEGROUND] = sConfig.GetBoolDefault("ChatLogBattleGroundScreen", false);
  561. + }
  562. +
  563. + // lexics cutter
  564. + LexicsCutterEnable = sConfig.GetBoolDefault("LexicsCutterEnable", false);
  565. +
  566. + if (LexicsCutterEnable)
  567. + {
  568. + // initialize lexics cutter parameters
  569. + LexicsCutterInnormativeCut = sConfig.GetBoolDefault("LexicsCutterInnormativeCut", true);
  570. + LexicsCutterNoActionOnGM = sConfig.GetBoolDefault("LexicsCutterNoActionOnGM", true);
  571. + LexicsCutterScreenLog = sConfig.GetBoolDefault("LexicsCutterScreenLog", false);
  572. + LexicsCutterCutReplacement = sConfig.GetStringDefault("LexicsCutterCutReplacement", "&!@^%!^&*!!! [gibberish]");
  573. + LexicsCutterAction = sConfig.GetIntDefault("LexicsCutterAction", 0);
  574. + LexicsCutterActionDuration = sConfig.GetIntDefault("LexicsCutterActionDuration", 60000);
  575. + std::string fn_analogsfile = sConfig.GetStringDefault("LexicsCutterAnalogsFile", "");
  576. + std::string fn_wordsfile = sConfig.GetStringDefault("LexicsCutterWordsFile", "");
  577. +
  578. + // read lexics cutter flags
  579. + cutflag[CHAT_LOG_CHAT] = sConfig.GetBoolDefault("LexicsCutInChat", true);
  580. + cutflag[CHAT_LOG_PARTY] = sConfig.GetBoolDefault("LexicsCutInParty", true);
  581. + cutflag[CHAT_LOG_GUILD] = sConfig.GetBoolDefault("LexicsCutInGuild", true);
  582. + cutflag[CHAT_LOG_WHISPER] = sConfig.GetBoolDefault("LexicsCutInWhisper", true);
  583. + cutflag[CHAT_LOG_CHANNEL] = sConfig.GetBoolDefault("LexicsCutInChannel", true);
  584. + cutflag[CHAT_LOG_RAID] = sConfig.GetBoolDefault("LexicsCutInRaid", true);
  585. + cutflag[CHAT_LOG_BATTLEGROUND] = sConfig.GetBoolDefault("LexicsCutInBattleGround", true);
  586. +
  587. + if (fn_analogsfile == "" || fn_wordsfile == "")
  588. + {
  589. + LexicsCutterEnable = false;
  590. + }
  591. + else
  592. + {
  593. + // initialize lexics cutter
  594. + Lexics = new LexicsCutter;
  595. + if (Lexics) Lexics->Read_Letter_Analogs(fn_analogsfile);
  596. + if (Lexics) Lexics->Read_Innormative_Words(fn_wordsfile);
  597. + if (Lexics) Lexics->Map_Innormative_Words();
  598. +
  599. + // read additional parameters
  600. + Lexics->IgnoreLetterRepeat = sConfig.GetBoolDefault("LexicsCutterIgnoreRepeats", true);
  601. + Lexics->IgnoreMiddleSpaces = sConfig.GetBoolDefault("LexicsCutterIgnoreSpaces", true);
  602. + fn_innormative = sConfig.GetStringDefault("LexicsCutterLogFile", "");
  603. + }
  604. + }
  605. +
  606. + // open all files (with aliasing)
  607. + OpenAllFiles();
  608. +
  609. + // write timestamps (init)
  610. + WriteInitStamps();
  611. +}
  612. +
  613. +bool ChatLog::_ChatCommon(int ChatType, Player *player, std::string &msg)
  614. +{
  615. + if (LexicsCutterEnable && Lexics && cutflag[ChatType] && Lexics->Check_Lexics(msg)) ChatBadLexicsAction(player, msg);
  616. +
  617. + if (!ChatLogEnable) return(false);
  618. +
  619. + if (ChatLogIgnoreUnprintable)
  620. + {
  621. + // have to ignore unprintables, verify string by UTF8 here
  622. + unsigned int pos = 0;
  623. + std::string lchar;
  624. + while (LexicsCutter::ReadUTF8(msg, lchar, pos))
  625. + {
  626. + if (lchar.size() == 1)
  627. + {
  628. + if (lchar[0] < ' ') return(false); // unprintable detected
  629. + }
  630. + }
  631. + }
  632. +
  633. + return(true);
  634. +}
  635. +
  636. +void ChatLog::ChatMsg(Player *player, std::string &msg, uint32 type)
  637. +{
  638. + if (!_ChatCommon(CHAT_LOG_CHAT, player, msg)) return;
  639. +
  640. + CheckDateSwitch();
  641. +
  642. + std::string log_str = "";
  643. +
  644. + switch (type)
  645. + {
  646. + case CHAT_MSG_EMOTE:
  647. + log_str.append("{EMOTE} ");
  648. + break;
  649. +
  650. + case CHAT_MSG_YELL:
  651. + log_str.append("{YELL} ");
  652. + break;
  653. + }
  654. +
  655. + log_str.append("[");
  656. + log_str.append(player->GetName());
  657. + log_str.append("] ");
  658. +
  659. + log_str.append(msg);
  660. +
  661. + log_str.append("\n");
  662. +
  663. + if (screenflag[CHAT_LOG_CHAT]) printf("%s", log_str.c_str());
  664. + if (files[CHAT_LOG_CHAT])
  665. + {
  666. + OutTimestamp(files[CHAT_LOG_CHAT]);
  667. + fprintf(files[CHAT_LOG_CHAT], "%s", log_str.c_str());
  668. + fflush(files[CHAT_LOG_CHAT]);
  669. + }
  670. +}
  671. +
  672. +void ChatLog::PartyMsg(Player *player, std::string &msg)
  673. +{
  674. + if (!_ChatCommon(CHAT_LOG_PARTY, player, msg)) return;
  675. +
  676. + CheckDateSwitch();
  677. +
  678. + std::string log_str = "";
  679. +
  680. + log_str.append("[");
  681. + log_str.append(player->GetName());
  682. + log_str.append("]->GROUP:");
  683. +
  684. + Group *group = player->GetGroup();
  685. + if (!group)
  686. + {
  687. + log_str.append("[unknown group] ");
  688. + }
  689. + else
  690. + {
  691. + // obtain group information
  692. + log_str.append("[");
  693. +
  694. + uint8 gm_count = group->GetMembersCount();
  695. + uint8 gm_count_m1 = gm_count - 1;
  696. + uint64 gm_leader_GUID = group->GetLeaderGUID();
  697. + Player *gm_member;
  698. +
  699. + gm_member = objmgr.GetPlayer(gm_leader_GUID);
  700. + if (gm_member)
  701. + {
  702. + log_str.append(gm_member->GetName());
  703. + log_str.append(",");
  704. + }
  705. +
  706. + Group::MemberSlotList g_members = group->GetMemberSlots();
  707. +
  708. + for (Group::member_citerator itr = g_members.begin(); itr != g_members.end(); itr++)
  709. + {
  710. + if (itr->guid == gm_leader_GUID) continue;
  711. +
  712. + gm_member = objmgr.GetPlayer(itr->guid);
  713. + if (gm_member)
  714. + {
  715. + log_str.append(itr->name);
  716. + log_str.append(",");
  717. + }
  718. + }
  719. +
  720. + log_str.erase(log_str.length() - 1);
  721. + log_str.append("] ");
  722. + }
  723. +
  724. + log_str.append(msg);
  725. +
  726. + log_str.append("\n");
  727. +
  728. + if (screenflag[CHAT_LOG_PARTY]) printf("%s", log_str.c_str());
  729. + if (files[CHAT_LOG_PARTY])
  730. + {
  731. + OutTimestamp(files[CHAT_LOG_PARTY]);
  732. + fprintf(files[CHAT_LOG_PARTY], "%s", log_str.c_str());
  733. + fflush(files[CHAT_LOG_PARTY]);
  734. + }
  735. +}
  736. +
  737. +void ChatLog::GuildMsg(Player *player, std::string &msg, bool officer)
  738. +{
  739. + if (!_ChatCommon(CHAT_LOG_GUILD, player, msg)) return;
  740. +
  741. + CheckDateSwitch();
  742. +
  743. + std::string log_str = "";
  744. +
  745. + log_str.append("[");
  746. + log_str.append(player->GetName());
  747. + log_str.append((officer ? "]->GUILD_OFF:" : "]->GUILD:"));
  748. +
  749. + if (!player->GetGuildId())
  750. + {
  751. + log_str.append("[unknown guild] ");
  752. + }
  753. + else
  754. + {
  755. + Guild *guild = objmgr.GetGuildById(player->GetGuildId());
  756. + if (!guild)
  757. + {
  758. + log_str.append("[unknown guild] ");
  759. + }
  760. + else
  761. + {
  762. + // obtain guild information
  763. + log_str.append("(");
  764. + log_str.append(guild->GetName());
  765. + log_str.append(") ");
  766. + }
  767. + }
  768. +
  769. + log_str.append(msg);
  770. +
  771. + log_str.append("\n");
  772. +
  773. + if (screenflag[CHAT_LOG_GUILD]) printf("%s", log_str.c_str());
  774. + if (files[CHAT_LOG_GUILD])
  775. + {
  776. + OutTimestamp(files[CHAT_LOG_GUILD]);
  777. + fprintf(files[CHAT_LOG_GUILD], "%s", log_str.c_str());
  778. + fflush(files[CHAT_LOG_GUILD]);
  779. + }
  780. +}
  781. +
  782. +void ChatLog::WhisperMsg(Player *player, std::string &to, std::string &msg)
  783. +{
  784. + if (!_ChatCommon(CHAT_LOG_WHISPER, player, msg)) return;
  785. +
  786. + CheckDateSwitch();
  787. +
  788. + std::string log_str = "";
  789. +
  790. + log_str.append("[");
  791. + log_str.append(player->GetName());
  792. + log_str.append("]->");
  793. +
  794. + if (to.size() == 0)
  795. + {
  796. + log_str.append("[???] ");
  797. + }
  798. + else
  799. + {
  800. + normalizePlayerName(to);
  801. + log_str.append("[");
  802. + log_str.append(to);
  803. + log_str.append("] ");
  804. + }
  805. +
  806. + log_str.append(msg);
  807. +
  808. + log_str.append("\n");
  809. +
  810. + if (screenflag[CHAT_LOG_WHISPER]) printf("%s", log_str.c_str());
  811. + if (files[CHAT_LOG_WHISPER])
  812. + {
  813. + OutTimestamp(files[CHAT_LOG_WHISPER]);
  814. + fprintf(files[CHAT_LOG_WHISPER], "%s", log_str.c_str());
  815. + fflush(files[CHAT_LOG_WHISPER]);
  816. + }
  817. +}
  818. +
  819. +void ChatLog::ChannelMsg(Player *player, std::string &channel, std::string &msg)
  820. +{
  821. + if (!_ChatCommon(CHAT_LOG_CHANNEL, player, msg)) return;
  822. +
  823. + CheckDateSwitch();
  824. +
  825. + std::string log_str = "";
  826. +
  827. + log_str.append("[");
  828. + log_str.append(player->GetName());
  829. + log_str.append("]->CHANNEL:");
  830. +
  831. + if (channel.size() == 0)
  832. + {
  833. + log_str.append("[unknown channel] ");
  834. + }
  835. + else
  836. + {
  837. + log_str.append("[");
  838. + log_str.append(channel);
  839. + log_str.append("] ");
  840. + }
  841. +
  842. + log_str.append(msg);
  843. +
  844. + log_str.append("\n");
  845. +
  846. + if (screenflag[CHAT_LOG_CHANNEL]) printf("%s", log_str.c_str());
  847. + if (files[CHAT_LOG_CHANNEL])
  848. + {
  849. + OutTimestamp(files[CHAT_LOG_CHANNEL]);
  850. + fprintf(files[CHAT_LOG_CHANNEL], "%s", log_str.c_str());
  851. + fflush(files[CHAT_LOG_CHANNEL]);
  852. + }
  853. +}
  854. +
  855. +void ChatLog::RaidMsg(Player *player, std::string &msg, uint32 type)
  856. +{
  857. + if (!_ChatCommon(CHAT_LOG_RAID, player, msg)) return;
  858. +
  859. + CheckDateSwitch();
  860. +
  861. + std::string log_str = "";
  862. +
  863. + log_str.append("[");
  864. + log_str.append(player->GetName());
  865. +
  866. + switch (type)
  867. + {
  868. + case CHAT_MSG_RAID:
  869. + log_str.append("]->RAID:");
  870. + break;
  871. +
  872. + case CHAT_MSG_RAID_LEADER:
  873. + log_str.append("]->RAID_LEADER:");
  874. + break;
  875. +
  876. + case CHAT_MSG_RAID_WARNING:
  877. + log_str.append("]->RAID_WARN:");
  878. + break;
  879. +
  880. + default:
  881. + log_str.append("]->RAID_UNKNOWN:");
  882. + }
  883. +
  884. + Group *group = player->GetGroup();
  885. + if (!group)
  886. + {
  887. + log_str.append("[unknown raid] ");
  888. + }
  889. + else
  890. + {
  891. + // obtain group information
  892. + log_str.append("[");
  893. +
  894. + uint8 gm_count = group->GetMembersCount();
  895. + uint8 gm_count_m1 = gm_count - 1;
  896. + uint64 gm_leader_GUID = group->GetLeaderGUID();
  897. + Player *gm_member;
  898. +
  899. + gm_member = objmgr.GetPlayer(gm_leader_GUID);
  900. + if (gm_member)
  901. + {
  902. + log_str.append(gm_member->GetName());
  903. + log_str.append(",");
  904. + }
  905. +
  906. + Group::MemberSlotList g_members = group->GetMemberSlots();
  907. +
  908. + for (Group::member_citerator itr = g_members.begin(); itr != g_members.end(); itr++)
  909. + {
  910. + if (itr->guid == gm_leader_GUID) continue;
  911. +
  912. + gm_member = objmgr.GetPlayer(itr->guid);
  913. + if (gm_member)
  914. + {
  915. + log_str.append(itr->name);
  916. + log_str.append(",");
  917. + }
  918. + }
  919. +
  920. + log_str.erase(log_str.length() - 1);
  921. + log_str.append("] ");
  922. + }
  923. +
  924. + log_str.append(msg);
  925. +
  926. + log_str.append("\n");
  927. +
  928. + if (screenflag[CHAT_LOG_RAID]) printf("%s", log_str.c_str());
  929. + if (files[CHAT_LOG_RAID])
  930. + {
  931. + OutTimestamp(files[CHAT_LOG_RAID]);
  932. + fprintf(files[CHAT_LOG_RAID], "%s", log_str.c_str());
  933. + fflush(files[CHAT_LOG_RAID]);
  934. + }
  935. +}
  936. +
  937. +void ChatLog::BattleGroundMsg(Player *player, std::string &msg, uint32 type)
  938. +{
  939. + if (!_ChatCommon(CHAT_LOG_BATTLEGROUND, player, msg)) return;
  940. +
  941. + CheckDateSwitch();
  942. +
  943. + std::string log_str = "";
  944. +
  945. + log_str.append("[");
  946. + log_str.append(player->GetName());
  947. +
  948. + switch (type)
  949. + {
  950. + case CHAT_MSG_BATTLEGROUND:
  951. + log_str.append("]->BG:");
  952. + break;
  953. +
  954. + case CHAT_MSG_BATTLEGROUND_LEADER:
  955. + log_str.append("]->BG_LEADER:");
  956. + break;
  957. +
  958. + default:
  959. + log_str.append("]->BG_UNKNOWN:");
  960. + }
  961. +
  962. + Group *group = player->GetGroup();
  963. + if (!group)
  964. + {
  965. + log_str.append("[unknown group] ");
  966. + }
  967. + else
  968. + {
  969. + // obtain group information
  970. + log_str.append("[");
  971. +
  972. + uint8 gm_count = group->GetMembersCount();
  973. + uint8 gm_count_m1 = gm_count - 1;
  974. + uint64 gm_leader_GUID = group->GetLeaderGUID();
  975. + Player *gm_member;
  976. +
  977. + gm_member = objmgr.GetPlayer(gm_leader_GUID);
  978. + if (gm_member)
  979. + {
  980. + log_str.append(gm_member->GetName());
  981. + log_str.append(",");
  982. + }
  983. +
  984. + Group::MemberSlotList g_members = group->GetMemberSlots();
  985. +
  986. + for (Group::member_citerator itr = g_members.begin(); itr != g_members.end(); itr++)
  987. + {
  988. + if (itr->guid == gm_leader_GUID) continue;
  989. +
  990. + gm_member = objmgr.GetPlayer(itr->guid);
  991. + if (gm_member)
  992. + {
  993. + log_str.append(itr->name);
  994. + log_str.append(",");
  995. + }
  996. + }
  997. +
  998. + log_str.erase(log_str.length() - 1);
  999. + log_str.append("] ");
  1000. + }
  1001. +
  1002. + log_str.append(msg);
  1003. +
  1004. + log_str.append("\n");
  1005. +
  1006. + if (screenflag[CHAT_LOG_BATTLEGROUND]) printf("%s", log_str.c_str());
  1007. + if (files[CHAT_LOG_BATTLEGROUND])
  1008. + {
  1009. + OutTimestamp(files[CHAT_LOG_BATTLEGROUND]);
  1010. + fprintf(files[CHAT_LOG_BATTLEGROUND], "%s", log_str.c_str());
  1011. + fflush(files[CHAT_LOG_BATTLEGROUND]);
  1012. + }
  1013. +}
  1014. +
  1015. +void ChatLog::OpenAllFiles()
  1016. +{
  1017. + std::string tempname;
  1018. + char dstr[12];
  1019. +
  1020. + if (ChatLogDateSplit)
  1021. + {
  1022. + time_t t = time(NULL);
  1023. + tm* aTm = localtime(&t);
  1024. + sprintf(dstr, "%-4d-%02d-%02d", aTm->tm_year + 1900, aTm->tm_mon + 1, aTm->tm_mday);
  1025. + }
  1026. +
  1027. + if (ChatLogEnable)
  1028. + {
  1029. + for (int i = 0; i <= CHATLOG_CHAT_TYPES_COUNT - 1; i++)
  1030. + {
  1031. + if (names[i] != "")
  1032. + {
  1033. + for (int j = i - 1; j >= 0; j--)
  1034. + {
  1035. + if (names[i] == names[j])
  1036. + {
  1037. + files[i] = files[j];
  1038. + break;
  1039. + }
  1040. + }
  1041. + if (!files[i])
  1042. + {
  1043. + tempname = names[i];
  1044. + if (ChatLogDateSplit)
  1045. + {
  1046. + // append date instead of $d if applicable
  1047. + int dpos = tempname.find("$d");
  1048. + if (dpos != tempname.npos)
  1049. + {
  1050. + tempname.replace(dpos, 2, &dstr[0], 10);
  1051. + }
  1052. + }
  1053. + files[i] = fopen(tempname.c_str(), "a+b");
  1054. + if (ChatLogUTFHeader && (ftell(files[i]) == 0)) fputs("\xEF\xBB\xBF", files[i]);
  1055. + }
  1056. + }
  1057. + }
  1058. + }
  1059. +
  1060. + // initialize innormative log
  1061. + if (LexicsCutterEnable)
  1062. + {
  1063. + if (fn_innormative != "")
  1064. + {
  1065. + tempname = fn_innormative;
  1066. + if (ChatLogDateSplit)
  1067. + {
  1068. + // append date instead of $d if applicable
  1069. + int dpos = tempname.find("$d");
  1070. + if (dpos != tempname.npos)
  1071. + {
  1072. + tempname.replace(dpos, 2, &dstr[0], 10);
  1073. + }
  1074. + }
  1075. + f_innormative = fopen(tempname.c_str(), "a+b");
  1076. + if (ChatLogUTFHeader && (ftell(f_innormative) == 0)) fputs("\xEF\xBB\xBF", f_innormative);
  1077. + }
  1078. + }
  1079. +}
  1080. +
  1081. +void ChatLog::CloseAllFiles()
  1082. +{
  1083. + for (int i = 0; i <= CHATLOG_CHAT_TYPES_COUNT - 1; i++)
  1084. + {
  1085. + if (files[i])
  1086. + {
  1087. + for (int j = i + 1; j <= CHATLOG_CHAT_TYPES_COUNT - 1; j++)
  1088. + {
  1089. + if (files[j] == files[i]) files[j] = NULL;
  1090. + }
  1091. +
  1092. + fclose(files[i]);
  1093. + files[i] = NULL;
  1094. + }
  1095. + }
  1096. +
  1097. + if (f_innormative)
  1098. + {
  1099. + fclose(f_innormative);
  1100. + f_innormative = NULL;
  1101. + }
  1102. +}
  1103. +
  1104. +void ChatLog::CheckDateSwitch()
  1105. +{
  1106. + if (ChatLogDateSplit)
  1107. + {
  1108. + time_t t = time(NULL);
  1109. + tm* aTm = localtime(&t);
  1110. + if (lastday != aTm->tm_mday)
  1111. + {
  1112. + // date switched
  1113. + CloseAllFiles();
  1114. + OpenAllFiles();
  1115. + WriteInitStamps();
  1116. + }
  1117. + }
  1118. +}
  1119. +
  1120. +void ChatLog::WriteInitStamps()
  1121. +{
  1122. + // remember date
  1123. + time_t t = time(NULL);
  1124. + tm* aTm = localtime(&t);
  1125. + lastday = aTm->tm_mday;
  1126. +
  1127. + if (files[CHAT_LOG_CHAT])
  1128. + {
  1129. + OutTimestamp(files[CHAT_LOG_CHAT]);
  1130. + fprintf(files[CHAT_LOG_CHAT], "%s", "[SYSTEM] Chat Log Initialized\n");
  1131. + }
  1132. + if (files[CHAT_LOG_PARTY])
  1133. + {
  1134. + OutTimestamp(files[CHAT_LOG_PARTY]);
  1135. + fprintf(files[CHAT_LOG_PARTY], "%s", "[SYSTEM] Party Chat Log Initialized\n");
  1136. + }
  1137. + if (files[CHAT_LOG_GUILD])
  1138. + {
  1139. + OutTimestamp(files[CHAT_LOG_GUILD]);
  1140. + fprintf(files[CHAT_LOG_GUILD], "%s", "[SYSTEM] Guild Chat Log Initialized\n");
  1141. + }
  1142. + if (files[CHAT_LOG_WHISPER])
  1143. + {
  1144. + OutTimestamp(files[CHAT_LOG_WHISPER]);
  1145. + fprintf(files[CHAT_LOG_WHISPER], "%s", "[SYSTEM] Whisper Log Initialized\n");
  1146. + }
  1147. + if (files[CHAT_LOG_CHANNEL])
  1148. + {
  1149. + OutTimestamp(files[CHAT_LOG_CHANNEL]);
  1150. + fprintf(files[CHAT_LOG_CHANNEL], "%s", "[SYSTEM] Chat Channels Log Initialized\n");
  1151. + }
  1152. + if (files[CHAT_LOG_RAID])
  1153. + {
  1154. + OutTimestamp(files[CHAT_LOG_RAID]);
  1155. + fprintf(files[CHAT_LOG_RAID], "%s", "[SYSTEM] Raid Party Chat Log Initialized\n");
  1156. + }
  1157. +
  1158. + if (f_innormative)
  1159. + {
  1160. + OutTimestamp(f_innormative);
  1161. + fprintf(f_innormative, "%s", "[SYSTEM] Innormative Lexics Log Initialized\n");
  1162. + }
  1163. +}
  1164. +
  1165. +void ChatLog::OutTimestamp(FILE* file)
  1166. +{
  1167. + time_t t = time(NULL);
  1168. + tm* aTm = localtime(&t);
  1169. + fprintf(file, "%-4d-%02d-%02d %02d:%02d:%02d ", aTm->tm_year + 1900, aTm->tm_mon + 1, aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec);
  1170. +}
  1171. +
  1172. +void ChatLog::ChatBadLexicsAction(Player* player, std::string& msg)
  1173. +{
  1174. + // logging
  1175. + std::string log_str = "";
  1176. +
  1177. + log_str.append("[");
  1178. + log_str.append(player->GetName());
  1179. + log_str.append("] ");
  1180. +
  1181. + log_str.append(msg);
  1182. +
  1183. + log_str.append("\n");
  1184. +
  1185. + if (LexicsCutterScreenLog) printf("<INNORMATIVE!> %s", log_str.c_str());
  1186. + if (f_innormative)
  1187. + {
  1188. + OutTimestamp(f_innormative);
  1189. + fprintf(f_innormative, "%s", log_str.c_str());
  1190. + fflush(f_innormative);
  1191. + }
  1192. +
  1193. + // cutting innormative lexics
  1194. + if (LexicsCutterInnormativeCut)
  1195. + {
  1196. + msg = LexicsCutterCutReplacement;
  1197. + }
  1198. +
  1199. + if (!player || !player->GetSession()) return;
  1200. +
  1201. + if (LexicsCutterNoActionOnGM && player->GetSession()->GetSecurity()) return;
  1202. +
  1203. + // special actions
  1204. + const SpellEntry* sl;
  1205. +
  1206. + switch (LexicsCutterAction)
  1207. + {
  1208. + case LEXICS_ACTION_SHEEP:
  1209. + {
  1210. + // sheep me, yeah, yeah, sheep me
  1211. + sl = sSpellStore.LookupEntry(118);
  1212. + if (sl)
  1213. + {
  1214. + for (int i = 0; i < 3; i++)
  1215. + {
  1216. + Aura* Aur = CreateAura(sl, i, NULL, player);
  1217. + if (Aur)
  1218. + {
  1219. + Aur->SetAuraDuration(LexicsCutterActionDuration);
  1220. + player->AddAura(Aur);
  1221. + }
  1222. + }
  1223. + }
  1224. + }
  1225. + break;
  1226. +
  1227. + case LEXICS_ACTION_STUN:
  1228. + {
  1229. + sl = sSpellStore.LookupEntry(13005);
  1230. + if (sl)
  1231. + {
  1232. + for (int i = 0; i < 3; i++)
  1233. + {
  1234. + Aura* Aur = CreateAura(sl, i, NULL, player);
  1235. + if (Aur)
  1236. + {
  1237. + Aur->SetAuraDuration(LexicsCutterActionDuration);
  1238. + player->AddAura(Aur);
  1239. + }
  1240. + }
  1241. + }
  1242. + }
  1243. + break;
  1244. +
  1245. + case LEXICS_ACTION_DIE:
  1246. + player->DealDamage(player, player->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
  1247. + break;
  1248. +
  1249. + case LEXICS_ACTION_SILENCE:
  1250. + {
  1251. + // glue the mouth
  1252. + time_t mutetime = time(NULL) + (int) (LexicsCutterActionDuration / 1000);
  1253. + player->GetSession()->m_muteTime = mutetime;
  1254. + }
  1255. + break;
  1256. +
  1257. + default: break;
  1258. + }
  1259. +}
  1260. \ No newline at end of file
  1261. diff -r c7781fec4099 -r 154cbf33d79a src/game/ChatLog.h
  1262. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  1263. +++ b/src/game/ChatLog.h Mon May 07 07:39:09 2012 +0300
  1264. @@ -0,0 +1,103 @@
  1265. +/*
  1266. + * Copyright (C) 2005,2006,2007 MaNGOS <http://www.oregonproject.org/>
  1267. + *
  1268. + * This program is free software; you can redistribute it and/or modify
  1269. + * it under the terms of the GNU General Public License as published by
  1270. + * the Free Software Foundation; either version 2 of the License, or
  1271. + * (at your option) any later version.
  1272. + *
  1273. + * This program is distributed in the hope that it will be useful,
  1274. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1275. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1276. + * GNU General Public License for more details.
  1277. + *
  1278. + * You should have received a copy of the GNU General Public License
  1279. + * along with this program; if not, write to the Free Software
  1280. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  1281. + */
  1282. +
  1283. +#ifndef OREGONSERVER_CHATLOG_H
  1284. +#define OREGONSERVER_CHATLOG_H
  1285. +
  1286. +#include "SharedDefines.h"
  1287. +#include "ChatLexicsCutter.h"
  1288. +#include "ObjectMgr.h"
  1289. +#include "Policies/Singleton.h"
  1290. +
  1291. +#define CHATLOG_CHAT_TYPES_COUNT 7
  1292. +
  1293. +enum ChatLogFiles
  1294. +{
  1295. + CHAT_LOG_CHAT = 0,
  1296. + CHAT_LOG_PARTY = 1,
  1297. + CHAT_LOG_GUILD = 2,
  1298. + CHAT_LOG_WHISPER = 3,
  1299. + CHAT_LOG_CHANNEL = 4,
  1300. + CHAT_LOG_RAID = 5,
  1301. + CHAT_LOG_BATTLEGROUND = 6,
  1302. +};
  1303. +
  1304. +enum LexicsActions
  1305. +{
  1306. + LEXICS_ACTION_LOG = 0,
  1307. + LEXICS_ACTION_SHEEP = 1,
  1308. + LEXICS_ACTION_STUN = 2,
  1309. + LEXICS_ACTION_DIE = 3,
  1310. + LEXICS_ACTION_SILENCE = 4,
  1311. +};
  1312. +
  1313. +class ChatLog : public Oregon::Singleton<ChatLog, Oregon::ClassLevelLockable<ChatLog, ACE_Thread_Mutex> >
  1314. +{
  1315. + public:
  1316. + ChatLog();
  1317. + ~ChatLog();
  1318. +
  1319. + void Initialize();
  1320. +
  1321. + void ChatMsg(Player *player, std::string &msg, uint32 type);
  1322. + void PartyMsg(Player *player, std::string &msg);
  1323. + void GuildMsg(Player *player, std::string &msg, bool officer);
  1324. + void WhisperMsg(Player *player, std::string &to, std::string &msg);
  1325. + void ChannelMsg(Player *player, std::string &channel, std::string &msg);
  1326. + void RaidMsg(Player *player, std::string &msg, uint32 type);
  1327. + void BattleGroundMsg(Player *player, std::string &msg, uint32 type);
  1328. +
  1329. + void ChatBadLexicsAction(Player *player, std::string &msg);
  1330. +
  1331. + private:
  1332. + bool _ChatCommon(int ChatType, Player *player, std::string &msg);
  1333. +
  1334. + bool ChatLogEnable;
  1335. + bool ChatLogDateSplit;
  1336. + bool ChatLogUTFHeader;
  1337. + bool ChatLogIgnoreUnprintable;
  1338. +
  1339. + int lastday;
  1340. +
  1341. + FILE* files[CHATLOG_CHAT_TYPES_COUNT];
  1342. + std::string names[CHATLOG_CHAT_TYPES_COUNT];
  1343. + bool screenflag[CHATLOG_CHAT_TYPES_COUNT];
  1344. +
  1345. + LexicsCutter* Lexics;
  1346. + bool cutflag[CHATLOG_CHAT_TYPES_COUNT];
  1347. +
  1348. + bool LexicsCutterEnable;
  1349. + bool LexicsCutterInnormativeCut;
  1350. + bool LexicsCutterNoActionOnGM;
  1351. + bool LexicsCutterScreenLog;
  1352. + std::string LexicsCutterCutReplacement;
  1353. + int LexicsCutterAction;
  1354. + int LexicsCutterActionDuration;
  1355. + std::string fn_innormative;
  1356. + FILE* f_innormative;
  1357. +
  1358. + void OpenAllFiles();
  1359. + void CloseAllFiles();
  1360. + void CheckDateSwitch();
  1361. +
  1362. + void WriteInitStamps();
  1363. + void OutTimestamp(FILE *file);
  1364. +};
  1365. +
  1366. +#define sChatLog Oregon::Singleton<ChatLog>::Instance()
  1367. +#endif
  1368. \ No newline at end of file
  1369. diff -r c7781fec4099 -r 154cbf33d79a src/oregoncore/CMakeLists.txt
  1370. --- a/src/oregoncore/CMakeLists.txt Mon Mar 11 00:57:51 2013 +0400
  1371. +++ b/src/oregoncore/CMakeLists.txt Mon May 07 07:39:09 2012 +0300
  1372. @@ -79,6 +79,8 @@
  1373. add_custom_command(TARGET oregon-core
  1374. POST_BUILD
  1375. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/oregoncore.conf.dist ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/
  1376. + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/innormative_words.conf ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/
  1377. + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/letter_analogs.conf ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/
  1378. )
  1379. endif()
  1380.  
  1381. diff -r c7781fec4099 -r 154cbf33d79a src/oregoncore/innormative_words.conf
  1382. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  1383. +++ b/src/oregoncore/innormative_words.conf Mon May 07 07:39:09 2012 +0300
  1384. @@ -0,0 +1,4 @@
  1385. +fuckyou
  1386. +bitch
  1387. +http
  1388. +еблан
  1389. \ No newline at end of file
  1390. diff -r c7781fec4099 -r 154cbf33d79a src/oregoncore/letter_analogs.conf
  1391. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  1392. +++ b/src/oregoncore/letter_analogs.conf Mon May 07 07:39:09 2012 +0300
  1393. @@ -0,0 +1,59 @@
  1394. +аАaA
  1395. +бБbB6
  1396. +вВvVwWB
  1397. +гГgGr
  1398. +дДdDg
  1399. +еЕёЁeE3
  1400. +ёЁеЕeE3
  1401. +жЖzZ
  1402. +зЗzZ3
  1403. +иИйЙiIuU1
  1404. +йЙиИiIjJuU1
  1405. +кКkK
  1406. +лЛlL1
  1407. +мМmM
  1408. +нНnNhH
  1409. +оОoO0Q
  1410. +пПpPn
  1411. +рРrRpP
  1412. +сСcC
  1413. +тТtT7
  1414. +уУuUyY
  1415. +фФfF
  1416. +хХhHxX
  1417. +цЦcC
  1418. +чЧ4
  1419. +шШ
  1420. +щЩ
  1421. +ъЪb
  1422. +ыЫyY
  1423. +ьЬb
  1424. +эЭ3
  1425. +юЮuU
  1426. +яЯR
  1427. +aAаА
  1428. +bBбБВ
  1429. +cCсСцЦ
  1430. +dDдД
  1431. +eEеЕ3
  1432. +fFфФ
  1433. +gGгГ
  1434. +hHхХнН
  1435. +iIиИйЙ1
  1436. +jJйЙиИ1
  1437. +kKкК
  1438. +lLлЛ1
  1439. +mMмМ
  1440. +nNнНп
  1441. +oOоО0
  1442. +pПпPрР
  1443. +qQО0
  1444. +rRрРяЯг
  1445. +sSсС
  1446. +tTтТ
  1447. +uUуУиИ
  1448. +vVвВ
  1449. +wWвВ
  1450. +xXхХ
  1451. +yYыЫуУ
  1452. +zZзЗ
  1453. \ No newline at end of file
  1454. diff -r c7781fec4099 -r 154cbf33d79a src/oregoncore/oregoncore.conf.dist
  1455. --- a/src/oregoncore/oregoncore.conf.dist Mon Mar 11 00:57:51 2013 +0400
  1456. +++ b/src/oregoncore/oregoncore.conf.dist Mon May 07 07:39:09 2012 +0300
  1457. @@ -2073,3 +2073,75 @@
  1458. Warden.ClientCheckHoldOff = 15
  1459. Warden.LogFile = "warden.log"
  1460.  
  1461. +###############################################################################
  1462. +# CHAT LEXICS CUTTER
  1463. +#
  1464. +# Chat log parameters
  1465. +ChatLogEnable = 0
  1466. +
  1467. +# If this is enabled, all $d in file names are replaced with current date
  1468. +# This does include innormative lexics log
  1469. +ChatLogDateSplit = 1
  1470. +#
  1471. +# If this is enabled, UTF8 header is written into new files
  1472. +ChatLogUTFHeader = 1
  1473. +#
  1474. +# If this is enabled, chat log will ignore messages with unprintable chars
  1475. +ChatLogIgnoreUnprintable = 1
  1476. +#
  1477. +# Chat log files
  1478. +ChatLogChatFile = main_chat-$d.log
  1479. +ChatLogPartyFile = party_chat-$d.log
  1480. +ChatLogGuildFile = guild_chat-$d.log
  1481. +ChatLogWhisperFile = whisper_chat-$d.log
  1482. +ChatLogChannelFile = channel_chat-$d.log
  1483. +ChatLogRaidFile = raid_chat-$d.log
  1484. +ChatLogBattleGroundFile = bg_chat-$d.log
  1485. +#
  1486. +# Chat log screen logging
  1487. +ChatLogChatScreen = 0
  1488. +ChatLogPartyScreen = 0
  1489. +ChatLogGuildScreen = 0
  1490. +ChatLogWhisperScreen = 0
  1491. +ChatLogChannelScreen = 0
  1492. +ChatLogRaidScreen = 0
  1493. +ChatLogBattleGroundScreen = 0
  1494. +#
  1495. +# Lexics cutter parameters
  1496. +LexicsCutterEnable = 1
  1497. +
  1498. +LexicsCutterInnormativeCut = 1
  1499. +LexicsCutterCutReplacement = &!@^%!^&*!!!
  1500. +LexicsCutterLogFile = innormative-$d.log
  1501. +LexicsCutterScreenLog = 0
  1502. +LexicsCutterAnalogsFile = letter_analogs.conf
  1503. +LexicsCutterWordsFile = innormative_words.conf
  1504. +#
  1505. +# Where to cut lexics
  1506. +LexicsCutInChat = 1
  1507. +LexicsCutInParty = 1
  1508. +LexicsCutInGuild = 1
  1509. +LexicsCutInWhisper = 1
  1510. +LexicsCutInChannel = 1
  1511. +LexicsCutInRaid = 1
  1512. +LexicsCutInBattleGround = 1
  1513. +#
  1514. +# Ignore word spaces like: W O R D
  1515. +LexicsCutterIgnoreSpaces = 1
  1516. +#
  1517. +# Ignore repeats like: WWOOOORRRRRD
  1518. +LexicsCutterIgnoreRepeats = 1
  1519. +#
  1520. +# --- Action:
  1521. +# --- 0: log only
  1522. +# --- 1: sheep
  1523. +# --- 2: stun
  1524. +# --- 3: kill
  1525. +# --- 4: leave 5 health
  1526. +# --- 5: disable chat
  1527. +LexicsCutterAction = 0
  1528. +LexicsCutterActionDuration = 60000
  1529. +
  1530. +# Do not perform action on GM if this is enabled
  1531. +LexicsCutterNoActionOnGM = 1
  1532. +###############################################################################
  1533. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement