Advertisement
Guest User

Untitled

a guest
Jan 16th, 2012
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 227.76 KB | None | 0 0
  1. From 5d04e4958d659604f76821e992b81364d633fb6c Mon Sep 17 00:00:00 2001
  2. From: LordPsyan <[email protected]>
  3. Date: Mon, 16 Jan 2012 10:14:40 -0600
  4. Subject: [PATCH] 2012-01-16_MangChat
  5.  
  6. ---
  7. README.MANGCHAT | 31 +
  8. sql/custom/mangos_irc.sql | 55 +
  9. src/game/AuctionHouseHandler.cpp | 4 +
  10. src/game/CMakeLists.txt | 7 +
  11. src/game/Channel.cpp | 5 +
  12. src/game/CharacterHandler.cpp | 4 +
  13. src/game/Chat.cpp | 1 +
  14. src/game/Chat.h | 1 +
  15. src/game/ChatHandler.cpp | 3 +
  16. src/game/GMTicketHandler.cpp | 13 +
  17. src/game/GameEventMgr.cpp | 9 +-
  18. src/game/Level1.cpp | 37 +
  19. src/game/Player.cpp | 11 +
  20. src/game/mangchat/IRCClient.cpp | 103 ++
  21. src/game/mangchat/IRCClient.h | 233 ++++
  22. src/game/mangchat/IRCCmd.cpp | 941 ++++++++++++++
  23. src/game/mangchat/IRCCmd.h | 137 ++
  24. src/game/mangchat/IRCCmde.cpp | 2059 +++++++++++++++++++++++++++++++
  25. src/game/mangchat/IRCConf.cpp | 189 +++
  26. src/game/mangchat/IRCConf.h | 12 +
  27. src/game/mangchat/IRCFunc.h | 268 ++++
  28. src/game/mangchat/IRCIO.cpp | 437 +++++++
  29. src/game/mangchat/IRCLog.cpp | 74 ++
  30. src/game/mangchat/IRCLog.h | 36 +
  31. src/game/mangchat/IRCSock.cpp | 160 +++
  32. src/game/mangchat/MCS_OnlinePlayers.cpp | 83 ++
  33. src/game/mangchat/MCS_OnlinePlayers.h | 41 +
  34. src/game/mangchat/mangchat.conf.dist.in | 204 +++
  35. src/mangosd/Main.cpp | 12 +-
  36. src/mangosd/Master.cpp | 8 +
  37. win/VC90/game.vcproj | 60 +
  38. 31 files changed, 5235 insertions(+), 3 deletions(-)
  39. create mode 100644 README.MANGCHAT
  40. create mode 100644 sql/custom/mangos_irc.sql
  41. create mode 100644 src/game/mangchat/IRCClient.cpp
  42. create mode 100644 src/game/mangchat/IRCClient.h
  43. create mode 100644 src/game/mangchat/IRCCmd.cpp
  44. create mode 100644 src/game/mangchat/IRCCmd.h
  45. create mode 100644 src/game/mangchat/IRCCmde.cpp
  46. create mode 100644 src/game/mangchat/IRCConf.cpp
  47. create mode 100644 src/game/mangchat/IRCConf.h
  48. create mode 100644 src/game/mangchat/IRCFunc.h
  49. create mode 100644 src/game/mangchat/IRCIO.cpp
  50. create mode 100644 src/game/mangchat/IRCLog.cpp
  51. create mode 100644 src/game/mangchat/IRCLog.h
  52. create mode 100644 src/game/mangchat/IRCSock.cpp
  53. create mode 100644 src/game/mangchat/MCS_OnlinePlayers.cpp
  54. create mode 100644 src/game/mangchat/MCS_OnlinePlayers.h
  55. create mode 100644 src/game/mangchat/mangchat.conf.dist.in
  56.  
  57. diff --git a/README.MANGCHAT b/README.MANGCHAT
  58. new file mode 100644
  59. index 0000000..d667dfa
  60. --- /dev/null
  61. +++ b/README.MANGCHAT
  62. @@ -0,0 +1,31 @@
  63. +[url]https://gist.github.com/1003422[/url]
  64. +
  65. +Readme:
  66. +Apply sql/custom/mangos_irc.sql
  67. +Copy and configure mangchat.conf
  68. +
  69. +Changes:
  70. +Sql tables renamed to lowercase format
  71. +
  72. +Authors:
  73. +|Death| <[email protected]>,
  74. +Dj_baby
  75. +Sanaell
  76. +Tase
  77. +Shinzon <[email protected]>
  78. +Xeross
  79. +3raZar3
  80. +the orangevirus team <[url=http://www.orangevir.us]www.orangevir.us[/url]>
  81. +
  82. +Todolist:
  83. +Cleanup
  84. +Rewrite
  85. +
  86. +Compiled under win32 VS2008 with VC90.
  87. +[b]Not tested [u]ingame[/u][/b] ;) again but should work ;)
  88. +
  89. +If you want a clean mangos with this patch here up to date go [url=https://github.com/Darkknight900/mangos/tree/mangchat]here[/url]. For a clean patch you can diff it against my [url=https://github.com/Darkknight900/mangos/tree/master]master[/url] branch it has the same rev. as my patched branch or take the gist.
  90. +
  91. +Up to date for current rev. 116xx
  92. \ No newline at end of file
  93. diff --git a/sql/custom/mangos_irc.sql b/sql/custom/mangos_irc.sql
  94. new file mode 100644
  95. index 0000000..398d8fe
  96. --- /dev/null
  97. +++ b/sql/custom/mangos_irc.sql
  98. @@ -0,0 +1,55 @@
  99. +SET FOREIGN_KEY_CHECKS=0;
  100. +DROP TABLE IF EXISTS `irc_commands`;
  101. +CREATE TABLE `irc_commands` (
  102. + `Command` varchar(10) NOT NULL default '',
  103. + `Description` varchar(150) NOT NULL default '',
  104. + `gmlevel` tinyint(3) unsigned NOT NULL default '0',
  105. + PRIMARY KEY (`Command`)
  106. +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='IRC Module System';
  107. +
  108. +INSERT INTO `irc_commands` VALUES
  109. +('acct', '[acct <Player> <(un)lock/mail/pass/rename>] : Perform Action To <Player> Account.', '2'),
  110. +('ban', '[ban <Player/IP> <ip/acct/unban/reason>] : Ban/Unban <Player>', '2'),
  111. +('chan', '[chan <op/deop/voice/devoice> <*IRC Nick*>] : Set Mode On Yourself, If <IRC Nick> Is Specified Then Set mode On Nick.', '2'),
  112. +('char', '[char <Player> <mailcheat/taxicheat/maxskill/setskill>] : Perform Action To Character.', '2'),
  113. +('fun', '[fun <Player> <Sound/Say>] : Do Selected Fun Action To <Player>.', '2'),
  114. +('help', '[help Command] : Use No Paramaters For List Of Available Commands.', '0'),
  115. +('inchan', '[inchan <Channel>] : Display Users In Selected In Game <Channel>', '0'),
  116. +('info', '[info] : Display Server Info. (Number Of Players Online/Max Since Last Restart/Uptime)', '0'),
  117. +('item', '[item <Player> <add> <ItemID/[ItemName]> <Amount>] : Additem To <Player>, Use <ItemID> Or <[Exact Item Name]>.', '2'),
  118. +('jail', '[jail <Player> <release/Reason>] : Jail Selected <Player> For <Reason>. Using release As <Reason> Releases Player.', '2'),
  119. +('kick', '[kick <Player> <Reason>] : Kick <Player> For <Reason>.', '2'),
  120. +('kill', '[kill <Player> <Reason>] : Kill <Player> For <Reason>.', '2'),
  121. +('level', '[level <Player> <NewLevel>] : Level <Player> To <NewLevel>. *Can Be Done Offline*', '2'),
  122. +('lookup', '[lookup <acct/char/creature/faction/go/item/quest/skill/spell/tele> <ID/Name>] : ', '2'),
  123. +('login', '[login <UserName> <Password>] : Login To MangChat Admin Mode. (Must Be Done In A PM)', '0'),
  124. +('logout', '[logout] : Logout Of MangChat Admin Mode.', '0'),
  125. +('money', '[money <Player> <(-)Money>] : Give Money To <Player>, Use - To Take Money. *Can Be Done Offline*', '2'),
  126. +('mute', '[mute <Player> <release/TimeInMins> <Reason>] : Mute Player For Reason, For <TimeInMins>. Using release As Time Releases Player. *Can Be Done Offline*', '2'),
  127. +('online', '[online] : Display All Users Logged In Game.', '0'),
  128. +('pm', '[pm <Player> <Message>] : Whisper <Player> In WoW <Message>.', '2'),
  129. +('reload', '[reload] : Reload MangChat Config Options And Security Level From DataBase.', '2'),
  130. +('restart', '[restart] : Restart MangChat, NOT MaNGOS World Server Itself. Forces Reconnection To IRC Server.', '2'),
  131. +('revive', '[revive <Player>] : Revive <Player>.', '2'),
  132. +('saveall', '[saveall] : Forces MaNGOS To Save All Players.', '2'),
  133. +('shutdown', '[shutdown <TimeInSeconds>] : Shuts The Server Down In <TimeInSeconds>, Use 0 For Immediate Shut Down', '2'),
  134. +('spell', '[spell <Player> <Cast/Learn/UnLearn> <SpellID>] : Make <Player> <Learn> Or <UnLearn> A Spell, Or <Cast> A Spell On A <Player>.', '2'),
  135. +('tele', '[tele <Player> <l/c/r/to> <Loc.Name/MAPID X Y Z/Recall/Player>] : Teleport Player To Location, Coords, Or Another Player. (l-Location)(c-Coords)', '2'),
  136. +('ticket', '[ticket <list/read/respond/delete> <limit/name/all> <message>] : Manage GM tickets, respond with message', '2'),
  137. +('top', '[top <accttime/chartime/money> <limit>] : Display top stats for given option. Only GM Higher Than Config Option Can Use Limit.', '2'),
  138. +('who', '[who] : Displays Users Currently Logged In To MangChat.', '1'),
  139. +('sysmsg', '[sysmsg <a/n/e> <Message>] : Broadcasts A System Message. (a-Broadcast System Message)(n-Broadcast Notify Message)(e-Event Message)', 3);
  140. +
  141. +SET FOREIGN_KEY_CHECKS=0;
  142. +DROP TABLE IF EXISTS `irc_inchan`;
  143. +CREATE TABLE `irc_inchan` (
  144. + `guid` int(11) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
  145. + `name` varchar(12) NOT NULL default '',
  146. + `channel` varchar(15) NOT NULL default '',
  147. + PRIMARY KEY (`guid`,`channel`)
  148. +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='IRC Module System';
  149. +
  150. +SET FOREIGN_KEY_CHECKS=0;
  151. +
  152. +DELETE FROM `command` WHERE `name` = 'ircpm';
  153. +INSERT INTO `command` VALUES ('ircpm', '1', 'Syntax:.ircpm #nick #Message\r\n\r\nSend a message to a person in irc');
  154. diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp
  155. index 52124bb..c348c5d 100644
  156. --- a/src/game/AuctionHouseHandler.cpp
  157. +++ b/src/game/AuctionHouseHandler.cpp
  158. @@ -29,6 +29,7 @@
  159. #include "Mail.h"
  160. #include "Util.h"
  161. #include "Chat.h"
  162. +#include "mangchat/IRCClient.h"
  163.  
  164. // please DO NOT use iterator++, because it is slower than ++iterator!!!
  165. // post-incrementation is always slower than pre-incrementation !
  166. @@ -364,6 +365,9 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
  167. DETAIL_LOG("selling %s to auctioneer %s with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
  168. itemGuid.GetString().c_str(), auctioneerGuid.GetString().c_str(), bid, buyout, etime, auctionHouseEntry->houseId);
  169.  
  170. + if (sIRC.BOTMASK & 1024)
  171. + sIRC.AHFunc(it->GetEntry(), it->GetProto()->Name1, pl->GetName(), auctionHouseEntry->faction);
  172. +
  173. SendAuctionCommandResult(AH, AUCTION_STARTED, AUCTION_OK);
  174.  
  175. GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, 1);
  176. diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt
  177. index 6f9dd0a..b672503 100644
  178. --- a/src/game/CMakeLists.txt
  179. +++ b/src/game/CMakeLists.txt
  180. @@ -74,6 +74,10 @@ source_group("Movement"
  181. movement/util.cpp
  182. )
  183.  
  184. +source_group("MangChat"
  185. + REGULAR_EXPRESSION mangchat/.*
  186. +)
  187. +
  188. if(PCH)
  189. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  190. endif()
  191. @@ -101,6 +105,9 @@ if(NOT ACE_USE_EXTERNAL)
  192. # add_dependencies(game ace)
  193. endif()
  194.  
  195. +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mangchat/mangchat.conf.dist.in ${CMAKE_CURRENT_BINARY_DIR}/mangchat/mangchat.conf.dist)
  196. +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mangchat/mangchat.conf.dist DESTINATION ${CONF_DIR})
  197. +
  198. # Generate precompiled header
  199. if(PCH)
  200. if(MSVC OR XCODE)
  201. diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp
  202. index 98a7a9c..cfd364c 100644
  203. --- a/src/game/Channel.cpp
  204. +++ b/src/game/Channel.cpp
  205. @@ -20,6 +20,7 @@
  206. #include "ObjectMgr.h"
  207. #include "World.h"
  208. #include "SocialMgr.h"
  209. +#include "mangchat/IRCClient.h"
  210.  
  211. Channel::Channel(const std::string& name, uint32 channel_id)
  212. : m_announce(true), m_moderate(false), m_name(name), m_flags(0), m_channelId(channel_id)
  213. @@ -109,6 +110,8 @@ void Channel::Join(ObjectGuid p, const char *pass)
  214. MakeYouJoined(&data);
  215. SendToOne(&data, p);
  216.  
  217. + sIRC.Handle_WoW_Channel(m_name, sObjectMgr.GetPlayer(p), CHANNEL_JOIN);
  218. +
  219. JoinNotify(p);
  220.  
  221. // if no owner first logged will become
  222. @@ -156,6 +159,8 @@ void Channel::Leave(ObjectGuid p, bool send)
  223.  
  224. LeaveNotify(p);
  225.  
  226. + sIRC.Handle_WoW_Channel(m_name, sObjectMgr.GetPlayer(p), CHANNEL_LEAVE);
  227. +
  228. if(changeowner)
  229. {
  230. ObjectGuid newowner = !m_players.empty() ? m_players.begin()->second.player : ObjectGuid();
  231. diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
  232. index a66f940..930d8b5 100644
  233. --- a/src/game/CharacterHandler.cpp
  234. +++ b/src/game/CharacterHandler.cpp
  235. @@ -38,6 +38,7 @@
  236. #include "Util.h"
  237. #include "ArenaTeam.h"
  238. #include "Language.h"
  239. +#include "mangchat/IRCClient.h"
  240.  
  241. // Playerbot mod:
  242. #include "playerbot/PlayerbotMgr.h"
  243. @@ -872,6 +873,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
  244. pCurrChar->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN, 1);
  245.  
  246. delete holder;
  247. +
  248. + if(sIRC.ajoin == 1)
  249. + sIRC.AutoJoinChannel(pCurrChar);
  250. }
  251.  
  252. void WorldSession::HandleSetFactionAtWarOpcode( WorldPacket & recv_data )
  253. diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
  254. index a04f57c..af71481 100644
  255. --- a/src/game/Chat.cpp
  256. +++ b/src/game/Chat.cpp
  257. @@ -832,6 +832,7 @@ ChatCommand * ChatHandler::getCommandTable()
  258. { "bot", SEC_PLAYER, false, &ChatHandler::HandlePlayerbotCommand, "", NULL },
  259. { "quit", SEC_CONSOLE, true, &ChatHandler::HandleQuitCommand, "", NULL },
  260. { "gearscore", SEC_ADMINISTRATOR, false, &ChatHandler::HandleShowGearScoreCommand, "", NULL },
  261. + { "ircpm", SEC_PLAYER, false, &ChatHandler::HandleIRCpmCommand, "", NULL },
  262.  
  263. { NULL, 0, false, NULL, "", NULL }
  264. };
  265. diff --git a/src/game/Chat.h b/src/game/Chat.h
  266. index fca9a51..2952192 100644
  267. --- a/src/game/Chat.h
  268. +++ b/src/game/Chat.h
  269. @@ -615,6 +615,7 @@ class MANGOS_DLL_SPEC ChatHandler
  270. bool HandlePlayerbotCommand(char* args);
  271. bool HandleQuitCommand(char* args);
  272. bool HandleShowGearScoreCommand(char* args);
  273. + bool HandleIRCpmCommand(char* args);
  274.  
  275. //! Development Commands
  276. bool HandleSaveAllCommand(char* args);
  277. diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp
  278. index 8ac0d77..4b06cdf 100644
  279. --- a/src/game/ChatHandler.cpp
  280. +++ b/src/game/ChatHandler.cpp
  281. @@ -36,6 +36,7 @@
  282. #include "Util.h"
  283. #include "GridNotifiersImpl.h"
  284. #include "CellImpl.h"
  285. +#include "mangchat/IRCClient.h"
  286.  
  287. // Playerbot mod
  288. #include "playerbot/PlayerbotAI.h"
  289. @@ -505,6 +506,8 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
  290.  
  291. sChatLog.ChannelMsg(GetPlayer(), channel, msg);
  292.  
  293. + sIRC.Send_WoW_IRC(_player, channel, msg);
  294. +
  295. if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
  296. if(Channel *chn = cMgr->GetChannel(channel, _player))
  297. chn->Say(_player->GetObjectGuid(), msg.c_str(), lang);
  298. diff --git a/src/game/GMTicketHandler.cpp b/src/game/GMTicketHandler.cpp
  299. index 4501701..41bb6b4 100644
  300. --- a/src/game/GMTicketHandler.cpp
  301. +++ b/src/game/GMTicketHandler.cpp
  302. @@ -24,6 +24,7 @@
  303. #include "ObjectAccessor.h"
  304. #include "Player.h"
  305. #include "Chat.h"
  306. +#include "mangchat/IRCClient.h"
  307.  
  308. void WorldSession::SendGMTicketGetTicket(uint32 status, GMTicket *ticket /*= NULL*/)
  309. {
  310. @@ -94,6 +95,12 @@ void WorldSession::HandleGMTicketDeleteTicketOpcode( WorldPacket & /*recv_data*/
  311. SendPacket( &data );
  312.  
  313. SendGMTicketGetTicket(0x0A);
  314. +
  315. + std::string name = GetPlayer()->GetName();
  316. + std::string channel = std::string("#") + sIRC._irc_chan[sIRC.Status];
  317. + sIRC.Send_IRC_Channel(channel, sIRC.MakeMsg("\00304,08\037/!\\\037\017\00304 GM Ticket Deleted For:\00304,08\037/!\\\037\017 %s", "%s", name.c_str()), true);
  318. +
  319. +
  320. }
  321.  
  322. void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
  323. @@ -139,6 +146,12 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
  324. if (itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets())
  325. ChatHandler(itr->second).PSendSysMessage(LANG_COMMAND_TICKETNEW,GetPlayer()->GetName());
  326. }
  327. +
  328. + std::string name = GetPlayer()->GetName();
  329. + std::string details = ticketText;
  330. + std::string channel = std::string("#") + sIRC._irc_chan[sIRC.Status];
  331. + sIRC.Send_IRC_Channel(channel, sIRC.MakeMsg("\00304,08\037/!\\\037\017\00304 New GM Ticket from:\00304,08\037/!\\\037\017 %s", "%s", name.c_str()), true);
  332. + sIRC.Send_IRC_Channel(channel, sIRC.MakeMsg("\00304,08\037/!\\\037\017\00304 Ticket Details:\00304,08\037/!\\\037\017 %s", "%s", details.c_str()), true);
  333. }
  334.  
  335. void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket & /*recv_data*/ )
  336. diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp
  337. index d82e1b6..dc03c3f 100644
  338. --- a/src/game/GameEventMgr.cpp
  339. +++ b/src/game/GameEventMgr.cpp
  340. @@ -29,6 +29,7 @@
  341. #include "MassMailMgr.h"
  342. #include "SpellMgr.h"
  343. #include "Policies/SingletonImp.h"
  344. +#include "mangchat/IRCClient.h"
  345.  
  346. INSTANTIATE_SINGLETON_1(GameEventMgr);
  347.  
  348. @@ -670,8 +671,14 @@ void GameEventMgr::ApplyNewEvent(uint16 event_id, bool resume)
  349. CharacterDatabase.PExecute("REPLACE INTO game_event_status (event) VALUES (%u)", event_id);
  350.  
  351. if (sWorld.getConfig(CONFIG_BOOL_EVENT_ANNOUNCE))
  352. + {
  353. sWorld.SendWorldText(LANG_EVENTMESSAGE, mGameEvent[event_id].description.c_str());
  354. -
  355. + if(sIRC.BOTMASK & 256)
  356. + {
  357. + std::string ircchan = std::string("#")+sIRC._irc_chan[sIRC.anchn];
  358. + sIRC.Send_IRC_Channel(ircchan, sIRC.MakeMsg("\00304,08\037/!\\\037\017\00304 Game Event \00304,08\037/!\\\037\017 %s", "%s", mGameEvent[event_id].description.c_str()), true);
  359. + }
  360. + }
  361. sLog.outString("GameEvent %u \"%s\" started.", event_id, mGameEvent[event_id].description.c_str());
  362. // spawn positive event tagget objects
  363. GameEventSpawn(event_id);
  364. diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
  365. index b0f94de..ecb98b0 100644
  366. --- a/src/game/Level1.cpp
  367. +++ b/src/game/Level1.cpp
  368. @@ -33,6 +33,7 @@
  369. #include "MapPersistentStateMgr.h"
  370. #include "Mail.h"
  371. #include "Util.h"
  372. +#include "mangchat/IRCClient.h"
  373. #ifdef _DEBUG_VMAPS
  374. #include "VMapFactory.h"
  375. #endif
  376. @@ -127,6 +128,11 @@ bool ChatHandler::HandleAnnounceCommand(char* args)
  377. return false;
  378.  
  379. sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args);
  380. + if (sIRC.BOTMASK & 256)
  381. + {
  382. + std::string channel = "#" + sIRC._irc_chan[sIRC.anchn];
  383. + sIRC.Send_IRC_Channel(channel, sIRC.MakeMsg("\00304,08\037/!\\\037\017\00304 System Message \00304,08\037/!\\\037\017 %s", "%s", args), true);
  384. + }
  385. return true;
  386. }
  387.  
  388. @@ -143,6 +149,12 @@ bool ChatHandler::HandleNotifyCommand(char* args)
  389. data << str;
  390. sWorld.SendGlobalMessage(&data);
  391.  
  392. + if (sIRC.BOTMASK & 256)
  393. + {
  394. + std::string ircchan = std::string("#") + sIRC._irc_chan[sIRC.anchn];
  395. + sIRC.Send_IRC_Channel(ircchan, sIRC.MakeMsg("\00304,08\037/!\\\037\017\00304 Global Notify \00304,08\037/!\\\037\017 %s", "%s", args), true);
  396. + }
  397. +
  398. return true;
  399. }
  400.  
  401. @@ -2290,3 +2302,28 @@ bool ChatHandler::HandleSetViewCommand(char* /*args*/)
  402.  
  403. return true;
  404. }
  405. +
  406. +bool ChatHandler::HandleIRCpmCommand(char* args)
  407. +{
  408. + if (!*args)
  409. + return false;
  410. +
  411. + std::string Msg = args;
  412. + if (Msg.find(" ") == std::string::npos)
  413. + return false;
  414. +
  415. + std::string To = Msg.substr(0, Msg.find(" "));
  416. + Msg = Msg.substr(Msg.find(" ") + 1);
  417. + std::size_t pos;
  418. +
  419. + while((pos = To.find("||")) != std::string::npos)
  420. + {
  421. + std::size_t find1 = To.find("||", pos);
  422. + To.replace(pos, find1 - pos + 2, "|");
  423. + }
  424. +
  425. + sIRC.SendIRC("PRIVMSG "+To+" : <WoW>["+m_session->GetPlayerName()+"] : " + Msg);
  426. + sIRC.Send_WoW_Player(m_session->GetPlayer(), "|cffCC4ACCTo ["+To+"]: "+Msg);
  427. +
  428. + return true;
  429. +}
  430. diff --git a/src/game/Player.cpp b/src/game/Player.cpp
  431. index 690fd65..1fe61a6 100644
  432. --- a/src/game/Player.cpp
  433. +++ b/src/game/Player.cpp
  434. @@ -62,6 +62,7 @@
  435. #include "Mail.h"
  436. #include "AccountMgr.h"
  437. #include "SpellAuras.h"
  438. +#include "mangchat/IRCClient.h"
  439.  
  440. #include <cmath>
  441.  
  442. @@ -2701,6 +2702,16 @@ void Player::GiveLevel(uint32 level)
  443.  
  444. UpdateAllStats();
  445.  
  446. + if (sIRC.BOTMASK & 64)
  447. + {
  448. + char plevel [3];
  449. + sprintf(plevel, "%u", level);
  450. +
  451. + std::string pname = GetName();
  452. + std::string channel = std::string("#") + sIRC._irc_chan[sIRC.anchn].c_str();
  453. + sIRC.Send_IRC_Channel(channel, "\00311["+pname+"] : Has Reached Level: "+plevel, true);
  454. + }
  455. +
  456. // set current level health and mana/energy to maximum after applying all mods.
  457. if (isAlive())
  458. SetHealth(GetMaxHealth());
  459. diff --git a/src/game/mangchat/IRCClient.cpp b/src/game/mangchat/IRCClient.cpp
  460. new file mode 100644
  461. index 0000000..7d19101
  462. --- /dev/null
  463. +++ b/src/game/mangchat/IRCClient.cpp
  464. @@ -0,0 +1,103 @@
  465. +/*
  466. + * MangChat for MaNGOS, the open source MMORPG-server
  467. + *
  468. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  469. + * Terms Of The GNU General Public License
  470. + *
  471. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  472. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  473. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  474. + *
  475. + * With Help And Support From The MaNGOS Project Community.
  476. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  477. + */
  478. +
  479. +#include "IRCClient.h"
  480. +#include "../World.h"
  481. +#include "../ObjectMgr.h"
  482. +#include "../MapManager.h"
  483. +
  484. +#include "Policies/SingletonImp.h"
  485. +INSTANTIATE_SINGLETON_1( IRCClient );
  486. +
  487. +#ifdef WIN32
  488. + #define Delay(x) Sleep(x)
  489. +#else
  490. + #define Delay(x) sleep(x / 1000)
  491. +#endif
  492. +
  493. +// IRCClient Constructor
  494. +IRCClient::IRCClient()
  495. +{
  496. + for(int i = 0;i > 5;i++)
  497. + sIRC.Script_Lock[i] = false;
  498. +}
  499. +
  500. +// IRCClient Destructor
  501. +IRCClient::~IRCClient(){}
  502. +
  503. +// ZThread Entry This function is called when the thread is created in Master.cpp (mangosd)
  504. +void IRCClient::run()
  505. +{
  506. + sIRC.iLog.WriteLog(" %s : ****** MaNGOS With MangChat Has Been Started ******", sIRC.iLog.GetLogDateTimeStr().c_str());
  507. +
  508. + // Before we begin we wait a while MaNGOS is still starting up.
  509. + ACE_Based::Thread::Sleep(500);
  510. + sLog.outString("\n%s\n%s\n%s\n%s",
  511. + "***************************************",
  512. + "** MangChat Threaded IRC Client **",
  513. + "** for inferna & orangevirus **",
  514. + "***************************************");
  515. + sLog.outString("MangChat: %s", sIRC._Mver.c_str());
  516. + int cCount = 0;
  517. +
  518. + if (!sIRC.Active)
  519. + sLog.outString("MangChat: IRC BOT disabled (irc.active = 0)");
  520. +
  521. + // Clean Up MySQL Tables
  522. + sLog.outString("MangChat: Cleaning Up Inchan Table");
  523. + WorldDatabase.PExecute("DELETE FROM `irc_inchan`");
  524. + sIRC._Max_Script_Inst = 0;
  525. +
  526. + // Create a loop to keep the thread running untill active is set to false
  527. + while(sIRC.Active && !World::IsStopped())
  528. + {
  529. + // Initialize socket library
  530. + if (InitSock())
  531. + {
  532. + // Connect To The IRC Server
  533. + sLog.outString("MangChat: Connecting to %s Try # %d", sIRC._Host.c_str(), cCount);
  534. + if(this->Connect(sIRC._Host.c_str(), sIRC._Port))
  535. + {
  536. + // On connection success reset the connection counter
  537. + cCount = 0;
  538. + sLog.outString("MangChat: Connected And Logging In");
  539. + // Login to the IRC server
  540. + if(this->Login(sIRC._Nick, sIRC._User, sIRC._Pass))
  541. + {
  542. + sLog.outString("MangChat: Logged In And Running!!");
  543. + // While we are connected to the irc server keep listening for data on the socket
  544. + while(sIRC.Connected && !World::IsStopped()){ sIRC.SockRecv(); }
  545. + }
  546. + sLog.outString("MangChat: Connection To IRC Server Lost!");
  547. + }
  548. + // When an error occures or connection lost cleanup
  549. + Disconnect();
  550. + // Increase the connection counter
  551. + cCount++;
  552. + // if MAX_CONNECT_ATTEMPT is reached stop trying
  553. + if(sIRC._MCA && cCount == sIRC._MCA)
  554. + sIRC.Active = false;
  555. + // If we need to reattempt a connection wait WAIT_CONNECT_TIME milli seconds before we try again
  556. + if(sIRC.Active)
  557. + ACE_Based::Thread::Sleep(sIRC._wct);
  558. + }
  559. + else
  560. + {
  561. + // Socket could not initialize cancel
  562. + sIRC.Active = false;
  563. + sLog.outError("MangChat: Could not initialize socket");
  564. + }
  565. + }
  566. + // thread stays alive for calls from other threads
  567. +}
  568. diff --git a/src/game/mangchat/IRCClient.h b/src/game/mangchat/IRCClient.h
  569. new file mode 100644
  570. index 0000000..3ca011b
  571. --- /dev/null
  572. +++ b/src/game/mangchat/IRCClient.h
  573. @@ -0,0 +1,233 @@
  574. +/*
  575. + * MangChat for MaNGOS, the open source MMORPG-server
  576. + *
  577. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  578. + * Terms Of The GNU General Public License
  579. + *
  580. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  581. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  582. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  583. + *
  584. + * With Help And Support From The MaNGOS Project Community.
  585. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  586. + */
  587. +
  588. +#ifndef _IRC_CLIENT_H
  589. +#define _IRC_CLIENT_H
  590. +
  591. +#include "Policies/Singleton.h"
  592. +#include "../Player.h"
  593. +#include "IRCLog.h"
  594. +#include "IRCCmd.h"
  595. +
  596. +using namespace std;
  597. +// The maximum ammount of channels used, must be >= config option
  598. +#define MAX_CONF_CHANNELS 10
  599. +#define MAX_CHAT_LINES 10
  600. +
  601. +// let scripts know we have mangchat
  602. +#define MANGCHAT_INSTALLED
  603. +
  604. +// CLINES is used for the default chatlines
  605. +// By using the GetChatLine function its easier and faster
  606. +// to receieve the line you need.
  607. +enum CLINES
  608. +{
  609. + IRC_WOW = 0,
  610. + WOW_IRC = 1,
  611. + JOIN_WOW = 2,
  612. + JOIN_IRC = 3,
  613. + LEAVE_WOW = 4,
  614. + LEAVE_IRC = 5,
  615. + CHANGE_NICK = 6
  616. +};
  617. +
  618. +// CACTION is used by the Handle_WoW_Channel function
  619. +// this function is called in channel.h when a player
  620. +// joins or leave a channel inside the client.
  621. +enum CACTION
  622. +{
  623. + CHANNEL_JOIN,
  624. + CHANNEL_LEAVE,
  625. +};
  626. +
  627. +enum script_Names
  628. +{
  629. + MCS_Players_Online = 0,
  630. +};
  631. +
  632. +// IRCClient main class
  633. +class IRCClient : public ACE_Based::Runnable
  634. +{
  635. + public:
  636. + IRCClient();
  637. + ~IRCClient();
  638. + // ZThread Entry
  639. + void run();
  640. +
  641. + // AH Function
  642. + void AHFunc(uint64 itmid, std::string itmnme, std::string plname, uint32 faction);
  643. +
  644. + //NOTE: Removed "BeenToGMI" due to back overflows caused with new packet structure (Shinzon)
  645. + //bool BeenToGMI(float posx, float posy, std::string player, std::string from);
  646. +
  647. + // IRCClient active
  648. + bool Active;
  649. + // Connected to IRC
  650. + bool Connected;
  651. + // Send data to IRC, in addition the endline is added \n
  652. + bool SendIRC(std::string data);
  653. + // This function is called in ChatHandler.cpp and processes the chat from game to IRC
  654. + void Send_WoW_IRC(Player *plr, std::string Channel, std::string Msg);
  655. + // Sends a message to all players on the specified channel
  656. + void Send_WoW_Channel(const char *channel, std::string chat);
  657. + // Send a system message to all players
  658. + void Send_WoW_System(std::string Message);
  659. + // Send a message to the specified IRC channel
  660. + void Send_IRC_Channel(std::string sChannel, std::string sMsg, bool NoPrefix = false, std::string nType = "PRIVMSG");
  661. + // Sends a message to all IRC Channels
  662. + void Send_IRC_Channels(std::string sMsg);
  663. + std::string MakeMsg(std::string msg, std::string var, std::string val)
  664. + {
  665. + std::size_t start = msg.find(var);
  666. + if (start != std::string::npos)
  667. + msg.replace(start, var.length(), val);
  668. + return msg;
  669. + }
  670. + void Send_WoW_Player(string sPlayer, string sMsg);
  671. + void Send_WoW_Player(Player *plr, string sMsg);
  672. +
  673. + // This function is called in Channel.cpp and processes Join/leave messages
  674. + void Handle_WoW_Channel(std::string Channel, Player *plr, int nAction);
  675. + void ResetIRC();
  676. +
  677. + void AutoJoinChannel(Player *plr);
  678. +
  679. + bool Script_Lock[5];
  680. + bool _AmiOp;
  681. +
  682. + string _Mver;
  683. +
  684. + // BotMask Options
  685. + int Botmask;
  686. + // Status Channel
  687. + int Status;
  688. + // Announce Channel
  689. + int anchn;
  690. + int autoanc;
  691. + // IRC Channel count
  692. + int _chan_count;
  693. + // IRC Channel list
  694. + // Array to store our IRC channels
  695. + // each element will corrospond
  696. + // with _wow_chan array below.
  697. + std::string _irc_chan[MAX_CONF_CHANNELS];
  698. + // Game Channel list
  699. + std::string _wow_chan[MAX_CONF_CHANNELS];
  700. + // AutoJoin Options
  701. + int ajoin;
  702. + string ajchan;
  703. + // Online Command Max Results
  704. + int onlrslt;
  705. + // Channel OnJoin/Restart/Kick Messages
  706. + string JoinMsg;
  707. + string RstMsg;
  708. + string kikmsg;
  709. + // Misc Options
  710. + string ojGM[SEC_CONSOLE];
  711. + string logfile;
  712. + int games;
  713. + int gmlog;
  714. + // IRC Commands Security Level
  715. + int CACCT;
  716. + int CBAN;
  717. + int CCHAN;
  718. + int CCHAR;
  719. + int CFUN;
  720. + int CHELP;
  721. + int CINCHAN;
  722. + int CINFO;
  723. + int CITEM;
  724. + int CJAIL;
  725. + int CKICK;
  726. + int _KILL;
  727. + int CLEVEL;
  728. + int CLOOKUP;
  729. + int CMONEY;
  730. + int CMUTE;
  731. + int CONLINE;
  732. + int CPM;
  733. + int CRESTART;
  734. + int CREVIVE;
  735. + int CSAVEALL;
  736. + int CSHUTDOWN;
  737. + int CSPELL;
  738. + int CSYSMSG;
  739. + int CTELE;
  740. + int CTOP;
  741. + int CWHO;
  742. + // BotMask
  743. + int BOTMASK;
  744. + // Max connect attempt
  745. + int _MCA;
  746. + // Auto rejoin when kicked from irc
  747. + int _autojoinkick;
  748. + // IRC Command prefix
  749. + string _cmd_prefx;
  750. + int _op_gm;
  751. + int _op_gm_lev;
  752. +
  753. + string GetChatLine(int nItem);
  754. +
  755. + int _Max_Script_Inst;
  756. + // MAX_SCRIPT_INST
  757. +
  758. + IRCLog iLog;
  759. +
  760. + // Load MangChat configuration file
  761. + bool LoadConfig();
  762. + void SetCfgFile(char const* cfgfile);
  763. +
  764. + std::string* GetNick() {return &_Nick; }
  765. +
  766. + private:
  767. + // Socket indentifier
  768. + int SOCKET;
  769. + fd_set sfdset;
  770. +
  771. + // Initialize socket library
  772. + bool InitSock();
  773. + // Connect to IRC Server
  774. + bool Connect(const char *cHost, int nPort);
  775. + // Login to IRC Server
  776. + bool Login(std::string sNick, std::string sUser, std::string sPass);
  777. + // Send raw data to IRC
  778. + bool SendData(const char *data);
  779. + // Disconnect from IRC and cleanup socket
  780. + void Disconnect();
  781. + // Processes the data receieved from IRC
  782. + void Handle_IRC(std::string sData);
  783. + // Receieves data from the socket.
  784. + void SockRecv();
  785. + // the mangchat configuration file
  786. + char const* CfgFile;
  787. + // Array that contains our chatlines from the conf file
  788. + string ILINES[MAX_CHAT_LINES];
  789. +
  790. +
  791. + string _Host; // IRC Server host
  792. + int _Port; // IRC Server Port
  793. + string _User; // IRC Username
  794. + string _Pass; // IRC Password
  795. + string _Nick; // IRC Nickname
  796. +
  797. + int _Auth; // Authentication type
  798. + string _Auth_Nick;
  799. + string _ICC; // IRC Connect code
  800. +
  801. + string _defchan; // IRC Default channel
  802. + int _ldefc; // IRC Leave Default channel
  803. + int _wct; // Wait Connect Time
  804. +};
  805. +#endif
  806. +#define sIRC MaNGOS::Singleton<IRCClient>::Instance()
  807. diff --git a/src/game/mangchat/IRCCmd.cpp b/src/game/mangchat/IRCCmd.cpp
  808. new file mode 100644
  809. index 0000000..45cf074
  810. --- /dev/null
  811. +++ b/src/game/mangchat/IRCCmd.cpp
  812. @@ -0,0 +1,941 @@
  813. +/*
  814. + * MangChat for MaNGOS, the open source MMORPG-server
  815. + *
  816. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  817. + * Terms Of The GNU General Public License
  818. + *
  819. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  820. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  821. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  822. + *
  823. + * With Help And Support From The MaNGOS Project Community.
  824. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  825. + */
  826. +
  827. +#include "IRCCmd.h"
  828. +#include "IRCClient.h"
  829. +#include "Database/DatabaseEnv.h"
  830. +#include "../ObjectMgr.h"
  831. +#include "../AccountMgr.h"
  832. +#include "../MapManager.h"
  833. +// Constructor
  834. +IRCCmd::IRCCmd(){}
  835. +// Destructor
  836. +IRCCmd::~IRCCmd(){}
  837. +
  838. +std::string IRCCmd::MakeUpper(std::string Channel)
  839. +{
  840. + std::string tmpchan = Channel;
  841. + std::transform(tmpchan.begin(), tmpchan.end(), tmpchan.begin(), towupper);
  842. +
  843. + return tmpchan;
  844. +}
  845. +
  846. +bool IRCCmd::ParamsValid(_CDATA *CD, int pCnt)
  847. +{
  848. + CD->PCOUNT = pCnt;
  849. +
  850. + if(CD->PARAMS.size() == 0)
  851. + return false;
  852. +
  853. + return ValidParams(CD->PARAMS, pCnt);
  854. +}
  855. +
  856. +int IRCCmd::ParamsValid(_CDATA *CD, int pCnt, int rLev)
  857. +{
  858. + //CD->PCOUNT = pCnt;
  859. + if(!CanUse(CD->USER, rLev))
  860. + return E_AUTH;
  861. + else if(pCnt == 0)
  862. + return E_OK;
  863. + else if(CD->PARAMS.size() == 0)
  864. + return E_SIZE;
  865. + else if(!ValidParams(CD->PARAMS, pCnt))
  866. + return E_SIZE;
  867. +
  868. + return E_OK;
  869. +}
  870. +
  871. +// This function checks if chat from irc is a command or not
  872. +// return true on yes and false on no
  873. +bool IRCCmd::IsValid(std::string USER, std::string FROM, std::string CHAT, std::string TYPE)
  874. +{
  875. + // If the first line of our chat is the command prefix we have a command
  876. + if(CHAT.substr(0, 1) == sIRC._cmd_prefx && CHAT.size() > 1 )
  877. + {
  878. + _CDATA CDATA;
  879. + bool cValid = false;
  880. + bool AuthValid = true;
  881. + bool dontlog = true;
  882. + std::string* _PARAMS = getArray(CHAT, 2);
  883. + CDATA.USER = USER;
  884. + CDATA.FROM = FROM;
  885. + CDATA.TYPE = TYPE;
  886. + CDATA.PCOUNT = 0;
  887. + CDATA.CMD = MakeUpper(_PARAMS[0].substr(1, _PARAMS[0].size() - 1));
  888. + CDATA.PARAMS = _PARAMS[1];
  889. + if(CDATA.CMD == "LOGIN")
  890. + {
  891. + if (FROM == *(sIRC.GetNick()))
  892. + {
  893. + if(ParamsValid(&CDATA, 2))
  894. + Handle_Login(&CDATA);
  895. + else
  896. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "login <Player> <Password> )", true, "ERROR");
  897. + }
  898. + else
  899. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Please Send A PM To Login!", true, "ERROR");
  900. +
  901. + if(GetLevel(USER) >= sIRC.gmlog)
  902. + dontlog = false;
  903. +
  904. + cValid = true;
  905. + }
  906. + else if(CDATA.CMD == "LOGOUT")
  907. + {
  908. + if (FROM == *(sIRC.GetNick()))
  909. + Handle_Logout(&CDATA);
  910. + else
  911. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Please Send A PM To Logout!", true, "ERROR");
  912. +
  913. + cValid = true;
  914. + }
  915. + else if(CDATA.CMD == "ACCT")
  916. + {
  917. + switch(ParamsValid(&CDATA, 2, sIRC.CACCT))
  918. + {
  919. + case E_OK:
  920. + Account_Player(&CDATA);
  921. + break;
  922. + case E_SIZE:
  923. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "acct <Player> <(un)lock/mail/pass/rename> )", true, "ERROR");
  924. + break;
  925. + case E_AUTH:
  926. + AuthValid = false;
  927. + break;
  928. + }
  929. + cValid = true;
  930. + }
  931. + else if(CDATA.CMD == "BAN")
  932. + {
  933. + switch(ParamsValid(&CDATA, 2, sIRC.CBAN))
  934. + {
  935. + case E_OK:
  936. + Ban_Player(&CDATA);
  937. + break;
  938. + case E_SIZE:
  939. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "ban <Player> <acct/ip> )", true, "ERROR");
  940. + break;
  941. + case E_AUTH:
  942. + AuthValid = false;
  943. + break;
  944. + }
  945. + cValid = true;
  946. + }
  947. + else if(CDATA.CMD == "CHAN")
  948. + {
  949. + switch(ParamsValid(&CDATA, 1, sIRC.CCHAN))
  950. + {
  951. + case E_OK:
  952. + Chan_Control(&CDATA);
  953. + break;
  954. + case E_SIZE:
  955. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "chan <op> <IRC User> )", true, "ERROR");
  956. + break;
  957. + case E_AUTH:
  958. + AuthValid = false;
  959. + break;
  960. + }
  961. + cValid = true;
  962. + }
  963. + else if(CDATA.CMD == "CHAR")
  964. + {
  965. + switch(ParamsValid(&CDATA, 2, sIRC.CCHAR))
  966. + {
  967. + case E_OK:
  968. + Char_Player(&CDATA);
  969. + break;
  970. + case E_SIZE:
  971. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "char <Player> <mailcheat/taxicheat/maxskill/setskill> )", true, "ERROR");
  972. + break;
  973. + case E_AUTH:
  974. + AuthValid = false;
  975. + break;
  976. + }
  977. + cValid = true;
  978. + }
  979. + else if(CDATA.CMD == "FUN")
  980. + {
  981. + switch(ParamsValid(&CDATA, 2, sIRC.CFUN))
  982. + {
  983. + case E_OK:
  984. + Fun_Player(&CDATA);
  985. + break;
  986. + case E_SIZE:
  987. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( "+sIRC._cmd_prefx+"fun <Player> <Sound/Say> )", true, "ERROR");
  988. + break;
  989. + case E_AUTH:
  990. + AuthValid = false;
  991. + break;
  992. + }
  993. + cValid = true;
  994. + }
  995. + else if(CDATA.CMD == "HELP")
  996. + {
  997. + switch(ParamsValid(&CDATA, 0, sIRC.CHELP))
  998. + {
  999. + case E_OK:
  1000. + Help_IRC(&CDATA);
  1001. + break;
  1002. + case E_SIZE:
  1003. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( "+sIRC._cmd_prefx+"help <Command> )", true, "ERROR");
  1004. + break;
  1005. + case E_AUTH:
  1006. + AuthValid = false;
  1007. + break;
  1008. + }
  1009. + cValid = true;
  1010. + }
  1011. + else if(CDATA.CMD == "INCHAN")
  1012. + {
  1013. + switch(ParamsValid(&CDATA, 1, sIRC.CINCHAN))
  1014. + {
  1015. + case E_OK:
  1016. + Inchan_Server(&CDATA);
  1017. + break;
  1018. + case E_SIZE:
  1019. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "inchan <Channel> )", true, "ERROR");
  1020. + break;
  1021. + case E_AUTH:
  1022. + AuthValid = false;
  1023. + break;
  1024. + }
  1025. + cValid = true;
  1026. + }
  1027. + else if(CDATA.CMD == "INFO")
  1028. + {
  1029. + switch(ParamsValid(&CDATA, 0, sIRC.CINFO))
  1030. + {
  1031. + case E_OK:
  1032. + Info_Server(&CDATA);
  1033. + break;
  1034. + case E_SIZE:
  1035. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "info )", true, "ERROR");
  1036. + break;
  1037. + case E_AUTH:
  1038. + AuthValid = false;
  1039. + break;
  1040. + }
  1041. + cValid = true;
  1042. + }
  1043. + else if(CDATA.CMD == "ITEM")
  1044. + {
  1045. + CDATA.PCOUNT = 3;
  1046. + switch(ParamsValid(&CDATA, 2, sIRC.CITEM))
  1047. + {
  1048. + case E_OK:
  1049. + Item_Player(&CDATA);
  1050. + break;
  1051. + case E_SIZE:
  1052. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "item <Player> <add> <ItemID/[ItemName]> <Amount> )", true, "ERROR");
  1053. + break;
  1054. + case E_AUTH:
  1055. + AuthValid = false;
  1056. + break;
  1057. + }
  1058. + cValid = true;
  1059. + }
  1060. + else if(CDATA.CMD == "JAIL")
  1061. + {
  1062. + CDATA.PCOUNT = 3;
  1063. + switch(ParamsValid(&CDATA, 1, sIRC.CJAIL))
  1064. + {
  1065. + case E_OK:
  1066. + Jail_Player(&CDATA);
  1067. + break;
  1068. + case E_SIZE:
  1069. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "jail <Player> <release/Reason>)", true, "ERROR");
  1070. + break;
  1071. + case E_AUTH:
  1072. + AuthValid = false;
  1073. + break;
  1074. + }
  1075. + cValid = true;
  1076. + }
  1077. + else if(CDATA.CMD == "KICK")
  1078. + {
  1079. + CDATA.PCOUNT = 2;
  1080. + switch(ParamsValid(&CDATA, 1, sIRC.CKICK))
  1081. + {
  1082. + case E_OK:
  1083. + Kick_Player(&CDATA);
  1084. + break;
  1085. + case E_SIZE:
  1086. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "kick <Player> <Reason> )", true, "ERROR");
  1087. + break;
  1088. + case E_AUTH:
  1089. + AuthValid = false;
  1090. + break;
  1091. + }
  1092. + cValid = true;
  1093. + }
  1094. + else if(CDATA.CMD == "KILL")
  1095. + {
  1096. + CDATA.PCOUNT = 2;
  1097. + switch(ParamsValid(&CDATA, 1, sIRC._KILL))
  1098. + {
  1099. + case E_OK:
  1100. + Kill_Player(&CDATA);
  1101. + break;
  1102. + case E_SIZE:
  1103. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "kill <Player> <Reason> )", true, "ERROR");
  1104. + break;
  1105. + case E_AUTH:
  1106. + AuthValid = false;
  1107. + break;
  1108. + }
  1109. + cValid = true;
  1110. + }
  1111. + else if(CDATA.CMD == "LEVEL")
  1112. + {
  1113. + CDATA.PCOUNT = 2;
  1114. + switch(ParamsValid(&CDATA, 2, sIRC.CLEVEL))
  1115. + {
  1116. + case E_OK:
  1117. + Level_Player(&CDATA);
  1118. + break;
  1119. + case E_SIZE:
  1120. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "level <Player> <NewLevel> )", true, "ERROR");
  1121. + break;
  1122. + case E_AUTH:
  1123. + AuthValid = false;
  1124. + break;
  1125. + }
  1126. + cValid = true;
  1127. + }
  1128. + else if(CDATA.CMD == "LOOKUP")
  1129. + {
  1130. + CDATA.PCOUNT = 2;
  1131. + switch(ParamsValid(&CDATA, 2, sIRC.CLOOKUP))
  1132. + {
  1133. + case E_OK:
  1134. + Lookup_Player(&CDATA);
  1135. + break;
  1136. + case E_SIZE:
  1137. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "lookup <acct/char/creature/faction/go/item/quest/skill/spell/tele> <ID/Name> )", true, "ERROR");
  1138. + break;
  1139. + case E_AUTH:
  1140. + AuthValid = false;
  1141. + break;
  1142. + }
  1143. + cValid = true;
  1144. + }
  1145. + else if(CDATA.CMD == "MONEY")
  1146. + {
  1147. + CDATA.PCOUNT = 2;
  1148. + switch(ParamsValid(&CDATA, 2, sIRC.CMONEY))
  1149. + {
  1150. + case E_OK:
  1151. + Money_Player(&CDATA);
  1152. + break;
  1153. + case E_SIZE:
  1154. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "money <Player> <(-)Money> )", true, "ERROR");
  1155. + break;
  1156. + case E_AUTH:
  1157. + AuthValid = false;
  1158. + break;
  1159. + }
  1160. + cValid = true;
  1161. + }
  1162. + else if(CDATA.CMD == "MUTE")
  1163. + {
  1164. + switch(ParamsValid(&CDATA, 2, sIRC.CMUTE))
  1165. + {
  1166. + case E_OK:
  1167. + Mute_Player(&CDATA);
  1168. + break;
  1169. + case E_SIZE:
  1170. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "mute <Player> <release/TimeInMins> <Reason> )", true, "ERROR");
  1171. + break;
  1172. + case E_AUTH:
  1173. + AuthValid = false;
  1174. + break;
  1175. + }
  1176. + cValid = true;
  1177. + }
  1178. + else if(CDATA.CMD == "ONLINE")
  1179. + {
  1180. + switch(ParamsValid(&CDATA, 0, sIRC.CONLINE))
  1181. + {
  1182. + case E_OK:
  1183. + Online_Players(&CDATA);
  1184. + break;
  1185. + case E_SIZE:
  1186. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "online )", true, "ERROR");
  1187. + break;
  1188. + case E_AUTH:
  1189. + AuthValid = false;
  1190. + break;
  1191. + }
  1192. + cValid = true;
  1193. + }
  1194. + else if(CDATA.CMD == "PM")
  1195. + {
  1196. + switch(ParamsValid(&CDATA, 2, sIRC.CPM))
  1197. + {
  1198. + case E_OK:
  1199. + PM_Player(&CDATA);
  1200. + break;
  1201. + case E_SIZE:
  1202. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "pm <Player> <Message> )", true, "ERROR");
  1203. + break;
  1204. + case E_AUTH:
  1205. + AuthValid = false;
  1206. + break;
  1207. + }
  1208. + cValid = true;
  1209. + }
  1210. + else if(CDATA.CMD == "RELOAD")
  1211. + {
  1212. + switch(ParamsValid(&CDATA, 0, sIRC.CRESTART))
  1213. + {
  1214. + case E_OK:
  1215. + sIRC.Send_IRC_Channels("Reloading MangChat Config Options. (Restart recommended)");
  1216. + sIRC.LoadConfig();
  1217. + break;
  1218. + case E_AUTH:
  1219. + AuthValid = false;
  1220. + break;
  1221. + }
  1222. + cValid = true;
  1223. + }
  1224. + else if(CDATA.CMD == "RESTART")
  1225. + {
  1226. + switch(ParamsValid(&CDATA, 0, sIRC.CRESTART))
  1227. + {
  1228. + case E_OK:
  1229. + sIRC.Send_IRC_Channels(sIRC.RstMsg);
  1230. + sIRC.ResetIRC();
  1231. + break;
  1232. + case E_AUTH:
  1233. + AuthValid = false;
  1234. + break;
  1235. + }
  1236. + cValid = true;
  1237. + }
  1238. + else if(CDATA.CMD == "REVIVE")
  1239. + {
  1240. + CDATA.PCOUNT = 2;
  1241. + switch(ParamsValid(&CDATA, 1, sIRC.CREVIVE))
  1242. + {
  1243. + case E_OK:
  1244. + Revive_Player(&CDATA);
  1245. + break;
  1246. + case E_SIZE:
  1247. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "revive <Player> )", true, "ERROR");
  1248. + break;
  1249. + case E_AUTH:
  1250. + AuthValid = false;
  1251. + break;
  1252. + }
  1253. + cValid = true;
  1254. + }
  1255. + else if(CDATA.CMD == "SAVEALL")
  1256. + {
  1257. + switch(ParamsValid(&CDATA, 0, sIRC.CSAVEALL))
  1258. + {
  1259. + case E_OK:
  1260. + Saveall_Player(&CDATA);
  1261. + break;
  1262. + case E_AUTH:
  1263. + AuthValid = false;
  1264. + break;
  1265. + }
  1266. + cValid = true;
  1267. + }
  1268. + else if(CDATA.CMD == "SHUTDOWN")
  1269. + {
  1270. + switch(ParamsValid(&CDATA, 1, sIRC.CSHUTDOWN))
  1271. + {
  1272. + case E_OK:
  1273. + Shutdown_Mangos(&CDATA);
  1274. + break;
  1275. + case E_SIZE:
  1276. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "shutdown <TimeInSeconds/cancel> )", true, "ERROR");
  1277. + break;
  1278. + case E_AUTH:
  1279. + AuthValid = false;
  1280. + break;
  1281. + }
  1282. + cValid = true;
  1283. + }
  1284. + else if(CDATA.CMD == "SPELL")
  1285. + {
  1286. + switch(ParamsValid(&CDATA, 2, sIRC.CSPELL))
  1287. + {
  1288. + case E_OK:
  1289. + Spell_Player(&CDATA);
  1290. + break;
  1291. + case E_SIZE:
  1292. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "spell <Player> <Cast/Learn/UnLearn> <SpellID> )", true, "ERROR");
  1293. + break;
  1294. + case E_AUTH:
  1295. + AuthValid = false;
  1296. + break;
  1297. + }
  1298. + cValid = true;
  1299. + }
  1300. + else if(CDATA.CMD == "SYSMSG")
  1301. + {
  1302. + CDATA.PCOUNT = 2;
  1303. + switch(ParamsValid(&CDATA, 2, sIRC.CSYSMSG))
  1304. + {
  1305. + case E_OK:
  1306. + Sysmsg_Server(&CDATA);
  1307. + break;
  1308. + case E_SIZE:
  1309. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "sysmsg <a/e/n/add/del/list> <Message> )", true, "ERROR");
  1310. + break;
  1311. + case E_AUTH:
  1312. + AuthValid = false;
  1313. + break;
  1314. + }
  1315. + cValid = true;
  1316. + }
  1317. + else if(CDATA.CMD == "TELE")
  1318. + {
  1319. + switch(ParamsValid(&CDATA, 2, sIRC.CTELE))
  1320. + {
  1321. + case E_OK:
  1322. + Tele_Player(&CDATA);
  1323. + break;
  1324. + case E_SIZE:
  1325. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "tele <Player> <l/c/r/to> <Loc.Name/MAPID X Y Z/Recall/Player> )", true, "ERROR");
  1326. + break;
  1327. + case E_AUTH:
  1328. + AuthValid = false;
  1329. + break;
  1330. + }
  1331. + cValid = true;
  1332. + }
  1333. + else if(CDATA.CMD == "TOP")
  1334. + {
  1335. + CDATA.PCOUNT = 1;
  1336. + switch(ParamsValid(&CDATA, 1, sIRC.CTOP))
  1337. + {
  1338. + case E_OK:
  1339. + Top_Player(&CDATA);
  1340. + break;
  1341. + case E_SIZE:
  1342. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "top <accttime/chartime/money> <limit> )", true, "ERROR");
  1343. + break;
  1344. + case E_AUTH:
  1345. + AuthValid = false;
  1346. + break;
  1347. + }
  1348. + cValid = true;
  1349. + }
  1350. + else if(CDATA.CMD == "WHO")
  1351. + {
  1352. + switch(ParamsValid(&CDATA, 0, sIRC.CWHO))
  1353. + {
  1354. + case E_OK:
  1355. + Who_Logged(&CDATA);
  1356. + break;
  1357. + case E_AUTH:
  1358. + AuthValid = false;
  1359. + break;
  1360. + }
  1361. + cValid = true;
  1362. + }
  1363. + else if(CDATA.CMD == "TICKET") // GM Ticket by bizkut http://github.com/bizkut
  1364. + {
  1365. + CDATA.PCOUNT = 1;
  1366. + switch(ParamsValid(&CDATA, 1, sIRC.CTOP))
  1367. + {
  1368. + case E_OK:
  1369. + GM_Ticket(&CDATA);
  1370. + break;
  1371. + case E_SIZE:
  1372. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Syntax Error! ( " + sIRC._cmd_prefx + "ticket <list/read/respond/delete> <limit/name/all> <message> )", true, "ERROR");
  1373. + break;
  1374. + case E_AUTH:
  1375. + AuthValid = false;
  1376. + break;
  1377. + }
  1378. + cValid = true;
  1379. + }
  1380. +
  1381. + if(!AuthValid && IsLoggedIn(USER))
  1382. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Access Denied! Your Security Level Is Too Low To Use This Command!", true, "ERROR");
  1383. +
  1384. + if (cValid == false && (sIRC.BOTMASK & 4))
  1385. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : Unknown Command!", true, "ERROR");
  1386. +
  1387. + if (cValid && dontlog)
  1388. + sIRC.iLog.WriteLog(" %s : [ %s(%d) ] Used Command: [ %s ] With Parameters: [ %s ]", sIRC.iLog.GetLogDateTimeStr().c_str(), CDATA.USER.c_str(), GetLevel(USER), CDATA.CMD.c_str(), CDATA.PARAMS.c_str());
  1389. +
  1390. + return cValid;
  1391. + }
  1392. + return false;
  1393. +}
  1394. +
  1395. +bool IRCCmd::CanUse(std::string USER, int nLevel)
  1396. +{
  1397. + if(IsLoggedIn(USER))
  1398. + {
  1399. + if(GetLevel(USER) >= nLevel)
  1400. + return true;
  1401. + else
  1402. + return false;
  1403. + }
  1404. + else if(nLevel == 0)
  1405. + {
  1406. + return true;
  1407. + }
  1408. + else
  1409. + sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : You Are Not Logged In!", true, "ERROR");
  1410. +
  1411. + return false;
  1412. +}
  1413. +
  1414. +std::string IRCCmd::ChanOrPM(_CDATA *CD)
  1415. +{
  1416. + if (CD->FROM == *(sIRC.GetNick()))
  1417. + return CD->USER;
  1418. + else
  1419. + return CD->FROM;
  1420. +}
  1421. +
  1422. +Player *IRCCmd::GetPlayer(std::string WHO)
  1423. +{
  1424. + normalizePlayerName(WHO);
  1425. +
  1426. + return ObjectAccessor::Instance().FindPlayerByName(WHO.c_str());
  1427. +}
  1428. +
  1429. +_client *IRCCmd::GetClient(std::string cname)
  1430. +{
  1431. + for(std::list<_client*>::iterator i = _CLIENTS.begin(); i != _CLIENTS.end(); i++)
  1432. + {
  1433. + if((*i)->Name == cname)
  1434. + return (*i);
  1435. + }
  1436. +
  1437. + return (NULL);
  1438. +}
  1439. +
  1440. +bool IRCCmd::IsLoggedIn(std::string USER)
  1441. +{
  1442. + for(std::list<_client*>::iterator i = _CLIENTS.begin(); i != _CLIENTS.end(); i++)
  1443. + {
  1444. + if((*i)->Name == USER)
  1445. + return true;
  1446. + }
  1447. +
  1448. + return false;
  1449. +}
  1450. +
  1451. +bool IRCCmd::AcctIsLoggedIn(std::string USER)
  1452. +{
  1453. + for(std::list<_client*>::iterator i = _CLIENTS.begin(); i != _CLIENTS.end(); i++)
  1454. + {
  1455. + if(MakeUpper((*i)->UName) == MakeUpper(USER))
  1456. + return true;
  1457. + }
  1458. +
  1459. + return false;
  1460. +}
  1461. +
  1462. +std::string IRCCmd::AcctIsBanned(std::string ACCT)
  1463. +{
  1464. + uint32 acctid = sAccountMgr.GetId(ACCT);
  1465. + std::string banned = "NOTBANNED";
  1466. + QueryResult *result = LoginDatabase.PQuery("SELECT banreason FROM ip_banned WHERE ip=(SELECT last_ip FROM account WHERE id = '%i')", acctid);
  1467. +
  1468. + if(result)
  1469. + {
  1470. + banned = (*result)[0].GetCppString();
  1471. + delete result;
  1472. + return "IP Banned. Reason:" + banned;
  1473. + }
  1474. +
  1475. + QueryResult *result2 = LoginDatabase.PQuery("SELECT banreason FROM account_banned WHERE id='%i'", acctid);
  1476. +
  1477. + if(result2)
  1478. + {
  1479. + banned = (*result2)[0].GetCppString();
  1480. + delete result2;
  1481. + return "Account Banned. Reason:" + banned;
  1482. + }
  1483. +
  1484. + return banned;
  1485. +}
  1486. +
  1487. +int IRCCmd::GetLevel(std::string sName)
  1488. +{
  1489. + for(std::list<_client*>::iterator i = _CLIENTS.begin(); i != _CLIENTS.end(); i++)
  1490. + {
  1491. + if((*i)->Name == sName)
  1492. + return (*i)->GMLevel;
  1493. + }
  1494. +
  1495. + return 0;
  1496. +}
  1497. +
  1498. +int IRCCmd::AcctLevel(std::string plnme)
  1499. +{
  1500. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(plnme);
  1501. + uint32 account_id = 0;
  1502. + uint32 security = 0;
  1503. + account_id = sObjectMgr.GetPlayerAccountIdByGUID(guid);
  1504. + security = sAccountMgr.GetSecurity(account_id);
  1505. +
  1506. + return security;
  1507. +}
  1508. +
  1509. +std::string IRCCmd::GetAccName(std::string sName)
  1510. +{
  1511. + for(std::list<_client*>::iterator i = _CLIENTS.begin(); i != _CLIENTS.end(); i++)
  1512. + {
  1513. + if((*i)->Name == sName)
  1514. + return (*i)->UName;
  1515. + }
  1516. +
  1517. + return "";
  1518. +}
  1519. +
  1520. +std::string IRCCmd::GetNameFromAcct(std::string sName)
  1521. +{
  1522. + for(std::list<_client*>::iterator i = _CLIENTS.begin(); i != _CLIENTS.end(); i++)
  1523. + {
  1524. + if((*i)->UName == sName)
  1525. + return (*i)->Name;
  1526. + }
  1527. +
  1528. + return "";
  1529. +}
  1530. +
  1531. +int IRCCmd::GetAcctIDFromName(std::string sName)
  1532. +{
  1533. + for(std::list<_client*>::iterator i = _CLIENTS.begin(); i != _CLIENTS.end(); i++)
  1534. + {
  1535. + if((*i)->Name == sName)
  1536. + {
  1537. + uint32 acct_id = 0;
  1538. + acct_id = sAccountMgr.GetId((*i)->UName.c_str());
  1539. + return acct_id;
  1540. + }
  1541. + }
  1542. +
  1543. + return 0;
  1544. +}
  1545. +
  1546. +std::string IRCCmd::GetAcctNameFromID(uint32 acctid)
  1547. +{
  1548. + QueryResult *result = LoginDatabase.PQuery("SELECT username FROM account WHERE id = '%d'", acctid);
  1549. +
  1550. + if(result)
  1551. + {
  1552. + std::string name = (*result)[0].GetCppString();
  1553. + delete result;
  1554. + return name;
  1555. + }
  1556. +
  1557. + return "";
  1558. +}
  1559. +
  1560. +std::string IRCCmd::GetCharNameFromGUID(ObjectGuid guid)
  1561. +{
  1562. + QueryResult *result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = '%d'", guid.GetCounter());
  1563. + if (result)
  1564. + {
  1565. + std::string name = (*result)[0].GetCppString();
  1566. + delete result;
  1567. + return name;
  1568. + }
  1569. +
  1570. + return "";
  1571. +}
  1572. +
  1573. +std::string IRCCmd::GetIPFromPlayer(std::string player)
  1574. +{
  1575. + QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", player.c_str());
  1576. + if(result)
  1577. + {
  1578. + std::string acctid = (*result)[0].GetCppString();
  1579. + delete result;
  1580. + QueryResult *result2 = LoginDatabase.PQuery("SELECT last_ip FROM account WHERE id = '%s'", acctid.c_str());
  1581. +
  1582. + if(result2)
  1583. + {
  1584. + std::string ip = (*result2)[0].GetCppString();
  1585. + delete result2;
  1586. + return ip;
  1587. + }
  1588. + }
  1589. +
  1590. + return "";
  1591. +}
  1592. +
  1593. +std::string IRCCmd::SecToDay(std::string secons)
  1594. +{
  1595. + unsigned int seconds = atoi(secons.c_str());
  1596. + unsigned int days = seconds / 86400;
  1597. + unsigned int hours = seconds / 3600 % 24;
  1598. + unsigned int mins = seconds / 60 % 60;
  1599. + char tottime[1000];
  1600. + sprintf(tottime, "%iDays:%iHours:%iMinutes", days, hours, mins);
  1601. +
  1602. + return tottime;
  1603. +}
  1604. +
  1605. +bool IRCCmd::ValidParams(std::string PARAMS, int nCount)
  1606. +{
  1607. + if(nCount == 1 && PARAMS.size() == 0)
  1608. + return false;
  1609. +
  1610. + int pcount = 0;
  1611. + size_t p = -1;
  1612. +
  1613. + for(int i = 0; i < nCount; i++)
  1614. + {
  1615. + p = PARAMS.find(" ", p + 1);
  1616. +
  1617. + if(p == -1)
  1618. + break;
  1619. + else
  1620. + pcount++;
  1621. + }
  1622. + nCount--;
  1623. +
  1624. + if(pcount >= nCount)
  1625. + return true;
  1626. + else
  1627. + return false;
  1628. +}
  1629. +
  1630. +std::string* IRCCmd::getArray(std::string PARAMS, int nCount)
  1631. +{
  1632. + std::string *array = new std::string[nCount];
  1633. +
  1634. + if(PARAMS.size() > 0)
  1635. + {
  1636. + int pcnt = 0;
  1637. + size_t ps = 0;
  1638. + size_t pc = -1;
  1639. + for(int i = 0; i < nCount; i++)
  1640. + {
  1641. + pc = PARAMS.find(" ", pc + 1);
  1642. + if(i + 1 == nCount && nCount != 1)
  1643. + {
  1644. + if(ps > 0 && pc > 0)
  1645. + array[i] = PARAMS.substr(ps, PARAMS.size() - ps);
  1646. + }
  1647. + else
  1648. + array[i] = PARAMS.substr(ps, pc - ps);
  1649. + ps = pc + 1;
  1650. + }
  1651. + }
  1652. +
  1653. + return array;
  1654. +}
  1655. +
  1656. +std::string IRCCmd::MakeMsg(const char *sLine, ... )
  1657. +{
  1658. + va_list ap;
  1659. + char tmpoutp[1024];
  1660. + va_start(ap, sLine);
  1661. + vsnprintf(tmpoutp, 1024, sLine, ap );
  1662. + va_end(ap);
  1663. + std::string outp = tmpoutp;
  1664. +
  1665. + return outp;
  1666. +}
  1667. +
  1668. +void IRCClient::AHFunc(uint64 itmid, std::string itmnme, std::string plname, uint32 faction)
  1669. +{
  1670. + IRCCmd Command;
  1671. + Player* plr = Command.GetPlayer(plname);
  1672. +
  1673. + if(plr)
  1674. + {
  1675. + std::string itemname = itmnme;
  1676. +
  1677. + char temp [7];
  1678. + sprintf(temp, "%u", itmid);
  1679. + std::string itemid = temp;
  1680. +
  1681. + std::string wowname = "";
  1682. + std::string ircname = "";
  1683. + switch (plr->GetTeam())
  1684. + {
  1685. + case 67: //horde
  1686. + wowname = "|cffff0000" + plname + "|r";
  1687. + ircname = "\0034" + plname;
  1688. + break;
  1689. + case 469: //alliance
  1690. + wowname = "|cff1589FF" + plname + "|r";
  1691. + ircname = "\00312" + plname;
  1692. + break;
  1693. + }
  1694. +
  1695. + std::string wowfact = "|cffFF8040[Auction House]:|r";
  1696. + std::string ircfact = "\00304,08\037/!\\\037\017\00307 Auction House \00304,08\037/!\\\037\017";
  1697. +
  1698. + switch(faction)
  1699. + {
  1700. + case 7: //neutral
  1701. + wowfact = "|cffff8040[Neutral Auction House]:|r";
  1702. + ircfact = "\00304,08\037/!\\\037\017\00307 Neutral Auction House \00304,08\037/!\\\037\017";
  1703. + break;
  1704. + case 6: //horde
  1705. + wowfact = "|cffff0000[Horde Auction House]:|r";
  1706. + ircfact = "\00304,08\037/!\\\037\017\00304 Horde Auction House \00304,08\037/!\\\037\017";
  1707. + break;
  1708. + case 2: //alliance
  1709. + wowfact = "|cff1589FF[Alliance Auction House]:|r";
  1710. + ircfact = "\00304,08\037/!\\\037\017\00312 Alliance Auction House \00304,08\037/!\\\037\017";
  1711. + break;
  1712. + }
  1713. +
  1714. + std::string wowstr = Command.MakeMsg("%s A New Item Has Been Added |cffffffff|Hitem:%s:0:0:0:0:0:0:0|h[%s]|h|r. By: %s", wowfact.c_str(), itemid.c_str(), itemname.c_str(), wowname.c_str());
  1715. + std::string ircstr = Command.MakeMsg("%s A New Item Has Been Added [%s]. By: %s", ircfact.c_str(), itemname.c_str(), ircname.c_str());
  1716. +
  1717. + sIRC.Send_WoW_Channel(sIRC._wow_chan[sIRC.Status].c_str(), wowstr.c_str());
  1718. + sIRC.Send_IRC_Channel(sIRC._irc_chan[sIRC.Status].c_str(), ircstr.c_str());
  1719. + }
  1720. +}
  1721. +
  1722. +//NOTE: Removed "BeenToGMI" due to back overflows caused with new packet structure (Shinzon)
  1723. +
  1724. +//bool IRCClient::BeenToGMI(float posx, float posy, float posz, std::string player, std::string from)
  1725. +//{
  1726. +// IRCCmd Command;
  1727. +// std::transform(location.begin(), location.end(), location.begin(), towupper);
  1728. +// sObjectMgr.GetAreaId
  1729. +// if(location == "GMI" || location == "GMISLAND")
  1730. +// if(MapManager::Instance().GetZoneId(1,posx,posy,posz) == 876)
  1731. +// {
  1732. +// QueryResult *result = WorldDatabase.PQuery("SELECT name FROM Hell_GMI WHERE name = '%s'",player.c_str());
  1733. +// if(result)
  1734. +// {
  1735. +// delete result;
  1736. +// uint64 guid = sObjectMgr.GetPlayerGUIDByName(player);
  1737. +// Player* plr = sObjectMgr.GetPlayer(guid);
  1738. +// uint64 guid2 = sObjectMgr.GetPlayerGUIDByName(from);
  1739. +// Player* plr2 = sObjectMgr.GetPlayer(guid2);
  1740. +// if(plr) sIRC.Send_WoW_Player(plr, "You Have Already Had A Trip To GM Island. There Is Only One Tele To GM Island Per Player, Please Donate If You Would like The .tele Command.");
  1741. +// if(plr2) sIRC.Send_WoW_Player(plr2, "This Player Has Already Had Their Trip To GM Island. The Tele Has Been Canceled.");
  1742. +// else sIRC.Send_IRC_Channel(from.c_str(), MakeMsg(" \0034[ERROR] : $Player Has Already Had Their Trip To GMI! The Tele Has Been Canceled", "$Player", player.c_str()), true, "ERROR");
  1743. +// return true;
  1744. +// }
  1745. +// else
  1746. +// {
  1747. +// if(Command.AcctLevel(player) == 0)
  1748. +// WorldDatabase.PExecute("INSERT INTO `Hell_GMI` VALUES ('%s')", player.c_str());
  1749. +// return false;
  1750. +// }
  1751. +// }
  1752. +// return false;
  1753. +//}
  1754. diff --git a/src/game/mangchat/IRCCmd.h b/src/game/mangchat/IRCCmd.h
  1755. new file mode 100644
  1756. index 0000000..39f8d97
  1757. --- /dev/null
  1758. +++ b/src/game/mangchat/IRCCmd.h
  1759. @@ -0,0 +1,137 @@
  1760. +/*
  1761. + * MangChat for MaNGOS, the open source MMORPG-server
  1762. + *
  1763. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  1764. + * Terms Of The GNU General Public License
  1765. + *
  1766. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  1767. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  1768. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  1769. + *
  1770. + * With Help And Support From The MaNGOS Project Community.
  1771. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  1772. + */
  1773. +
  1774. +#ifndef _IRC_CMD_H
  1775. +#define _IRC_CMD_H
  1776. +
  1777. +#define MAX_CLIENTS 50
  1778. +#include "Common.h"
  1779. +#include "../Player.h"
  1780. +#include "../ObjectAccessor.h"
  1781. +
  1782. +struct ChannelUser
  1783. +{
  1784. + int UserType;
  1785. + std::string Name;
  1786. + std::string UName;
  1787. + int UserLevel;
  1788. +};
  1789. +
  1790. +struct _client
  1791. +{
  1792. + bool LoggedIn;
  1793. + std::string Name;
  1794. + std::string UName;
  1795. + int GMLevel;
  1796. +};
  1797. +
  1798. +struct _CDATA
  1799. +{
  1800. + std::string CMD;
  1801. + std::string USER;
  1802. + std::string FROM;
  1803. + std::string PARAMS;
  1804. + std::string TYPE;
  1805. + int PCOUNT;
  1806. +};
  1807. +
  1808. +enum APVERR
  1809. +{
  1810. + E_OK,
  1811. + E_SIZE,
  1812. + E_AUTH,
  1813. + E_IVALID,
  1814. +};
  1815. +
  1816. +enum ESOUNDS
  1817. +{
  1818. + S_ENTERWORLD = 602,
  1819. + S_QUESTFAILED = 847,
  1820. + S_INVITE = 880,
  1821. + S_LEVELUP = 888,
  1822. + S_COINSOUND = 895,
  1823. + S_WHISPER = 3081,
  1824. + S_STEALTH = 3325,
  1825. +};
  1826. +
  1827. +class IRCCmd
  1828. +{
  1829. + public:
  1830. + IRCCmd();
  1831. + ~IRCCmd();
  1832. +
  1833. + void Handle_Logout(_CDATA *CD);
  1834. + bool IsLoggedIn(std::string USER);
  1835. + bool IsValid(std::string USER, std::string FROM, std::string CHAT, std::string TYPE);
  1836. + bool AcctIsLoggedIn(std::string USER);
  1837. + _client *GetClient(std::string cname);
  1838. +
  1839. + static std::string MakeMsg(const char *sLine, ... );
  1840. + static std::string ChanOrPM(_CDATA *CD);
  1841. + int AcctLevel(std::string plnme);
  1842. + int GetLevel(std::string sName);
  1843. + std::string MakeUpper(std::string Channel);
  1844. + std::string AcctIsBanned(std::string ACCT);
  1845. + std::list<_client*> _CLIENTS;
  1846. + Player* GetPlayer(std::string WHO);
  1847. +
  1848. + private:
  1849. + // MangChat Commands
  1850. + void Handle_Login(_CDATA *CD);
  1851. + void Account_Player(_CDATA *CD);
  1852. + void Ban_Player(_CDATA *CD);
  1853. + void Chan_Control(_CDATA *CD);
  1854. + void Char_Player(_CDATA *CD);
  1855. + void Fun_Player(_CDATA *CD);
  1856. + void Help_IRC(_CDATA *CD);
  1857. + void Item_Player(_CDATA *CD);
  1858. + void Inchan_Server(_CDATA *CD);
  1859. + void Info_Server(_CDATA *CD);
  1860. + void Jail_Player(_CDATA *CD);
  1861. + void Kick_Player(_CDATA *CD);
  1862. + void Kill_Player(_CDATA *CD);
  1863. + void Level_Player(_CDATA *CD);
  1864. + void Lookup_Player(_CDATA *CD);
  1865. + void Money_Player(_CDATA *CD);
  1866. + void Mute_Player(_CDATA *CD);
  1867. + void Online_Players(_CDATA *CD);
  1868. + void PM_Player(_CDATA *CD);
  1869. + void Revive_Player(_CDATA *CD);
  1870. + void Saveall_Player(_CDATA *CD);
  1871. + void Shutdown_Mangos(_CDATA *CD);
  1872. + void Spell_Player(_CDATA *CD);
  1873. + void Sysmsg_Server(_CDATA *CD);
  1874. + void Tele_Player(_CDATA *CD);
  1875. + void Top_Player(_CDATA *CD);
  1876. + void Who_Logged(_CDATA *CD);
  1877. + void GM_Ticket(_CDATA *CD);
  1878. + bool CanUse(std::string USER, int nLevel);
  1879. + bool ValidParams(std::string PARAMS, int nCount = 1);
  1880. + bool ParamsValid(_CDATA *CD, int pCnt);
  1881. + int ParamsValid(_CDATA *CD, int pCnt, int rLev);
  1882. + std::string GetAccName(std::string sName);
  1883. + std::string GetNameFromAcct(std::string sName);
  1884. + std::string GetAcctNameFromID(uint32 acctid);
  1885. + std::string GetCharNameFromGUID(ObjectGuid guid);
  1886. + std::string GetIPFromPlayer(std::string player);
  1887. + std::string SecToDay(std::string secons);
  1888. + int GetAcctIDFromName(std::string sName);
  1889. + std::string* getArray(std::string PARAMS, int nCount = 1);
  1890. +};
  1891. +
  1892. +inline void MakeLower(std::string& str)
  1893. +{
  1894. + std::transform( str.begin(), str.end(), str.begin(), ::tolower );
  1895. +}
  1896. +#endif
  1897. diff --git a/src/game/mangchat/IRCCmde.cpp b/src/game/mangchat/IRCCmde.cpp
  1898. new file mode 100644
  1899. index 0000000..8e0567d
  1900. --- /dev/null
  1901. +++ b/src/game/mangchat/IRCCmde.cpp
  1902. @@ -0,0 +1,2059 @@
  1903. +/*
  1904. + * MangChat for MaNGOS, the open source MMORPG-server
  1905. + *
  1906. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  1907. + * Terms Of The GNU General Public License
  1908. + *
  1909. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  1910. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  1911. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  1912. + *
  1913. + * With Help And Support From The MaNGOS Project Community.
  1914. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  1915. + */
  1916. +
  1917. +#include "IRCCmd.h"
  1918. +#include "IRCClient.h"
  1919. +#include "MCS_OnlinePlayers.h"
  1920. +#include "WorldPacket.h"
  1921. +#include "Database/DatabaseEnv.h"
  1922. +#include "../Chat.h"
  1923. +#include "../MapManager.h"
  1924. +#include "../World.h"
  1925. +#include "../Guild.h"
  1926. +#include "../GuildMgr.h"
  1927. +#include "../ObjectMgr.h"
  1928. +#include "../AccountMgr.h"
  1929. +#include "../Language.h"
  1930. +#include "../SpellAuras.h"
  1931. +#include "SystemConfig.h"
  1932. +#include "revision_nr.h"
  1933. +#include "../../shared/Config/Config.h"
  1934. +#include "../GMTicketMgr.h"
  1935. +
  1936. +#define Send_Player(p, m) sIRC.Send_WoW_Player(p, m)
  1937. +#define Send_IRCA(c, m, b, t) sIRC.Send_IRC_Channel(c, m, b, t)
  1938. +
  1939. +#ifdef WIN32
  1940. + #define Delay(x) Sleep(x)
  1941. +#else
  1942. + #define Delay(x) sleep(x / 1000)
  1943. +#endif
  1944. +
  1945. +void IRCCmd::Handle_Login(_CDATA *CD)
  1946. +{
  1947. + std::string* _PARAMS = getArray(CD->PARAMS, 2);
  1948. + std::string isbanned = AcctIsBanned(_PARAMS[0]);
  1949. + if (isbanned == "NOTBANNED")
  1950. + {
  1951. + if (!IsLoggedIn(CD->USER))
  1952. + {
  1953. + if (!AcctIsLoggedIn(_PARAMS[0].c_str()))
  1954. + {
  1955. + QueryResult *result = LoginDatabase.PQuery("SELECT `gmlevel` FROM `account` WHERE `username`='%s' AND `sha_pass_hash`=SHA1(CONCAT(UPPER(`username`),':',UPPER('%s')));", _PARAMS[0].c_str(), _PARAMS[1].c_str());
  1956. + if (result)
  1957. + {
  1958. + Field *fields = result->Fetch();
  1959. + int GMLevel = fields[0].GetInt16();
  1960. + if (GMLevel >= 0)
  1961. + {
  1962. + _client *NewClient = new _client();
  1963. + NewClient->Name = CD->USER;
  1964. + NewClient->UName = MakeUpper(_PARAMS[0]);
  1965. + NewClient->GMLevel = fields[0].GetInt16();
  1966. + _CLIENTS.push_back(NewClient);
  1967. + Send_IRCA(CD->USER, MakeMsg("You Are Now Logged In As %s, Welcome To MangChat Admin Mode.", _PARAMS[0].c_str()), true, CD->TYPE);
  1968. +
  1969. + if (sIRC._op_gm == 1 && GMLevel >= sIRC._op_gm_lev)
  1970. + {
  1971. + for (int i=1;i < sIRC._chan_count + 1;i++)
  1972. + sIRC.SendIRC("MODE #"+sIRC._irc_chan[i]+" +o "+CD->USER );
  1973. + }
  1974. + }
  1975. + } else
  1976. + Send_IRCA(CD->USER, "\0034[ERROR] : Sorry, Your Username Or Password Is Incorrect. Please Try Again. ", true, "ERROR");
  1977. + } else
  1978. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : %s Is Already Logged In With This Username. ", GetNameFromAcct(MakeUpper(_PARAMS[0])).c_str()), true, "ERROR");
  1979. + } else
  1980. + Send_IRCA(CD->USER, "\0034[ERROR] : You Are Already Logged In As "+ _PARAMS[0] +"!", true, "ERROR");
  1981. + } else
  1982. + Send_IRCA(CD->USER, "\0034[ERROR] : Sorry You Are "+isbanned+". You Cannot Log In To MangChat "+CD->USER.c_str()+"!", true, "ERROR");
  1983. +}
  1984. +
  1985. +void IRCCmd::Handle_Logout(_CDATA *CD)
  1986. +{
  1987. + for (std::list<_client*>::iterator i=_CLIENTS.begin(); i!=_CLIENTS.end();i++)
  1988. + {
  1989. + if ((*i)->Name == CD->USER)
  1990. + {
  1991. + _CLIENTS.erase(i);
  1992. + delete (*i);
  1993. + Send_IRCA(CD->USER, "You Are Now Logged Out!", true, CD->TYPE);
  1994. + return;
  1995. + }
  1996. + }
  1997. + Send_IRCA(CD->USER, "\0034[ERROR] : You Are Not Logged In!", true, "ERROR");
  1998. +}
  1999. +
  2000. +void IRCCmd::Account_Player(_CDATA *CD)
  2001. +{
  2002. + std::string* _PARAMS = getArray(CD->PARAMS, 3);
  2003. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  2004. + {
  2005. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  2006. + return;
  2007. + }
  2008. + normalizePlayerName(_PARAMS[0]);
  2009. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(_PARAMS[0]);
  2010. + uint32 account_id = 0;
  2011. + account_id = sObjectMgr.GetPlayerAccountIdByGUID(guid);
  2012. + if (account_id)
  2013. + {
  2014. + if (account_id == GetAcctIDFromName(CD->USER) || GetLevel(CD->USER) >= sIRC._op_gm_lev)
  2015. + {
  2016. + Player* plr = sObjectMgr.GetPlayer(guid);
  2017. + if (_PARAMS[1] == "lock")
  2018. + {
  2019. + LoginDatabase.PExecute( "UPDATE `account` SET `locked` = '1' WHERE `id` = '%d'",account_id);
  2020. + if (plr) Send_Player(plr, MakeMsg("Your Account Has Been Locked To Your Current IP By: %s", CD->USER.c_str()));
  2021. + Send_IRCA(ChanOrPM(CD), "\00313["+GetAcctNameFromID(account_id)+"] : Account Has Been Locked To Their Current IP Address.", true, CD->TYPE);
  2022. + }
  2023. + else if (_PARAMS[1] == "unlock")
  2024. + {
  2025. + LoginDatabase.PExecute( "UPDATE `account` SET `locked` = '0' WHERE `id` = '%d'",account_id);
  2026. + if (plr) Send_Player(plr, MakeMsg("Your Account Has Been UnLocked From The Associated IP By: %s", CD->USER.c_str()));
  2027. + Send_IRCA(ChanOrPM(CD), "\00313["+GetAcctNameFromID(account_id)+"] : Account Has Been UnLocked From The Associated IP Address.", true, CD->TYPE);
  2028. + }
  2029. + else if (_PARAMS[1] == "mail")
  2030. + {
  2031. + LoginDatabase.PExecute( "UPDATE `account` SET `email` = '%s' WHERE `id` = '%d'",_PARAMS[2].c_str() ,account_id);
  2032. + if (plr) Send_Player(plr, MakeMsg("%s Has Changed Your EMail Adress To: %s", CD->USER.c_str(), _PARAMS[2].c_str()));
  2033. + Send_IRCA(ChanOrPM(CD), "\00313["+GetAcctNameFromID(account_id)+"] : EMail Address Successfully Changed To: "+_PARAMS[2], true, CD->TYPE);
  2034. + }
  2035. + else if (_PARAMS[1] == "pass")
  2036. + {
  2037. + LoginDatabase.PExecute( "UPDATE `account` SET `sha_pass_hash` = SHA1(CONCAT(UPPER(`username`),':',UPPER('%s'))) WHERE `id` = '%d'",_PARAMS[2].c_str() ,account_id);
  2038. + if (plr) Send_Player(plr, MakeMsg("%s Has Changed Your Password To: %s", CD->USER.c_str(), _PARAMS[2].c_str()));
  2039. + Send_IRCA(ChanOrPM(CD), "\00313["+GetAcctNameFromID(account_id)+"] : Password Successfully Changed To: "+_PARAMS[2], true, CD->TYPE);
  2040. + }
  2041. + else if (_PARAMS[1] == "rename")
  2042. + {
  2043. + if (plr)
  2044. + {
  2045. + plr->SetAtLoginFlag(AT_LOGIN_RENAME);
  2046. + Send_Player(plr, MakeMsg("%s Has Requested You Change This Characters Name, Rename Will Be Forced On Next Login!", CD->USER.c_str()));
  2047. + }
  2048. + CharacterDatabase.PExecute("UPDATE `characters` SET `at_login` = `at_login` | '1' WHERE `guid` = '%u'", guid.GetCounter());
  2049. + Send_IRCA(ChanOrPM(CD), "\00313["+GetAcctNameFromID(account_id)+"] : Has Been Forced To Change Their Characters Name, Rename Will Be Forced On Next Login!", true, CD->TYPE);
  2050. + }
  2051. + }
  2052. + else
  2053. + Send_IRCA(CD->USER, "\0034[ERROR] : You Are Not A GM, You May Only Change Settings In Your Own Account.", true, "ERROR");
  2054. + }
  2055. + else
  2056. + Send_IRCA(CD->USER, "\0034[ERROR] : No Such Player Exists, So Account Cannot Be Looked Up.", true, "ERROR");
  2057. +}
  2058. +
  2059. +void IRCCmd::Ban_Player(_CDATA *CD)
  2060. +{
  2061. + std::string* _PARAMS = getArray(CD->PARAMS, 3);
  2062. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  2063. + {
  2064. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  2065. + return;
  2066. + }
  2067. + if (_PARAMS[1] == "ip")
  2068. + {
  2069. + std::string ip = GetIPFromPlayer(_PARAMS[0]);
  2070. + if (_PARAMS[2] == "")
  2071. + _PARAMS[2] = "No Reason";
  2072. + if (ip != "")
  2073. + {
  2074. + LoginDatabase.PExecute( "INSERT IGNORE INTO `ip_banned` VALUES ('%s', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '%s', '%s')", ip.c_str(), CD->USER.c_str(), _PARAMS[2].c_str());
  2075. + if (Player* plr = GetPlayer(_PARAMS[0]))
  2076. + plr->GetSession()->KickPlayer();
  2077. + Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Had Their IP Address Banned. [%s] Reason: %s",_PARAMS[0].c_str() ,ip.c_str() , _PARAMS[2].c_str()), true, CD->TYPE);
  2078. + }
  2079. + else
  2080. + Send_IRCA(CD->USER, "\0034[ERROR] : I Cannot Locate An IP Address For The Character Name Given.", true, "ERROR");
  2081. + }
  2082. + if (_PARAMS[1] == "acct")
  2083. + {
  2084. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(_PARAMS[0].c_str());
  2085. + uint32 acctid = sObjectMgr.GetPlayerAccountIdByGUID(guid);
  2086. + if (_PARAMS[2] == "")
  2087. + _PARAMS[2] = "No Reason";
  2088. + if (acctid)
  2089. + {
  2090. + LoginDatabase.PExecute( "INSERT INTO `account_banned` VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '%s', '%s', 1)", acctid, CD->USER.c_str(), _PARAMS[2].c_str());
  2091. + if (Player* plr = GetPlayer(_PARAMS[0]))
  2092. + plr->GetSession()->KickPlayer();
  2093. + Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Had Their Account Banned. Reason: %s",_PARAMS[0].c_str(), _PARAMS[2].c_str()), true, CD->TYPE);
  2094. + }
  2095. + else
  2096. + Send_IRCA(CD->USER, "\0034[ERROR] : I Cannot Locate An Account For The Character Name Given.", true, "ERROR");
  2097. + }
  2098. + if (_PARAMS[1] == "unban")
  2099. + {
  2100. + std::string unbani = _PARAMS[0];
  2101. + if (atoi(unbani.c_str()) > 0)
  2102. + {
  2103. + LoginDatabase.PExecute( "DELETE FROM ip_banned WHERE ip = '%s'", _PARAMS[0].c_str());
  2104. + Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Been Removed From The IP Ban List.", _PARAMS[0].c_str()), true, CD->TYPE);
  2105. + }
  2106. + else
  2107. + {
  2108. + QueryResult *result = LoginDatabase.PQuery("SELECT id FROM `account` WHERE username = '%s'", _PARAMS[0].c_str());
  2109. + if (result)
  2110. + {
  2111. + Field *fields = result->Fetch();
  2112. + std::string id = fields[0].GetCppString();
  2113. +
  2114. + LoginDatabase.PExecute( "DELETE FROM account_banned WHERE id = %s", id.c_str());
  2115. + delete result;
  2116. + Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Been Removed From The Account Ban List.", _PARAMS[0].c_str()), true, CD->TYPE);
  2117. +
  2118. + }
  2119. + else
  2120. + Send_IRCA(CD->USER, "\0034[ERROR] : I Cannot Locate An Account Or IP Address For The Paramaters Given.", true, "ERROR");
  2121. + }
  2122. + }
  2123. +}
  2124. +
  2125. +void IRCCmd::Chan_Control(_CDATA *CD)
  2126. +{
  2127. + std::string* _PARAMS = getArray(CD->PARAMS, 2);
  2128. + if (CD->FROM == *(sIRC.GetNick()))
  2129. + {
  2130. + Send_IRCA(CD->USER, "\0034[ERROR] : You Cannot Use This Command Through A PM Yet.", true, "ERROR");
  2131. + return;
  2132. + }
  2133. + if (_PARAMS[0] == "op")
  2134. + {
  2135. + if (_PARAMS[1].length() > 1)
  2136. + sIRC.SendIRC("MODE "+CD->FROM+" +o "+_PARAMS[1] );
  2137. + else
  2138. + sIRC.SendIRC("MODE "+CD->FROM+" +o "+CD->USER );
  2139. + }
  2140. + if (_PARAMS[0] == "deop")
  2141. + {
  2142. + if (_PARAMS[1].length() > 1)
  2143. + sIRC.SendIRC("MODE "+CD->FROM+" -o "+_PARAMS[1] );
  2144. + else
  2145. + sIRC.SendIRC("MODE "+CD->FROM+" -o "+CD->USER );
  2146. + }
  2147. + if (_PARAMS[0] == "voice")
  2148. + {
  2149. + if (_PARAMS[1].length() > 1)
  2150. + sIRC.SendIRC("MODE "+CD->FROM+" +v "+_PARAMS[1] );
  2151. + else
  2152. + sIRC.SendIRC("MODE "+CD->FROM+" +v "+CD->USER );
  2153. + }
  2154. + if (_PARAMS[0] == "devoice")
  2155. + {
  2156. + if (_PARAMS[1].length() > 1)
  2157. + sIRC.SendIRC("MODE "+CD->FROM+" -v "+_PARAMS[1] );
  2158. + else
  2159. + sIRC.SendIRC("MODE "+CD->FROM+" -v "+CD->USER );
  2160. + }
  2161. +}
  2162. +
  2163. +void IRCCmd::Char_Player(_CDATA *CD)
  2164. +{
  2165. + std::string* _PARAMS = getArray(CD->PARAMS, 5);
  2166. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  2167. + {
  2168. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  2169. + return;
  2170. + }
  2171. + normalizePlayerName(_PARAMS[0]);
  2172. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(_PARAMS[0]);
  2173. + Player* plr = sObjectMgr.GetPlayer(guid);
  2174. + if (plr)
  2175. + {
  2176. + if (_PARAMS[1] == "mapcheat")
  2177. + {
  2178. + bool explore = false;
  2179. + if (_PARAMS[2] != "0")
  2180. + explore = true;
  2181. + for (uint8 i=0; i<64; i++)
  2182. + {
  2183. + if (_PARAMS[2] != "0")
  2184. + plr->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0xFFFFFFFF);
  2185. + else
  2186. + plr->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0);
  2187. + }
  2188. + if (explore)
  2189. + {
  2190. + Send_Player(plr, MakeMsg("All Your Zones Have Been Set To Explored By: %s", CD->USER.c_str()));
  2191. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Now Explored All Zones.", true, CD->TYPE);
  2192. + }
  2193. + else
  2194. + {
  2195. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Now Had All Zones Set To Un-Explored.", true, CD->TYPE);
  2196. + Send_Player(plr, MakeMsg("All Your Zones Have Been Set To Un-Explored By: %s", CD->USER.c_str()));
  2197. + }
  2198. + }
  2199. + if (_PARAMS[1] == "taxicheat")
  2200. + {
  2201. + if (_PARAMS[2] != "0")
  2202. + {
  2203. + plr->SetTaxiCheater(true);
  2204. + Send_Player(plr, MakeMsg("Taxi Node Cheat Has Been Enabled By: %s", CD->USER.c_str()));
  2205. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Taxi Node Cheat Has Been Enabled.", true, CD->TYPE);
  2206. + }
  2207. + else
  2208. + {
  2209. + plr->SetTaxiCheater(false);
  2210. + Send_Player(plr, MakeMsg("Taxi Node Cheat Has Been Disabled By: %s", CD->USER.c_str()));
  2211. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Taxi Node Cheat Has Been Disabled.", true, CD->TYPE);
  2212. + }
  2213. + }
  2214. + if (_PARAMS[1] == "maxskill")
  2215. + {
  2216. + plr->UpdateSkillsToMaxSkillsForLevel();
  2217. + Send_Player(plr, MakeMsg("Your Skills Have Been Maxed Out By: %s", CD->USER.c_str()));
  2218. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Skills Have Been Maxed Out.", true, CD->TYPE);
  2219. + }
  2220. + if (_PARAMS[1] == "setskill")
  2221. + {
  2222. + std::string* _PARAMSA = getArray(_PARAMS[2], 4);
  2223. + uint32 skill = atoi(_PARAMS[2].c_str());
  2224. + uint32 level = atol(_PARAMS[3].c_str());
  2225. + int32 max = _PARAMS[4].c_str() ? atol (_PARAMS[4].c_str()) : plr->GetPureMaxSkillValue(skill);
  2226. + SkillLineEntry const* skilllookup = sSkillLineStore.LookupEntry(skill);
  2227. + //if skillid entered is not a number and greater then 0 then the command is being used wrong
  2228. + if (skill >= 0)
  2229. + {
  2230. + //does the skill even exist
  2231. + if (skilllookup)
  2232. + {
  2233. + //does player have the skill yet
  2234. + if (plr->GetSkillValue(skill))
  2235. + {
  2236. + plr->SetSkill(skill,level,max);
  2237. + Send_Player(plr, MakeMsg("Skill: %s Has Been Set To Level: %i Max: %i By: %s",skilllookup->name[0], level, max, CD->USER.c_str()));
  2238. + Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Had Skill: %s Set To Level: %d Max: %d",_PARAMS[0].c_str() , skilllookup->name[0], level, max), true, CD->TYPE);
  2239. + }
  2240. + else
  2241. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Player Does Not Have The %s Skill Yet.", skilllookup->name[0]), true, "ERROR");
  2242. + }
  2243. + else
  2244. + Send_IRCA(CD->USER, "\0034[ERROR] : That Skill ID Does Not Exist.", true, "ERROR");
  2245. + }
  2246. + else
  2247. + Send_IRCA(CD->USER, "\0034[ERROR] : The Skill ID Entered Is Invalid.", true, "ERROR");
  2248. + }
  2249. + }
  2250. + else
  2251. + Send_IRCA(CD->USER, "\0034[ERROR] : No Character With That Name Exists.", true, "ERROR");
  2252. +}
  2253. +
  2254. +void IRCCmd::Fun_Player(_CDATA *CD)
  2255. +{
  2256. + std::string* _PARAMS = getArray(CD->PARAMS, 3);
  2257. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  2258. + {
  2259. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  2260. + return;
  2261. + }
  2262. + if (Player* plr = GetPlayer(_PARAMS[0]))
  2263. + {
  2264. + if (_PARAMS[1] == "say")
  2265. + {
  2266. + plr->Say(_PARAMS[2], LANG_UNIVERSAL);
  2267. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Was Forced To Say: "+_PARAMS[2]+".", true, CD->TYPE);
  2268. + }
  2269. + if (_PARAMS[1] == "sound")
  2270. + {
  2271. + uint32 sndid = atoi(_PARAMS[2].c_str());
  2272. + plr->PlayDistanceSound(sndid);
  2273. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Just Heard Sound ID: "+_PARAMS[2]+".", true, CD->TYPE);
  2274. + }
  2275. + }
  2276. + else
  2277. + Send_IRCA(CD->USER, "\0034[ERROR] : Player Not Online!", true, "ERROR");
  2278. +}
  2279. +
  2280. +void IRCCmd::Help_IRC(_CDATA *CD)
  2281. +{
  2282. + std::string* _PARAMS = getArray(CD->PARAMS, 1);
  2283. + QueryResult *result = WorldDatabase.PQuery("SELECT `Command`, `Description`, `gmlevel` FROM `irc_commands`");
  2284. + if (result)
  2285. + {
  2286. + if (IsLoggedIn(CD->USER))
  2287. + {
  2288. + if (_PARAMS[0] == "")
  2289. + {
  2290. + QueryResult *result = WorldDatabase.PQuery("SELECT * FROM `irc_commands` WHERE `gmlevel` <= %u ORDER BY `Command`", GetLevel(CD->USER));
  2291. + if (result)
  2292. + {
  2293. + std::string output = "\002MangChat IRC Commands:\017 ";
  2294. + for (uint64 i=0; i < result->GetRowCount(); i++)
  2295. + {
  2296. + Field *fields = result->Fetch();
  2297. + output += fields[0].GetCppString() + ", ";
  2298. + result->NextRow();
  2299. + }
  2300. + delete result;
  2301. + Send_IRCA(CD->USER, output, true, CD->TYPE.c_str());
  2302. + }
  2303. + }
  2304. + else
  2305. + {
  2306. + QueryResult *result = WorldDatabase.PQuery("SELECT `Description`, `gmlevel` FROM `irc_commands` WHERE `Command` = '%s'", _PARAMS[0].c_str());
  2307. + if (result)
  2308. + {
  2309. + Field *fields = result->Fetch();
  2310. + if (fields[1].GetInt32() > GetLevel(CD->USER))
  2311. + {
  2312. + Send_IRCA(CD->USER, "You Do Not Have Access To That Command, So No Help Is Available.", true, CD->TYPE.c_str());
  2313. + return;
  2314. + }
  2315. + if (result)
  2316. + {
  2317. + std::string cmdhlp = fields[0].GetCppString();
  2318. + delete result;
  2319. + Send_IRCA(CD->USER, cmdhlp, true, CD->TYPE.c_str());
  2320. + }
  2321. + }
  2322. + else
  2323. + Send_IRCA(CD->USER, "\0034[ERROR] : No Such Command Exists, Please Check The Spelling And Try Again.", true, "ERROR");
  2324. + }
  2325. + }
  2326. + else if (!IsLoggedIn(CD->USER))
  2327. + {
  2328. + if (_PARAMS[0] == "")
  2329. + {
  2330. + QueryResult *result = WorldDatabase.PQuery("SELECT * FROM `irc_commands` WHERE `gmlevel` = 0 ORDER BY `Command`");
  2331. + if (result)
  2332. + {
  2333. + std::string output = "\002MangChat IRC Commands:\017 ";
  2334. + for (uint64 i=0; i < result->GetRowCount(); i++)
  2335. + {
  2336. + Field *fields = result->Fetch();
  2337. + output += fields[0].GetCppString() + ", ";
  2338. + result->NextRow();
  2339. + }
  2340. + delete result;
  2341. + Send_IRCA(CD->USER, output, true, CD->TYPE.c_str());
  2342. + Send_IRCA(CD->USER, "You Are Currently Not Logged In, Please Login To See A Complete List Of Commands Available To You.", true, CD->TYPE.c_str());
  2343. + }
  2344. + }
  2345. + else
  2346. + {
  2347. + QueryResult *result = WorldDatabase.PQuery("SELECT `Description`, `gmlevel` FROM `irc_commands` WHERE `Command` = '%s'", _PARAMS[0].c_str());
  2348. + if (result)
  2349. + {
  2350. + Field *fields = result->Fetch();
  2351. + if (fields[1].GetUInt32() > 0)
  2352. + {
  2353. + Send_IRCA(CD->USER, "You Do Not Have Access To That Command, So No Help Is Available.", true, CD->TYPE.c_str());
  2354. + return;
  2355. + }
  2356. + std::string cmdhlp = fields[0].GetCppString();
  2357. + delete result;
  2358. + Send_IRCA(CD->USER, cmdhlp, true, CD->TYPE.c_str());
  2359. + }
  2360. + else
  2361. + Send_IRCA(CD->USER, "\0034[ERROR] : No Such Command Exists, Please Check The Spelling And Try Again.", true, "ERROR");
  2362. + }
  2363. + }
  2364. + }
  2365. + else
  2366. + Send_IRCA(CD->USER, "\0034[ERROR] : Database Error! Please Make Sure You Used irc_commands.sql, You Must Have A Table In Your World Database (irc_commands)!", true, "ERROR");
  2367. +}
  2368. +
  2369. +void IRCCmd::Inchan_Server(_CDATA *CD)
  2370. +{
  2371. + std::string* _PARAMS = getArray(CD->PARAMS, 1);
  2372. + if (_PARAMS[0] == "")
  2373. + {
  2374. + Send_IRCA(CD->USER, "\0034[ERROR] : Syntax Error! ( "+sIRC._cmd_prefx+"inchan <ChannelName> )", true, "ERROR");
  2375. + return;
  2376. + }
  2377. + QueryResult *result = WorldDatabase.PQuery("SELECT * FROM `irc_inchan` WHERE `channel` = '%s' ORDER BY `name`", _PARAMS[0].c_str());
  2378. + if (result)
  2379. + {
  2380. + Field *fields = result->Fetch();
  2381. + std::string output = "\002Players In The [ "+fields[2].GetCppString()+" ] Channel:\017 ";
  2382. + for (uint64 i=0; i < result->GetRowCount(); i++)
  2383. + {
  2384. + output += fields[1].GetCppString() + ", ";
  2385. + result->NextRow();
  2386. + }
  2387. + delete result;
  2388. + Send_IRCA(ChanOrPM(CD), output, true, CD->TYPE);
  2389. + }
  2390. + else
  2391. + Send_IRCA(ChanOrPM(CD), "No Players Are Currently In [ "+_PARAMS[0]+" ] Channel!", true, CD->TYPE.c_str());
  2392. +}
  2393. +
  2394. +void IRCCmd::Info_Server(_CDATA *CD)
  2395. +{
  2396. + std::string* _PARAMS = getArray(CD->PARAMS, 1);
  2397. +
  2398. + // get currently active Players
  2399. + char clientsNum [50];
  2400. + sprintf(clientsNum, "%u", sWorld.GetActiveSessionCount());
  2401. +
  2402. + // get max active Players since last restart
  2403. + char maxClientsNum [50];
  2404. + sprintf(maxClientsNum, "%u", sWorld.GetMaxActiveSessionCount());
  2405. +
  2406. + // get UpTime
  2407. + std::string upTime = secsToTimeString(sWorld.GetUptime());
  2408. +
  2409. + // Send Player and Uptime information to IRC
  2410. + Send_IRCA(ChanOrPM(CD), "\x2 Number Of Players Online:\x3\x31\x30 " + (std::string)clientsNum + "\xF |\x2 Max Since Last Restart:\x3\x31\x30 "+(std::string)maxClientsNum+"\xF |\x2 UpTime:\x3\x31\x30 "+upTime, true, CD->TYPE);
  2411. +
  2412. + // send core revision info to IRC
  2413. + #ifdef _DISTRIBUTION
  2414. + Send_IRCA(ChanOrPM(CD), " Core: \x2 " +(std::string)_DISTRIBUTION +" \x2 based on \x2 MaNGOS ["+ (std::string)REVISION_NR+"]", true, CD->TYPE);
  2415. + #else
  2416. + Send_IRCA(ChanOrPM(CD), " Core: \x2 MaNGOS ["+ (std::string)REVISION_NR+"]", true, CD->TYPE);
  2417. + #endif
  2418. +
  2419. +
  2420. + // send scripting library info to IRC
  2421. + std::string scriptVersion;
  2422. + if (sScriptMgr.IsScriptLibraryLoaded())
  2423. + {
  2424. + scriptVersion = sScriptMgr.GetScriptLibraryVersion();
  2425. + if (scriptVersion.empty())
  2426. + scriptVersion= "Unknown Script Library.";
  2427. + // cut a bit, if it is too long
  2428. + else if (scriptVersion.length() > 30)
  2429. + scriptVersion = scriptVersion.substr(0,30) + "...";
  2430. + }
  2431. + else
  2432. + scriptVersion = "No Script Library loaded!";
  2433. +
  2434. + Send_IRCA(ChanOrPM(CD), " Script Library: \x2"+scriptVersion, true, CD->TYPE);
  2435. +
  2436. +
  2437. + // send DB info to IRC
  2438. + std::string dbVersion(sWorld.GetDBVersion());
  2439. + if (dbVersion.empty())
  2440. + dbVersion = "Unknown DB Version.";
  2441. + else if (dbVersion.length() > 30)
  2442. + dbVersion = dbVersion.substr(0,30) + "...";
  2443. +
  2444. + Send_IRCA(ChanOrPM(CD), " Database: \x2"+dbVersion, true, CD->TYPE);
  2445. +}
  2446. +
  2447. +void IRCCmd::Item_Player(_CDATA *CD)
  2448. +{
  2449. + std::string* _PARAMS = getArray(CD->PARAMS, 3);
  2450. +
  2451. + normalizePlayerName(_PARAMS[0]);
  2452. + Player *chr = GetPlayer(_PARAMS[0].c_str());
  2453. + if (_PARAMS[1] == "add")
  2454. + {
  2455. + std::string s_param = _PARAMS[2];
  2456. +
  2457. + char *args = (char*)s_param.c_str();
  2458. + uint32 itemId = 0;
  2459. + if (args[0]=='[')
  2460. + {
  2461. + char* citemName = citemName = strtok((char*)args, "]");
  2462. + if (citemName && citemName[0])
  2463. + {
  2464. + std::string itemName = citemName+1;
  2465. + WorldDatabase.escape_string(itemName);
  2466. + QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str());
  2467. + if (!result)
  2468. + {
  2469. + Send_IRCA(CD->USER, "\0034[ERROR] : Item Not Found!", true, "ERROR");
  2470. + return;
  2471. + }
  2472. + itemId = result->Fetch()->GetUInt16();
  2473. + delete result;
  2474. + }
  2475. + else
  2476. + {
  2477. + Send_IRCA(CD->USER, "\0034[ERROR] : Syntax Error! ( "+sIRC._cmd_prefx+"item <Player> <add> [Exact Item Name] <Amount> )", true, "ERROR");
  2478. + return;
  2479. + }
  2480. + }
  2481. + else
  2482. + {
  2483. + std::string itemName = s_param;
  2484. + WorldDatabase.escape_string(itemName);
  2485. + QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str());
  2486. + if (result)
  2487. + {
  2488. + itemId = result->Fetch()->GetUInt16();
  2489. + }
  2490. + delete result;
  2491. +
  2492. + char* cId = strtok(args, " ");
  2493. + if (!cId)
  2494. + {
  2495. + Send_IRCA(CD->USER, "\0034[ERROR] : Syntax Error! ( "+sIRC._cmd_prefx+"item <Player> <add> <ItemID> <Amount> )", true, "ERROR");
  2496. + return;
  2497. + }
  2498. + itemId = atol(cId);
  2499. + }
  2500. + char* ccount = strtok(NULL, " ");
  2501. + int32 count = 1;
  2502. + if (ccount) {
  2503. + count = atol(ccount);
  2504. + }
  2505. + Player* plTarget = chr;
  2506. + if (!plTarget)
  2507. + {
  2508. + Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Online!", true, "ERROR");
  2509. + return;
  2510. + }
  2511. + ItemPrototype const *pProto = sObjectMgr.GetItemPrototype(itemId);
  2512. + //Subtract
  2513. + if (count < 0)
  2514. + {
  2515. + plTarget->DestroyItemCount(itemId, -count, true, false);
  2516. + char itemid2[255];
  2517. + sprintf(itemid2,"%d",itemId);
  2518. + std::string itake = " \00313["+ _PARAMS[0] +"] : Has Had Item " +itemid2+ " Taken From Them!";
  2519. + Send_IRCA(ChanOrPM(CD), itake, true, CD->TYPE);
  2520. + return;
  2521. + }
  2522. + //Adding items
  2523. + uint32 noSpaceForCount = 0;
  2524. +
  2525. + // check space and find places
  2526. + ItemPosCountVec dest;
  2527. + uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount );
  2528. + if ( msg == EQUIP_ERR_INVENTORY_FULL ) // convert to possibel store amount
  2529. + count -= noSpaceForCount;
  2530. + else if ( msg != EQUIP_ERR_OK ) // other error, can't add
  2531. + {
  2532. + char s_countForStore[255];
  2533. + sprintf(s_countForStore,"%d",count);
  2534. + std::string ierror = " \00313["+ _PARAMS[0] +"] : Could Not Create All Items! " +s_countForStore+ " Item(s) Were Not Created!";
  2535. + Send_IRCA(ChanOrPM(CD), ierror, true, CD->TYPE);
  2536. + return;
  2537. + }
  2538. + Item* item = plTarget->StoreNewItem( dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
  2539. + if (count > 0 && item)
  2540. + {
  2541. + plTarget->SendNewItem(item,count,true,false);
  2542. + QueryResult *result = WorldDatabase.PQuery("SELECT name FROM item_template WHERE entry = %d", itemId);
  2543. + char* dbitemname = NULL;
  2544. + if (result)
  2545. + {
  2546. + dbitemname = (char*)result->Fetch()->GetString();
  2547. + }
  2548. + std::string iinfo = " \00313[" + _PARAMS[0] + "] : Has Been Given Item "+dbitemname+". From: "+CD->USER.c_str()+".";
  2549. + Send_IRCA(ChanOrPM(CD), iinfo, true, CD->TYPE);
  2550. + delete result;
  2551. + }
  2552. + if (noSpaceForCount > 0)
  2553. + {
  2554. + char s_countForStore[255];
  2555. + sprintf(s_countForStore,"%d",noSpaceForCount);
  2556. + std::string ierror = " \00313["+ _PARAMS[0] +"] : Could Not Create All Items! " +s_countForStore+ " Item(s) Were Not Created!";
  2557. + Send_IRCA(ChanOrPM(CD), ierror, true, CD->TYPE);
  2558. + return;
  2559. + }
  2560. + }
  2561. + else
  2562. + {
  2563. + Send_IRCA(CD->USER, "\0034[ERROR] : Syntax Error! ( "+sIRC._cmd_prefx+"item <Player> <add> <ItemID> <Amount> )", true, "ERROR");
  2564. + return;
  2565. + }
  2566. +}
  2567. +
  2568. +void IRCCmd::Jail_Player(_CDATA *CD)
  2569. +{
  2570. + if (ValidParams(CD->PARAMS, 1))
  2571. + {
  2572. + std::string* _PARAMS = getArray(CD->PARAMS, 2);
  2573. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  2574. + {
  2575. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  2576. + return;
  2577. + }
  2578. + if (Player *plr = GetPlayer(_PARAMS[0]))
  2579. + {
  2580. + std::string sReason = "";
  2581. + if (_PARAMS[1] == "release")
  2582. + {
  2583. + float rposx, rposy, rposz, rposo = 0;
  2584. + uint32 rmapid = 0;
  2585. + CharacterDatabase.escape_string(_PARAMS[0]);
  2586. + QueryResult *result = CharacterDatabase.PQuery( "SELECT `map`, `position_x`, `position_y`, `position_z` FROM `character_homebind` WHERE `guid` = '" UI64FMTD "'", plr->GetObjectGuid() );
  2587. + if (result)
  2588. + {
  2589. + Field *fields = result->Fetch();
  2590. + rmapid = fields[0].GetUInt16();
  2591. + rposx = fields[1].GetFloat();
  2592. + rposy = fields[2].GetFloat();
  2593. + rposz = fields[3].GetFloat();
  2594. + delete result;
  2595. + plr->SetMovement(MOVE_UNROOT);
  2596. + plr->TeleportTo(rmapid, rposx, rposy, rposz, rposo);
  2597. + plr->RemoveAurasDueToSpell(42201);
  2598. + plr->RemoveAurasDueToSpell(23775);
  2599. + plr->RemoveAurasDueToSpell(9454);
  2600. + Send_Player(plr, MakeMsg("You Have Been Released By: %s.", CD->USER.c_str()));
  2601. + sReason = " \00313["+_PARAMS[0]+"] : Has Been Released By: "+CD->USER+".";
  2602. + Send_IRCA(ChanOrPM(CD), sReason, true, CD->TYPE);
  2603. + }
  2604. + }
  2605. + else
  2606. + {
  2607. + if (_PARAMS[1] == "")
  2608. + _PARAMS[1] = "No Reason Given.";
  2609. + plr->TeleportTo(13, 0, 0, 0, 0);
  2610. + plr->SetMovement(MOVE_ROOT);
  2611. + plr->CastSpell(plr, 42201, true);
  2612. + plr->CastSpell(plr, 23775, true);
  2613. + plr->CastSpell(plr, 9454, true);
  2614. + Send_Player(plr, MakeMsg("You Have Been Jailed By: %s. Reason: %s.", CD->USER.c_str(), _PARAMS[1].c_str()));
  2615. + sReason = " \00313["+_PARAMS[0]+"] : Has Been Jailed By: "+CD->USER+". Reason: "+_PARAMS[1]+".";
  2616. + Send_IRCA(ChanOrPM(CD), sReason, true, CD->TYPE);
  2617. + }
  2618. + }
  2619. + else
  2620. + Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Online!", true, "ERROR");
  2621. + }
  2622. +}
  2623. +
  2624. +void IRCCmd::Kick_Player(_CDATA *CD)
  2625. +{
  2626. + std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT);
  2627. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  2628. + {
  2629. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  2630. + return;
  2631. + }
  2632. + if (_PARAMS[1] == "")
  2633. + _PARAMS[1] = "No Reason Given.";
  2634. + if (Player* plr = GetPlayer(_PARAMS[0]))
  2635. + {
  2636. + plr->GetSession()->KickPlayer();
  2637. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Been Kicked By: "+CD->USER+". Reason: "+_PARAMS[1]+".", true, CD->TYPE);
  2638. + }
  2639. + else
  2640. + Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Online!", true, "ERROR");
  2641. +}
  2642. +
  2643. +void IRCCmd::Kill_Player(_CDATA *CD)
  2644. +{
  2645. + std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT);
  2646. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  2647. + {
  2648. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  2649. + return;
  2650. + }
  2651. + if (Player* plr = GetPlayer(_PARAMS[0]))
  2652. + {
  2653. + if (plr->isAlive())
  2654. + {
  2655. + plr->DealDamage(plr, plr->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
  2656. + plr->SaveToDB();
  2657. + if (_PARAMS[1] == "")
  2658. + _PARAMS[1] = "No Reason Given.";
  2659. + Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Been Killed By: %s.", _PARAMS[0].c_str(), CD->USER.c_str()) + + + " Reason: "+_PARAMS[1]+".", true, CD->TYPE);
  2660. + Send_Player(plr, MakeMsg("You Have Been Killed By: %s. Reason: %s.", CD->USER.c_str(), _PARAMS[1].c_str()));
  2661. + }
  2662. + else
  2663. + Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Already Dead!", true, "ERROR");
  2664. + }
  2665. + else
  2666. + Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Online!", true, "ERROR");
  2667. +}
  2668. +
  2669. +void IRCCmd::Lookup_Player(_CDATA *CD)
  2670. +{
  2671. + std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT);
  2672. + if (_PARAMS[0] == "acct")
  2673. + {
  2674. + uint32 acctid = atoi(_PARAMS[1].c_str());
  2675. + if (sAccountMgr.GetId(_PARAMS[1]))
  2676. + acctid = sAccountMgr.GetId(_PARAMS[1]);
  2677. + if (acctid > 0)
  2678. + {
  2679. + std::string DateTime = "%a, %b %d, %Y - %h:%i%p";
  2680. + QueryResult *result = LoginDatabase.PQuery("SELECT id, username, gmlevel, last_ip, (SELECT banreason FROM account_banned WHERE id = %d LIMIT 1) as banned, (SELECT banreason FROM ip_banned WHERE ip = last_ip) as bannedip, DATE_FORMAT(last_login, '%s') FROM `account` WHERE id = %d", acctid, DateTime.c_str(), acctid, acctid);
  2681. + if (result)
  2682. + {
  2683. + Field *fields = result->Fetch();
  2684. +
  2685. + uint32 id = fields[0].GetUInt32();
  2686. + std::string usrname = fields[1].GetCppString();
  2687. + uint32 gm = fields[2].GetUInt32();
  2688. + std::string lastip = fields[3].GetCppString();
  2689. + std::string banreason = fields[4].GetCppString();
  2690. + std::string banreasonip = fields[5].GetCppString();
  2691. + std::string lastlogin = fields[6].GetCppString();
  2692. + delete result;
  2693. +
  2694. + QueryResult *chars = CharacterDatabase.PQuery("SELECT guid, name, (SELECT SUM(totaltime) FROM characters WHERE account = %d) AS tottime FROM characters WHERE account = %u", id, id);
  2695. + std::string characters = "None";
  2696. + std::string totaccttime = "Never Logged In";
  2697. + if (chars)
  2698. + {
  2699. + characters = "";
  2700. + Field *fields = chars->Fetch();
  2701. + totaccttime = SecToDay(fields[2].GetCppString());
  2702. + for (uint64 i=0; i < chars->GetRowCount(); i++)
  2703. + {
  2704. + std::string guid = fields[0].GetCppString();
  2705. + std::string charname = fields[1].GetCppString();
  2706. + characters.append(charname+"("+guid+"), ");
  2707. + chars->NextRow();
  2708. + }
  2709. + delete chars;
  2710. + }
  2711. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Username:\x3\x31\x30 %s \xF|\x2 AccountID:\x3\x31\x30 %d \xF|\x2 GM Level:\x3\x31\x30 %d \xF|\x2 Last IP:\x3\x31\x30 %s \xF|\x2 Last Login:\x3\x31\x30 %s", usrname.c_str(), id, gm, lastip.c_str(), lastlogin.c_str()), true, CD->TYPE);
  2712. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Total Play Time:\x3\x31\x30 %s \xF|\x2 Characters:\x3\x31\x30 %s ", totaccttime.c_str(), characters.c_str()), true, CD->TYPE);
  2713. + if (banreason.length() > 1)
  2714. + Send_IRCA(ChanOrPM(CD), MakeMsg("\0034This User Has An Account Ban. Ban Reason: %s", banreason.c_str()), true, CD->TYPE);
  2715. + if (banreasonip.length() > 1)
  2716. + Send_IRCA(ChanOrPM(CD), MakeMsg("\0034This User Has An IP Ban. Ban Reason: %s", banreasonip.c_str()), true, CD->TYPE);
  2717. + }
  2718. + else
  2719. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Account ID." ,true, "ERROR");
  2720. + }
  2721. + else
  2722. + {
  2723. + QueryResult *result = LoginDatabase.PQuery("SELECT id, username FROM `account` WHERE username LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str());
  2724. + if (result)
  2725. + {
  2726. + Field *fields = result->Fetch();
  2727. + std::string accts = "\002Account Search Results:\x3\x31\x30 ";
  2728. + for (uint64 i=0; i < result->GetRowCount(); i++)
  2729. + {
  2730. + std::string acctid = fields[0].GetCppString();
  2731. + std::string acctname = fields[1].GetCppString();
  2732. + accts.append(acctname+"("+acctid+")\xF | \x3\x31\x30\x2");
  2733. + result->NextRow();
  2734. + }
  2735. + delete result;
  2736. + Send_IRCA(ChanOrPM(CD), accts, true, CD->TYPE);
  2737. + }
  2738. + else
  2739. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Username. I Cant Find Any Users With Those Search Terms." ,true, "ERROR");
  2740. + }
  2741. + }
  2742. + if (_PARAMS[0] == "char")
  2743. + {
  2744. + ObjectGuid plguid = ObjectGuid(uint64(_PARAMS[1].c_str()));
  2745. + if (!sObjectMgr.GetPlayerGuidByName(_PARAMS[1].c_str()).IsEmpty())
  2746. + plguid = sObjectMgr.GetPlayerGuidByName(_PARAMS[1].c_str());
  2747. + if (!plguid.IsEmpty())
  2748. + {
  2749. + QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, name, race, class, online, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 35), ' ' , -1) AS level, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 238), ' ' , -1) AS guildid, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 239), ' ' , -1) AS guildrank, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 927), ' ' , -1) AS xp, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 928), ' ' , -1) AS maxxp, SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ' , 1462), ' ' , -1) AS gold, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 1454), ' ' , -1) AS hk, totaltime FROM characters WHERE guid =%i", plguid.GetCounter());
  2750. + uint32 latency = 0;
  2751. + Player *chr = sObjectMgr.GetPlayer(plguid);
  2752. + if (chr)
  2753. + {
  2754. + latency = chr->GetSession()->GetLatency();
  2755. + }
  2756. + char templatency [100];
  2757. + sprintf(templatency, "%ums", latency);
  2758. + if (result)
  2759. + {
  2760. + Field *fields = result->Fetch();
  2761. + std::string pguid = fields[0].GetCppString();
  2762. + std::string pacct = fields[1].GetCppString();
  2763. + std::string pname = fields[2].GetCppString();
  2764. + uint32 praceid = fields[3].GetUInt32();
  2765. + uint32 pclassid = fields[4].GetUInt32();
  2766. + std::string ponline = (fields[5].GetInt32() == 1 ? "\x3\x30\x33Online" : "\x3\x30\x34Offline\xF");
  2767. + std::string plevel = fields[6].GetCppString();
  2768. + uint32 pguildid = fields[7].GetUInt32();
  2769. + uint32 pguildrank = fields[8].GetUInt32();
  2770. + std::string pxp = fields[9].GetCppString();
  2771. + std::string pmaxxp = fields[10].GetCppString();
  2772. + unsigned int money = fields[11].GetInt32();
  2773. + std::string hk = fields[12].GetCppString();
  2774. + std::string totaltim = SecToDay(fields[13].GetCppString());
  2775. + delete result;
  2776. + std::string sqlquery = "SELECT `gmlevel` FROM `account` WHERE `id` = '" + pacct + "';";
  2777. + QueryResult *result = LoginDatabase.Query(sqlquery.c_str());
  2778. + Field *fields2 = result->Fetch();
  2779. + std::string pgmlvl = fields2[0].GetCppString();
  2780. + delete result;
  2781. + std::string guildinfo = "";
  2782. + if (pguildid != 0)
  2783. + {
  2784. + Guild* guild = sGuildMgr.GetGuildById(pguildid);
  2785. + if (guild)
  2786. + {
  2787. + guildinfo = " " + guild->GetRankName(pguildrank) + " Of " + guild->GetName();
  2788. + }
  2789. + }
  2790. + else guildinfo = " None";
  2791. + ChrRacesEntry const* prace = sChrRacesStore.LookupEntry(praceid);
  2792. + ChrClassesEntry const* pclass = sChrClassesStore.LookupEntry(pclassid);
  2793. +
  2794. + if (atoi(plevel.c_str()) < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
  2795. + plevel += " (" + pxp + "/" + pmaxxp + ")";
  2796. + unsigned int gold = money / 10000;
  2797. + unsigned int silv = (money % 10000) / 100;
  2798. + unsigned int cop = (money % 10000) % 100;
  2799. + char tempgold [100];
  2800. + sprintf(tempgold, "\x2\x3\x30\x37%ug \x3\x31\x34%us \x3\x30\x35%uc\xF", gold, silv, cop);
  2801. + if (ponline == "\x3\x30\x33Online")
  2802. + {
  2803. + Player * plr = ObjectAccessor::Instance().FindPlayerByName(pname.c_str());
  2804. + if (plr)
  2805. + {
  2806. + AreaTableEntry const* area = GetAreaEntryByAreaID(plr->GetAreaId());
  2807. + ponline += " in " + (std::string) area->area_name[sWorld.GetDefaultDbcLocale()];
  2808. + if (area->zone != 0)
  2809. + {
  2810. + AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone);
  2811. + ponline += " (" + (std::string)zone->area_name[sWorld.GetDefaultDbcLocale()] + ")";
  2812. + }
  2813. + }
  2814. + }
  2815. + std::string pinfo = "\x2 About Player:\x3\x31\x30 " +pname+ "\xF |\x2 GM Level:\x3\x31\x30 " +pgmlvl+ "\xF |\x2 AcctID:\x3\x31\x30 " +pacct+ "\xF |\x2 CharID:\x3\x31\x30 " +pguid+ " \xF |\x2 Played Time:\x2\x3\x31\x30 " +totaltim.c_str()+" \xF |\x2 Latency:\x2\x3\x31\x30 "+templatency;
  2816. + std::string pinfo2 = "\x2 Level:\x2\x3\x31\x30 " + plevel + "\xF |\x2 Money:\x2 " + tempgold + "\xF |\x2 Guild Info:\x2\x3\x31\x30 "+guildinfo+"\xF |\x2 Status:\x2 " + ponline;
  2817. + // pinfo3 = " :" + " \x2Honor Kills:\x2\x3\x31\x30 " + hk;
  2818. + Send_IRCA(ChanOrPM(CD),pinfo , true, CD->TYPE);
  2819. + Send_IRCA(ChanOrPM(CD),pinfo2 , true, CD->TYPE);
  2820. + // Send_IRCA(ChanOrPM(CD),pinfo3 , true, CD->TYPE);
  2821. + }
  2822. + else
  2823. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Character ID. (GUID)" ,true, "ERROR");
  2824. + }
  2825. + else
  2826. + {
  2827. + QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, name FROM characters WHERE name LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str());
  2828. + if (result)
  2829. + {
  2830. + Field *fields = result->Fetch();
  2831. + std::string items = "\x2 Character Search Results:\x3\x31\x30 ";
  2832. + for (uint64 i=0; i < result->GetRowCount(); i++)
  2833. + {
  2834. + std::string guid = fields[0].GetCppString();
  2835. + std::string account = fields[1].GetCppString();
  2836. + std::string name = fields[2].GetCppString();
  2837. + MakeUpper(name);
  2838. + items.append(name+"(Account:"+account+" - GUID:"+guid+")\xF | \x3\x31\x30\x2");
  2839. + result->NextRow();
  2840. + }
  2841. + delete result;
  2842. + Send_IRCA(ChanOrPM(CD), items, true, CD->TYPE);
  2843. + }
  2844. + else
  2845. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Character. I Cant Find Any Characters With Those Search Terms." ,true, "ERROR");
  2846. + }
  2847. + }
  2848. + if (_PARAMS[0] == "creature")
  2849. + {
  2850. + std::string creature = _PARAMS[1];
  2851. + if (atoi(creature.c_str()) > 0)
  2852. + {
  2853. + WorldDatabase.escape_string(_PARAMS[1]);
  2854. + QueryResult *result = WorldDatabase.PQuery("SELECT entry, modelid_A, name, (minlevel*maxlevel/2) as level, faction_A, armor, (SELECT count(*) FROM creature WHERE id = '%s') as spawns FROM creature_template WHERE entry = '%s';", _PARAMS[1].c_str(), _PARAMS[1].c_str());
  2855. + if (result)
  2856. + {
  2857. + Field *fields = result->Fetch();
  2858. +
  2859. + uint32 entry = fields[0].GetUInt32();
  2860. + uint32 modelid = fields[1].GetUInt32();
  2861. + std::string name = fields[2].GetCppString();
  2862. + uint32 level = fields[3].GetUInt32();
  2863. + uint32 faction = fields[4].GetUInt32();
  2864. + uint32 armor = fields[5].GetUInt32();
  2865. + uint32 spawns = fields[6].GetUInt32();
  2866. + delete result;
  2867. +
  2868. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Name:\x3\x31\x30 %s \xF|\x2 CreatureID:\x3\x31\x30 %d \xF|\x2 DisplayID:\x3\x31\x30 %d \xF|\x2 Spawns:\x3\x31\x30 %d", name.c_str(), entry, modelid, spawns), true, CD->TYPE);
  2869. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Level:\x3\x31\x30 %d \xF|\x2 Faction:\x3\x31\x30 %d \xF|\x2 Armor:\x3\x31\x30 %d", level, faction, armor), true, CD->TYPE);
  2870. + }
  2871. + else
  2872. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Creature ID." ,true, "ERROR");
  2873. + }
  2874. + else
  2875. + {
  2876. + QueryResult *result = WorldDatabase.PQuery("SELECT entry, name FROM creature_template WHERE name LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str());
  2877. + if (result)
  2878. + {
  2879. + Field *fields = result->Fetch();
  2880. + std::string items = "\002Creature Search Results:\x3\x31\x30 ";
  2881. + //Send_IRCA(ChanOrPM(CD), "", true, CD->TYPE);
  2882. + for (uint64 i=0; i < result->GetRowCount(); i++)
  2883. + {
  2884. + std::string CreatureID = fields[0].GetCppString();
  2885. + std::string Name = fields[1].GetCppString();
  2886. + items.append(Name+"("+CreatureID+")\xF | \x3\x31\x30\x2");
  2887. + result->NextRow();
  2888. + }
  2889. + delete result;
  2890. + Send_IRCA(ChanOrPM(CD), items, true, CD->TYPE);
  2891. + }
  2892. + else
  2893. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Creature. I Cant Find Any Creatures With Those Search Terms." ,true, "ERROR");
  2894. + }
  2895. + }
  2896. + if (_PARAMS[0] == "faction")
  2897. + {
  2898. + std::string faction = _PARAMS[1];
  2899. + if (atoi(faction.c_str()) > 0)
  2900. + {
  2901. + FactionEntry const *factionEntry = sFactionStore.LookupEntry(atoi(faction.c_str()));
  2902. + if (factionEntry)
  2903. + {
  2904. + std::string name = factionEntry->name[sWorld.GetDefaultDbcLocale()];
  2905. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2 Faction:\x3\x31\x30 %s \xF|\x2 FactionID:\x3\x31\x30 %s",name.c_str(), faction.c_str()), true, CD->TYPE);
  2906. + }
  2907. + else
  2908. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown FactionID." ,true, "ERROR");
  2909. +
  2910. + }
  2911. + else
  2912. + {
  2913. + uint32 counter = 0;
  2914. + std::string factions = "\002Faction Search Results:\x3\x31\x30 ";
  2915. + for (uint32 id = 0; id < sFactionStore.GetNumRows(); id++)
  2916. + {
  2917. + FactionEntry const *factionEntry = sFactionStore.LookupEntry(id);
  2918. + if (factionEntry)
  2919. + {
  2920. + MakeLower( _PARAMS[1] );
  2921. + std::string name = factionEntry->name[sWorld.GetDefaultDbcLocale()];
  2922. + MakeLower( name );
  2923. + if (name.find(_PARAMS[1]) != std::string::npos && counter < 10)
  2924. + {
  2925. + char factionid[100];
  2926. + sprintf(factionid, "%d", id);
  2927. + factions.append(name+"("+factionid+")\xF | \x3\x31\x30\x2");
  2928. + ++counter;
  2929. + }
  2930. + }
  2931. + }
  2932. + if (counter == 0)
  2933. + factions.append("No Factions Found.");
  2934. + Send_IRCA(ChanOrPM(CD), factions, true, CD->TYPE);
  2935. + }
  2936. + }
  2937. + if (_PARAMS[0] == "go")
  2938. + {
  2939. + std::string gobject = _PARAMS[1];
  2940. + if (atoi(gobject.c_str()) > 0)
  2941. + {
  2942. + WorldDatabase.escape_string(_PARAMS[1]);
  2943. + QueryResult *result = WorldDatabase.PQuery("SELECT entry, type, displayId, name, faction, (SELECT count(*) FROM gameobject WHERE id = '%s') as spawns FROM gameobject_template WHERE entry = '%s';", _PARAMS[1].c_str(), _PARAMS[1].c_str());
  2944. + if (result)
  2945. + {
  2946. + Field *fields = result->Fetch();
  2947. +
  2948. + uint32 entry = fields[0].GetUInt32();
  2949. + uint32 type = fields[1].GetUInt32();
  2950. + uint32 modelid = fields[2].GetUInt32();
  2951. + std::string name = fields[3].GetCppString();
  2952. + uint32 faction = fields[4].GetUInt32();
  2953. + uint32 spawns = fields[5].GetUInt32();
  2954. + delete result;
  2955. +
  2956. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2GO Name:\x3\x31\x30 %s \xF|\x2 GameobjectID:\x3\x31\x30 %d \xF|\x2 DisplayID:\x3\x31\x30 %d \xF|\x2 Spawns:\x3\x31\x30 %d", name.c_str(), entry, modelid, spawns), true, CD->TYPE);
  2957. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Type:\x3\x31\x30 %d \xF|\x2 Faction:\x3\x31\x30 %d", type, faction), true, CD->TYPE);
  2958. + }
  2959. + else
  2960. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Creature ID." ,true, "ERROR");
  2961. + }
  2962. + else
  2963. + {
  2964. + QueryResult *result = WorldDatabase.PQuery("SELECT entry, name FROM gameobject_template WHERE name LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str());
  2965. + if (result)
  2966. + {
  2967. + Field *fields = result->Fetch();
  2968. + std::string gos = "\002Gameobject Search Results:\x3\x31\x30 ";
  2969. + for (uint64 i=0; i < result->GetRowCount(); i++)
  2970. + {
  2971. + std::string GOID = fields[0].GetCppString();
  2972. + std::string GoName = fields[1].GetCppString();
  2973. + gos.append(GoName+"("+GOID+")\xF | \x3\x31\x30\x2");
  2974. + result->NextRow();
  2975. + }
  2976. + delete result;
  2977. + Send_IRCA(ChanOrPM(CD), gos, true, CD->TYPE);
  2978. + }
  2979. + else
  2980. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Game Object. I Cant Find Any Game Object's With Those Search Terms." ,true, "ERROR");
  2981. + }
  2982. + }
  2983. + if (_PARAMS[0] == "item")
  2984. + {
  2985. + std::string item = _PARAMS[1];
  2986. + if (atoi(item.c_str()) > 0)
  2987. + {
  2988. + QueryResult *result = WorldDatabase.PQuery("SELECT entry, name, displayid, (SELECT count(*) FROM creature_loot_template WHERE item = '%s') as loot FROM `item_template` WHERE entry = %s", _PARAMS[1].c_str(), _PARAMS[1].c_str());
  2989. + if (result)
  2990. + {
  2991. + Field *fields = result->Fetch();
  2992. + QueryResult *result2 = CharacterDatabase.PQuery("SELECT count(*) FROM `character_inventory` WHERE item_template = %s", _PARAMS[1].c_str());
  2993. + Field *fields2 = result2->Fetch();
  2994. + uint32 charcnt = fields2[0].GetUInt32();
  2995. + delete result2;
  2996. +
  2997. + uint32 ItemID = fields[0].GetUInt32();
  2998. + std::string ItmName = fields[1].GetCppString();
  2999. + uint32 DisplayID = fields[2].GetUInt32();
  3000. + uint32 loots = 0;
  3001. + loots = fields[3].GetUInt32();
  3002. + delete result;
  3003. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Item:\x3\x31\x30 %s \xF|\x2 ItemID:\x3\x31\x30 %d \xF|\x2 DisplayID:\x3\x31\x30 %d \xF|\x2 Owned By:\x3\x31\x30 %d players \xF|\x2 Dropped By:\x3\x31\x30 %d creatures", ItmName.c_str(), ItemID, DisplayID, charcnt, loots), true, CD->TYPE);
  3004. + }
  3005. + else
  3006. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown ItemID." ,true, "ERROR");
  3007. + }
  3008. + else
  3009. + {
  3010. + QueryResult *result = WorldDatabase.PQuery("SELECT entry, name FROM `item_template` WHERE name LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str());
  3011. + if (result)
  3012. + {
  3013. + Field *fields = result->Fetch();
  3014. + std::string items = "\002Item Search Results:\x3\x31\x30 ";
  3015. + for (uint64 i=0; i < result->GetRowCount(); i++)
  3016. + {
  3017. + std::string ItemID = fields[0].GetCppString();
  3018. + std::string ItemName = fields[1].GetCppString();
  3019. + items.append(ItemName+"("+ItemID+")\xF | \x3\x31\x30\x2");
  3020. + result->NextRow();
  3021. + }
  3022. + delete result;
  3023. + Send_IRCA(ChanOrPM(CD), items, true, CD->TYPE);
  3024. + }
  3025. + else
  3026. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Item. I Cant Find Any Items With Those Search Terms." ,true, "ERROR");
  3027. + }
  3028. + }
  3029. + if (_PARAMS[0] == "quest")
  3030. + {
  3031. + std::string quest = _PARAMS[1];
  3032. + if (atoi(quest.c_str()) > 0)
  3033. + {
  3034. + WorldDatabase.escape_string(_PARAMS[1]);
  3035. + QueryResult *result = WorldDatabase.PQuery("SELECT entry, Title FROM quest_template WHERE entry = '%s';", _PARAMS[1].c_str(), _PARAMS[1].c_str());
  3036. + if (result)
  3037. + {
  3038. + QueryResult *result2 = CharacterDatabase.PQuery("SELECT count(*) FROM character_queststatus WHERE quest = '%s' AND status = '1';", _PARAMS[1].c_str());
  3039. + Field *fields2 = result2->Fetch();
  3040. + uint32 status = fields2[0].GetUInt32();
  3041. + delete result2;
  3042. +
  3043. + Field *fields = result->Fetch();
  3044. + uint32 entry = fields[0].GetUInt32();
  3045. + std::string name = fields[1].GetCppString();
  3046. + delete result;
  3047. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Quest Name:\x3\x31\x30 %s \xF|\x2 QuestID:\x3\x31\x30 %d \xF|\x2 Completed:\x3\x31\x30 %d times", name.c_str(), entry, status), true, CD->TYPE);
  3048. + }
  3049. + else
  3050. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Quest ID." ,true, "ERROR");
  3051. + }
  3052. + else
  3053. + {
  3054. + QueryResult *result = WorldDatabase.PQuery("SELECT entry, Title FROM quest_template WHERE Title LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str());
  3055. + if (result)
  3056. + {
  3057. + Field *fields = result->Fetch();
  3058. + std::string quests = "\002Quest Search Results:\x3\x31\x30 ";
  3059. + //Send_IRCA(ChanOrPM(CD), "", true, CD->TYPE);
  3060. + for (uint64 i=0; i < result->GetRowCount(); i++)
  3061. + {
  3062. + std::string QuestID = fields[0].GetCppString();
  3063. + std::string QuestName = fields[1].GetCppString();
  3064. + quests.append(QuestName+"("+QuestID+")\xF | \x3\x31\x30\x2");
  3065. + result->NextRow();
  3066. + }
  3067. + delete result;
  3068. + Send_IRCA(ChanOrPM(CD), quests, true, CD->TYPE);
  3069. + }
  3070. + else
  3071. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Quest. I Cant Find Any Quest's With Those Search Terms." ,true, "ERROR");
  3072. + }
  3073. + }
  3074. + if (_PARAMS[0] == "skill")
  3075. + {
  3076. + std::string skill = _PARAMS[1];
  3077. + if (atoi(skill.c_str()) > 0)
  3078. + {
  3079. + SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(atoi(skill.c_str()));
  3080. + if (skillInfo)
  3081. + {
  3082. + std::string name = skillInfo->name[sWorld.GetDefaultDbcLocale()];
  3083. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Skill:\x3\x31\x30 %s \xF|\x2 SkillID:\x3\x31\x30 %s",name.c_str(), skill.c_str()), true, CD->TYPE);
  3084. + }
  3085. + else
  3086. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown SkillID." ,true, "ERROR");
  3087. +
  3088. + }
  3089. + else
  3090. + {
  3091. + uint32 counter = 0;
  3092. + std::string skills = "\002Skill Search Results:\x3\x31\x30 ";
  3093. + for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++)
  3094. + {
  3095. + SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(id);
  3096. + if (skillInfo)
  3097. + {
  3098. + MakeLower( _PARAMS[1] );
  3099. + std::string name = skillInfo->name[sWorld.GetDefaultDbcLocale()];
  3100. + MakeLower( name );
  3101. + if (name.find(_PARAMS[1]) != std::string::npos && counter < 10)
  3102. + {
  3103. + char skillid[100];
  3104. + sprintf(skillid, "%d", id);
  3105. + skills.append(name+"("+skillid+")\xF | \x3\x31\x30\x2");
  3106. + ++counter;
  3107. + }
  3108. + }
  3109. + }
  3110. + if (counter == 0)
  3111. + skills.append("No Skills Found.");
  3112. + Send_IRCA(ChanOrPM(CD), skills, true, CD->TYPE);
  3113. + }
  3114. + }
  3115. + if (_PARAMS[0] == "spell")
  3116. + {
  3117. + std::string spell = _PARAMS[1];
  3118. + if (atoi(spell.c_str()) > 0)
  3119. + {
  3120. + SpellEntry const *spellInfo = sSpellStore.LookupEntry(atoi(spell.c_str()));
  3121. + if (spellInfo)
  3122. + {
  3123. + std::string name = spellInfo->SpellName[sWorld.GetDefaultDbcLocale()];
  3124. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Spell:\x3\x31\x30 %s \xF|\x2 SpellID:\x3\x31\x30 %s",name.c_str(), spell.c_str()), true, CD->TYPE);
  3125. + }
  3126. + else
  3127. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown SpellID." ,true, "ERROR");
  3128. +
  3129. + }
  3130. + else
  3131. + {
  3132. + uint32 counter = 0;
  3133. + std::string spells = "\002Spell Search Results:\x3\x31\x30 ";
  3134. + for (uint32 id = 0; id < sSpellStore.GetNumRows(); id++)
  3135. + {
  3136. + SpellEntry const *spellInfo = sSpellStore.LookupEntry(id);
  3137. + if (spellInfo)
  3138. + {
  3139. + MakeLower( _PARAMS[1] );
  3140. + std::string name = spellInfo->SpellName[sWorld.GetDefaultDbcLocale()];
  3141. + MakeLower( name );
  3142. + if (name.find(_PARAMS[1]) != std::string::npos && counter < 10)
  3143. + {
  3144. + char itemid[100];
  3145. + sprintf(itemid, "%d", id);
  3146. + spells.append(name+"("+itemid+")\xF | \x3\x31\x30\x2");
  3147. + ++counter;
  3148. + }
  3149. + }
  3150. + }
  3151. + if (counter == 0)
  3152. + spells.append("No Spells Found.");
  3153. + Send_IRCA(ChanOrPM(CD), spells, true, CD->TYPE);
  3154. + }
  3155. + }
  3156. + if (_PARAMS[0] == "tele")
  3157. + {
  3158. + std::string tele = _PARAMS[1];
  3159. + if (atoi(tele.c_str()) > 0)
  3160. + {
  3161. + QueryResult *result = WorldDatabase.PQuery("SELECT * FROM `game_tele` WHERE id = %s", _PARAMS[1].c_str());
  3162. + if (result)
  3163. + {
  3164. + Field *fields = result->Fetch();
  3165. +
  3166. + uint32 teleid = fields[0].GetUInt32();
  3167. + uint32 pos_x = fields[1].GetUInt32();
  3168. + uint32 pos_y = fields[2].GetUInt32();
  3169. + uint32 pos_z = fields[3].GetUInt32();
  3170. + uint32 oriet = fields[4].GetUInt32();
  3171. + uint32 map = fields[5].GetUInt32();
  3172. + std::string telname = fields[6].GetCppString();
  3173. + delete result;
  3174. +
  3175. + Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Tele Name:\x3\x31\x30 %s \xF|\x2 TeleID:\x3\x31\x30 %d \xF|\x2 Coordinates:\x3\x31\x30 [X: %d, Y: %d, Z: %d, MAP: %d, Orientation: %d]", telname.c_str(), teleid, pos_x, pos_y, pos_z, map, oriet), true, CD->TYPE);
  3176. + }
  3177. + else
  3178. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Teleport Location ID." ,true, "ERROR");
  3179. + }
  3180. + else
  3181. + {
  3182. + QueryResult *result = WorldDatabase.PQuery("SELECT id, name FROM `game_tele` WHERE name LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str());
  3183. + if (result)
  3184. + {
  3185. + Field *fields = result->Fetch();
  3186. + std::string teles = "\002Tele Location Search Results:\x3\x31\x30 ";
  3187. + for (uint64 i=0; i < result->GetRowCount(); i++)
  3188. + {
  3189. + std::string TeleID = fields[0].GetCppString();
  3190. + std::string TeleName = fields[1].GetCppString();
  3191. + teles.append(TeleName+"("+TeleID+")\xF | \x3\x31\x30\x2");
  3192. + result->NextRow();
  3193. + }
  3194. + Send_IRCA(ChanOrPM(CD), teles, true, CD->TYPE);
  3195. + delete result;
  3196. + }
  3197. + else
  3198. + Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Item. I Cant Find Any Items With Those Search Terms." ,true, "ERROR");
  3199. + }
  3200. + }
  3201. +}
  3202. +
  3203. +void IRCCmd::Sysmsg_Server(_CDATA *CD)
  3204. +{
  3205. + std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT);
  3206. + std::string ircchan = "#";
  3207. + ircchan += sIRC._irc_chan[sIRC.anchn].c_str();
  3208. + if(_PARAMS[0] == "a")
  3209. + {
  3210. + std::string str = _PARAMS[1];
  3211. + std::string ancmsg = MakeMsg("\00304,08\037/!\\\037\017\00304 Server Announcement \00304,08\037/!\\\037\017 %s",_PARAMS[1].c_str());
  3212. + sWorld.SendWorldText(LANG_SYSTEMMESSAGE,str.c_str());
  3213. + sIRC.Send_IRC_Channel(ircchan, ancmsg, true);
  3214. + }
  3215. + else if (_PARAMS[0] == "e")
  3216. + {
  3217. + std::string str = _PARAMS[1];
  3218. + std::string notstr = "[Server Event]: " + _PARAMS[1];
  3219. + std::string notmsg = MakeMsg("\00304,08\037/!\\\037\017\00304 Game Event \00304,08\037/!\\\037\017 %s",_PARAMS[1].c_str());
  3220. + sWorld.SendWorldText(LANG_EVENTMESSAGE,str.c_str());
  3221. + sIRC.Send_IRC_Channel(ircchan, notmsg, true);
  3222. + }
  3223. + else if (_PARAMS[0] == "n")
  3224. + {
  3225. + std::string str = "Global notify: " + _PARAMS[1];
  3226. + std::string notmsg = MakeMsg("\00304,08\037/!\\\037\017\00304 Global Notify \00304,08\037/!\\\037\017 %s",_PARAMS[1].c_str());
  3227. + WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
  3228. + data << str;
  3229. + sWorld.SendGlobalMessage(&data);
  3230. + sIRC.Send_IRC_Channel(ircchan, notmsg, true);
  3231. + }
  3232. + /* NOT WORKING!!
  3233. + else if (_PARAMS[0] == "add")
  3234. + {
  3235. + WorldDatabase.PExecute( "INSERT INTO IRC_AutoAnnounce (message, addedby) VALUES ('%s', '%s')", _PARAMS[1].c_str(), CD->USER.c_str());
  3236. + std::string str = _PARAMS[1];
  3237. + std::string ancmsg = MakeMsg("\00304,08\037/!\\\037\017\00304 Server Information \00304,08\037/!\\\037\017 %s",_PARAMS[1].c_str());
  3238. + sWorld.SendWorldText(3000,str.c_str());
  3239. + sIRC.Send_IRC_Channel(ircchan, ancmsg, true);
  3240. + }
  3241. + else if (_PARAMS[0] == "del")
  3242. + {
  3243. + WorldDatabase.PExecute( "DELETE FROM IRC_AutoAnnounce WHERE id = %s", _PARAMS[1].c_str());
  3244. + Send_IRCA(ChanOrPM(CD), MakeMsg("Deleted Automatic Announcement Message ID: %s", _PARAMS[1].c_str()), true, CD->TYPE);
  3245. + }
  3246. + else if (_PARAMS[0] == "list")
  3247. + {
  3248. + QueryResult *result = WorldDatabase.PQuery("SELECT * FROM IRC_AutoAnnounce LIMIT 5;", _PARAMS[1].c_str());
  3249. + if(result)
  3250. + {
  3251. + Field *fields = result->Fetch();
  3252. + for (uint64 i=0; i < result->GetRowCount(); i++)
  3253. + {
  3254. + std::string id = fields[0].GetCppString();
  3255. + std::string message = fields[1].GetCppString();
  3256. + std::string addedby = fields[2].GetCppString();
  3257. + Send_IRCA(ChanOrPM(CD), MakeMsg("ID: %s - Added By: %s - Message: %s", id.c_str(), addedby.c_str(), message.c_str()), true, CD->TYPE);
  3258. + result->NextRow();
  3259. + }
  3260. + delete result;
  3261. + }
  3262. + else
  3263. + Send_IRCA(CD->USER, "\0034[ERROR] : No Auto Announce Messages Are In The Database.", true, "ERROR");
  3264. + }*/
  3265. + else
  3266. + Send_IRCA(CD->USER, "\0034[ERROR] : Please Use (a-Announce)(n-Notify)(e-Event) As Second Parameter!", true, "ERROR");
  3267. +}
  3268. +
  3269. +void IRCCmd::Level_Player(_CDATA *CD)
  3270. +{
  3271. + std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT);
  3272. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  3273. + {
  3274. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  3275. + return;
  3276. + }
  3277. + std::string player = _PARAMS[0];
  3278. + normalizePlayerName(player);
  3279. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(player.c_str());
  3280. + std::string s_newlevel = _PARAMS[1];
  3281. + uint8 i_newlvl = atoi(s_newlevel.c_str());
  3282. + if (guid.IsEmpty())
  3283. + {
  3284. + Send_IRCA(CD->USER, "\0034[ERROR] : Player Not Found!", true, "ERROR");
  3285. + return;
  3286. + } else if ( i_newlvl < 1 || i_newlvl > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL) )
  3287. + {
  3288. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Level Must Be Between 1 And %i!",sConfig.GetIntDefault("MaxPlayerLevel", 70)), true, "ERROR");
  3289. + return;
  3290. + } else
  3291. + {
  3292. + Player *chr = sObjectMgr.GetPlayer(guid);
  3293. + int32 i_oldlvl = chr ? chr->getLevel() : Player::GetLevelFromDB(guid);
  3294. + if (chr)
  3295. + {
  3296. + chr->GiveLevel(i_newlvl);
  3297. + chr->InitTalentForLevel();
  3298. + chr->SetUInt32Value(PLAYER_XP,0);
  3299. + WorldPacket data;
  3300. + ChatHandler CH(chr->GetSession());
  3301. + if (i_oldlvl == i_newlvl)
  3302. + CH.FillSystemMessageData(&data, "Your level progress has been reset.");
  3303. + else
  3304. + if (i_oldlvl < i_newlvl)
  3305. + {
  3306. + char temp [32];
  3307. + sprintf(temp, "You have been leveled up (%i)",i_newlvl-i_oldlvl);
  3308. + CH.FillSystemMessageData(&data, temp);
  3309. + }
  3310. + else
  3311. + if (i_oldlvl > i_newlvl)
  3312. + {
  3313. + char temp [34];
  3314. + sprintf(temp, "You have been leveled down (%i)",i_newlvl-i_oldlvl);
  3315. + CH.FillSystemMessageData(&data, temp);
  3316. + }
  3317. + chr->GetSession()->SendPacket( &data );
  3318. + }
  3319. + else
  3320. + {
  3321. + std::ostringstream ss;
  3322. + ss << "UPDATE characters SET level='"<<uint32(i_newlvl)<<"',xp='0' WHERE guid='"<</*GUID_LOPART(guid)*/ chr->GetGUIDLow() <<"'";
  3323. + sLog.outDebug("%s", ss.str().c_str());
  3324. + CharacterDatabase.Execute(ss.str().c_str());
  3325. + }
  3326. + }
  3327. + Send_IRCA(ChanOrPM(CD), "\00313[" + _PARAMS[0]+ "] : Has Been Leveled To " + _PARAMS[1] + ". By: "+CD->USER+".", true, CD->TYPE);
  3328. +}
  3329. +
  3330. +void IRCCmd::Money_Player(_CDATA *CD)
  3331. +{
  3332. + std::string* _PARAMS = getArray(CD->PARAMS, 2);
  3333. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  3334. + {
  3335. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  3336. + return;
  3337. + }
  3338. + std::string player = _PARAMS[0];
  3339. + normalizePlayerName(player);
  3340. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(player.c_str());
  3341. + Player *chr = sObjectMgr.GetPlayer(guid);
  3342. +
  3343. + std::string s_money = _PARAMS[1];
  3344. + int32 money = atoi(s_money.c_str());
  3345. + unsigned int gold = money / 10000;
  3346. + unsigned int silv = (money % 10000) / 100;
  3347. + unsigned int cop = (money % 10000) % 100;
  3348. + char tempgold [100];
  3349. + sprintf(tempgold, "\x2\x3\x30\x37%ug \x3\x31\x34%us \x3\x30\x35%uc\xF", gold, silv, cop);
  3350. + if (guid.IsEmpty())
  3351. + {
  3352. + Send_IRCA(CD->USER, "\0034[ERROR] : Player Not Found!", true, "ERROR");
  3353. + return;
  3354. + }
  3355. + else
  3356. + {
  3357. + Player *chr = sObjectMgr.GetPlayer(guid);
  3358. + uint32 moneyuser = 0;
  3359. + if (chr)
  3360. + moneyuser = chr->GetMoney();
  3361. + else {
  3362. + CharacterDatabase.escape_string(player);
  3363. + std::string sqlquery = "SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ' , 1462), ' ' , -1) AS `gold` FROM `characters` WHERE `name` = '"+player+"';";
  3364. + QueryResult *result = CharacterDatabase.Query(sqlquery.c_str());
  3365. + Field *fields = result->Fetch();
  3366. + moneyuser = fields[0].GetInt32();
  3367. + delete result;
  3368. + }
  3369. + int32 addmoney = money;
  3370. + int32 newmoney = moneyuser + addmoney;
  3371. + char s_newmoney[255];
  3372. + sprintf(s_newmoney,"%d",newmoney);
  3373. + if (addmoney < 0)
  3374. + {
  3375. + sLog.outDetail("USER1: %i, ADD: %i, DIF: %i\\n", moneyuser, addmoney, newmoney);
  3376. + if (newmoney <= 0 )
  3377. + {
  3378. + Send_IRCA(ChanOrPM(CD), "\00313["+player+"] : Has Had All Money Taken By: "+CD->USER.c_str()+".", true, CD->TYPE);
  3379. + if (chr)
  3380. + {
  3381. + chr->SetMoney(0);
  3382. + Send_Player(chr, MakeMsg("You Have Been Liquidated By: %s. Total Money Is Now 0.", CD->USER.c_str()));
  3383. + }
  3384. + else
  3385. + CharacterDatabase.PExecute("UPDATE `characters` SET data=concat(substring_index(data,' ',1462-1),' ','%u',' ', right(data,length(data)-length(substring_index(data,' ',1462))-1) ) where guid='%u'",newmoney, guid.GetCounter() );
  3386. + }
  3387. + else
  3388. + {
  3389. + Send_IRCA(ChanOrPM(CD), "\00313["+player+"] : Has Had ("+s_money+"\00313) Taken From Them By: "+CD->USER.c_str()+".", true, CD->TYPE);
  3390. + if (chr)
  3391. + {
  3392. + chr->SetMoney( newmoney );
  3393. + Send_Player(chr, MakeMsg("You Have Had %s Copper Taken From You By: %s.", _PARAMS[1].c_str(), CD->USER.c_str()));
  3394. + }
  3395. + else
  3396. + CharacterDatabase.PExecute("UPDATE `characters` SET data=concat(substring_index(data,' ',1462-1),' ','%u',' ', right(data,length(data)-length(substring_index(data,' ',1462))-1) ) where guid='%u'",newmoney, guid.GetCounter() );
  3397. + }
  3398. + }
  3399. + else
  3400. + {
  3401. + Send_IRCA(ChanOrPM(CD), "\00313["+player+"] : Has Been Given ("+tempgold+"\00313) From: "+CD->USER.c_str()+".", true, CD->TYPE);
  3402. + if (chr)
  3403. + {
  3404. + chr->ModifyMoney( addmoney );
  3405. + Send_Player(chr, MakeMsg("You Have Been Given %s Copper. From: %s.", _PARAMS[1].c_str(), CD->USER.c_str()));
  3406. + }
  3407. + else
  3408. + CharacterDatabase.PExecute("UPDATE `characters` SET data=concat(substring_index(data,' ',1462-1),' ','%u',' ', right(data,length(data)-length(substring_index(data,' ',1462))-1) ) where guid='%u'",newmoney, guid.GetCounter() );
  3409. + }
  3410. + }
  3411. +}
  3412. +
  3413. +void IRCCmd::Mute_Player(_CDATA *CD)
  3414. +{
  3415. + std::string* _PARAMS = getArray(CD->PARAMS, 3);
  3416. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  3417. + {
  3418. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  3419. + return;
  3420. + }
  3421. + normalizePlayerName(_PARAMS[0]);
  3422. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(_PARAMS[0]);
  3423. + if (!guid.IsEmpty())
  3424. + {
  3425. + if (_PARAMS[1] == "release")
  3426. + {
  3427. + Player* plr = sObjectMgr.GetPlayer(guid);
  3428. + uint32 account_id = 0;
  3429. + account_id = sObjectMgr.GetPlayerAccountIdByGUID(guid);
  3430. + LoginDatabase.PExecute("UPDATE `account` SET `mutetime` = '0' WHERE `id` = '%u'", account_id );
  3431. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Been UnMuted By: "+CD->USER+"." , true, CD->TYPE);
  3432. + if (plr)
  3433. + {
  3434. + plr->GetSession()->m_muteTime = 0;
  3435. + Send_Player(plr, MakeMsg("You Have Been UnMuted By: %s.", CD->USER.c_str()));
  3436. + }
  3437. + }
  3438. + else
  3439. + {
  3440. + if (_PARAMS[2] == "")
  3441. + _PARAMS[2] = "No Reason Given";
  3442. + Player* plr = sObjectMgr.GetPlayer(guid);
  3443. + time_t mutetime = time(NULL) + atoi(_PARAMS[1].c_str())*60;
  3444. + uint32 account_id = 0;
  3445. + account_id = sObjectMgr.GetPlayerAccountIdByGUID(guid);
  3446. + if (plr) plr->GetSession()->m_muteTime = mutetime;
  3447. + LoginDatabase.PExecute("UPDATE `account` SET `mutetime` = " UI64FMTD " WHERE `id` = '%u'",uint64(mutetime), account_id );
  3448. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Been Muted By: "+CD->USER+". For: "+_PARAMS[1]+" Minutes. Reason: "+_PARAMS[2] , true, CD->TYPE);
  3449. + if (plr) Send_Player(plr, MakeMsg("You Have Been Muted By: %s. For: %s Minutes. Reason: %s", CD->USER.c_str(), _PARAMS[1].c_str(), _PARAMS[2].c_str()));
  3450. + }
  3451. + }
  3452. + else
  3453. + Send_IRCA(CD->USER, "\0034[ERROR] : Player Does Not Exist!", true, "ERROR");
  3454. +}
  3455. +
  3456. +void IRCCmd::Online_Players(_CDATA *CD)
  3457. +{
  3458. + sIRC.Script_Lock[MCS_Players_Online] = true;
  3459. + ACE_Based::Thread script(new mcs_OnlinePlayers(CD));
  3460. +}
  3461. +
  3462. +void IRCCmd::PM_Player(_CDATA *CD)
  3463. +{
  3464. + std::string* _PARAMS = getArray(CD->PARAMS, 2);
  3465. + if (Player* plr = GetPlayer(_PARAMS[0]))
  3466. + {
  3467. + if (plr->isAcceptWhispers())
  3468. + {
  3469. + std::string sMsg = MakeMsg("|cffFE87FD[<IRC>%s] Whispers: %s|r", CD->USER.c_str(), _PARAMS[1].c_str());
  3470. + Send_Player(plr, sMsg);
  3471. + plr->PlayDistanceSound(3081);
  3472. + Send_IRCA(ChanOrPM(CD), "\00313To ["+_PARAMS[0]+"] : "+_PARAMS[1]+".", true, CD->TYPE);
  3473. + }
  3474. + else
  3475. + Send_IRCA(CD->USER, "\0034[ERROR] : Is Not Accepting Private Messages!", true, "ERROR");
  3476. + }
  3477. + else
  3478. + Send_IRCA(CD->USER, "\0034[ERROR] : Player not online!", true, "ERROR");
  3479. +}
  3480. +
  3481. +void IRCCmd::Revive_Player(_CDATA *CD)
  3482. +{
  3483. + std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT);
  3484. + if (Player* plr = GetPlayer(_PARAMS[0]))
  3485. + {
  3486. + if (plr->isDead())
  3487. + {
  3488. + plr->ResurrectPlayer(0.5f);
  3489. + plr->SpawnCorpseBones();
  3490. + plr->SaveToDB();
  3491. + sIRC.Send_IRC_Channel(ChanOrPM(CD), " \00313["+_PARAMS[0]+"] : Has Been Revived By: " + CD->USER, true, CD->TYPE);
  3492. + Send_Player(plr, MakeMsg("You Have Been Revived By: %s.", CD->USER.c_str()));
  3493. + }
  3494. + else
  3495. + Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Dead!", true, "ERROR");
  3496. + }
  3497. + else
  3498. + Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Online!", true, "ERROR");
  3499. +}
  3500. +
  3501. +void IRCCmd::Saveall_Player(_CDATA *CD)
  3502. +{
  3503. + ObjectAccessor::Instance().SaveAllPlayers();
  3504. + Send_IRCA(ChanOrPM(CD), "\00313["+CD->USER+"] : Has Saved All Players!", true, CD->TYPE);
  3505. +}
  3506. +
  3507. +void IRCCmd::Shutdown_Mangos(_CDATA *CD)
  3508. +{
  3509. + std::string* _PARAMS = getArray(CD->PARAMS, 1);
  3510. + if (_PARAMS[0] == "cancel")
  3511. + {
  3512. + sWorld.ShutdownCancel();
  3513. + Send_IRCA(ChanOrPM(CD), "\0034Server Shutdown Has Been Cancelled.", true, CD->TYPE);
  3514. + }
  3515. +
  3516. + int32 i_time = atoi(_PARAMS[0].c_str());
  3517. + if (i_time <= 0 && _PARAMS[0]!="0")
  3518. + {
  3519. + Send_IRCA(ChanOrPM(CD), "\00313["+CD->USER+"] : Please Enter A Number! And No Negative Numbers! "+_PARAMS[0]+" Seconds!?", true, CD->TYPE);
  3520. + return;
  3521. + }
  3522. + if (i_time > 1) Send_IRCA(ChanOrPM(CD), "\00313["+CD->USER+"] : Has Requested Server To Be Shut Down In "+_PARAMS[0]+" Seconds!", true, CD->TYPE);
  3523. + sWorld.ShutdownServ(i_time, 0, 0);
  3524. + Delay(i_time*1000);
  3525. + Send_IRCA(ChanOrPM(CD), "\0034Server Will Now Shut Down.. Good Bye!", true, CD->TYPE);
  3526. + sIRC.Active = false;
  3527. + sIRC.ResetIRC();
  3528. +}
  3529. +
  3530. +void IRCCmd::Spell_Player(_CDATA *CD)
  3531. +{
  3532. + std::string* _PARAMS = getArray(CD->PARAMS, 3);
  3533. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  3534. + {
  3535. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  3536. + return;
  3537. + }
  3538. + uint32 spell = atoi(_PARAMS[2].c_str());
  3539. + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell);
  3540. + if (Player* plr = GetPlayer(_PARAMS[0]))
  3541. + {
  3542. + if (spellInfo)
  3543. + {
  3544. + std::string name = spellInfo->SpellName[sWorld.GetDefaultDbcLocale()];
  3545. + if (_PARAMS[1] == "cast")
  3546. + {
  3547. + plr->CastSpell(plr, spell, true);
  3548. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Had Spell "+name+" Casted On Them.", true, CD->TYPE);
  3549. + }
  3550. + if (_PARAMS[1] == "learn")
  3551. + {
  3552. + plr->learnSpell(spell,false);
  3553. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Learned Spell "+name+".", true, CD->TYPE);
  3554. + }
  3555. + if (_PARAMS[1] == "unlearn")
  3556. + {
  3557. + plr->removeSpell(spell);
  3558. + Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Unlearned Spell "+name+".", true, CD->TYPE);
  3559. + }
  3560. + }
  3561. + else
  3562. + Send_IRCA(CD->USER, "\0034[ERROR] : Incorrect Spell ID!", true, "ERROR");
  3563. + }
  3564. + else
  3565. + Send_IRCA(CD->USER, "\0034[ERROR] : Player Not Online!", true, "ERROR");
  3566. +}
  3567. +
  3568. +void IRCCmd::Tele_Player(_CDATA *CD)
  3569. +{
  3570. + std::string* _PARAMS = getArray(CD->PARAMS, 4);
  3571. + if (AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512))
  3572. + {
  3573. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR");
  3574. + return;
  3575. + }
  3576. + bool DoTeleport = false;
  3577. + float pX, pY, pZ, pO = 0;
  3578. + uint32 mapid = 0;
  3579. + std::string rMsg = " \0034[ERROR] : Teleport Failed!";
  3580. + std::string wMsg = "Invalid Tele Location";
  3581. + Player* plr = GetPlayer(_PARAMS[0]);
  3582. + if (plr)
  3583. + {
  3584. + if (plr->IsTaxiFlying() || plr->isInCombat())
  3585. + {
  3586. + Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : %s Is Busy And Cannot Be Teleported! They Could Be In Combat, Or Flying.",_PARAMS[0].c_str()), true, "ERROR");
  3587. + return;
  3588. + }
  3589. + }
  3590. + if (_PARAMS[1] == "l" || _PARAMS[1].size() > 2)
  3591. + {
  3592. + if (_PARAMS[1].size() > 1)
  3593. + _PARAMS[2] = _PARAMS[1];
  3594. + WorldDatabase.escape_string(_PARAMS[2]);
  3595. + QueryResult *result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map FROM game_tele WHERE name='%s';", _PARAMS[2].c_str());
  3596. + if (result)
  3597. + {
  3598. + Field *fields = result->Fetch();
  3599. + pX = fields[0].GetFloat();
  3600. + pY = fields[1].GetFloat();
  3601. + pZ = fields[2].GetFloat();
  3602. + pO = fields[3].GetFloat();
  3603. + mapid = fields[4].GetUInt16();
  3604. + delete result;
  3605. + rMsg = MakeMsg(" \00313[%s] : Teleported To %s! By: %s.",
  3606. + _PARAMS[0].c_str(),
  3607. + _PARAMS[2].c_str(),
  3608. + CD->USER.c_str());
  3609. + wMsg = MakeMsg("You Have Been Teleported To %s By: %s.",
  3610. + _PARAMS[2].c_str(),
  3611. + CD->USER.c_str());
  3612. + DoTeleport = true;
  3613. + }
  3614. + else
  3615. + {
  3616. + WorldDatabase.escape_string(_PARAMS[2]);
  3617. + QueryResult *result = WorldDatabase.PQuery("SELECT name FROM game_tele WHERE name LIKE '%%%s%%' LIMIT 7;", _PARAMS[2].c_str());
  3618. + if (result)
  3619. + {
  3620. + std::string telename = "<> ";
  3621. + for (uint64 i=0; i < result->GetRowCount(); i++)
  3622. + {
  3623. + Field *fields = result->Fetch();
  3624. + telename.append(fields[0].GetCppString());
  3625. + result->NextRow();
  3626. + telename.append(" <> ");
  3627. + }
  3628. + delete result;
  3629. + Send_IRCA(CD->USER, "I Cannot Find Location: "+_PARAMS[2]+" . Perhaps One Of These Will Work For You.", true, "ERROR");
  3630. + Send_IRCA(CD->USER, telename, true, "ERROR");
  3631. + return;
  3632. + }
  3633. + else
  3634. + Send_IRCA(CD->USER, "\0034[ERROR] : Location Not Found! Nothing Even Close Found!", true, "ERROR");
  3635. + return;
  3636. + }
  3637. + }
  3638. + else if (_PARAMS[1] == "c")
  3639. + {
  3640. + std::string* _PARAMSA = getArray(_PARAMS[2], 4);
  3641. + pX = atof(_PARAMSA[1].c_str());
  3642. + pY = atof(_PARAMSA[2].c_str());
  3643. + pZ = atof(_PARAMSA[3].c_str());
  3644. + mapid = atoi(_PARAMSA[0].c_str());
  3645. + rMsg = MakeMsg(" \00313[%s] : Teleported To Map: %s. Position: X(%s) Y(%s) Z(%s)! By: %s.",
  3646. + _PARAMS[0].c_str(),
  3647. + _PARAMSA[0].c_str(),
  3648. + _PARAMSA[1].c_str(),
  3649. + _PARAMSA[2].c_str(),
  3650. + _PARAMSA[3].c_str(),
  3651. + CD->USER.c_str());
  3652. + wMsg = MakeMsg("You Have Been Teleported To Map: %s. Position: X(%s) Y(%s) Z(%s)! By: %s.",
  3653. + _PARAMSA[0].c_str(),
  3654. + _PARAMSA[1].c_str(),
  3655. + _PARAMSA[2].c_str(),
  3656. + _PARAMSA[3].c_str(),
  3657. + CD->USER.c_str());
  3658. + DoTeleport = true;
  3659. + }
  3660. + else if (_PARAMS[1] == "r")
  3661. + {
  3662. + if (plr)
  3663. + {
  3664. + pX = plr->m_recallX;
  3665. + pY = plr->m_recallY;
  3666. + pZ = plr->m_recallZ;
  3667. + pO = plr->m_recallO;
  3668. + mapid = plr->m_recallMap;
  3669. + rMsg = MakeMsg(" \00313[%s] : Has Been Recalled To Their Previous Location.",
  3670. + _PARAMS[0].c_str());
  3671. + wMsg = MakeMsg("You Have Been Recalled To Your Previous Location. By: %s",
  3672. + CD->USER.c_str());
  3673. + DoTeleport = true;
  3674. + }
  3675. + else
  3676. + {
  3677. + Send_IRCA(CD->USER, MakeMsg("\00313[%s] : Cannot Be Recalled, They Are Not Online.", _PARAMS[0].c_str()), true, "ERROR");
  3678. + return;
  3679. + }
  3680. +
  3681. + }
  3682. + else if (_PARAMS[1] == "to")
  3683. + {
  3684. + if (!plr)
  3685. + {
  3686. + Send_IRCA(CD->USER, "\0034[ERROR] First Player Not Online! Offline Tele Not Supported For 'to'.", true, "ERROR");
  3687. + return;
  3688. + }
  3689. + Player* plr2 = GetPlayer(_PARAMS[2]);
  3690. + if (plr2)
  3691. + {
  3692. + plr2->GetContactPoint(plr, pX, pY, pZ);
  3693. + mapid = plr2->GetMapId();
  3694. + }
  3695. + else
  3696. + {
  3697. + if (!sObjectMgr.GetPlayerGuidByName(_PARAMS[2].c_str()).IsEmpty())
  3698. + {
  3699. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(_PARAMS[2].c_str());
  3700. + bool in_flight;
  3701. + Player::LoadPositionFromDB(guid,mapid, pX, pY, pZ, pO, in_flight);
  3702. + }
  3703. + else
  3704. + {
  3705. + Send_IRCA(CD->USER, "\0034[ERROR] : Second Player Not Found!", true, "ERROR");
  3706. + return;
  3707. + }
  3708. + }
  3709. + rMsg = MakeMsg(" \00313[%s] : Teleported To Player: [%s] By: %s.",
  3710. + _PARAMS[0].c_str(),
  3711. + _PARAMS[2].c_str(),
  3712. + CD->USER.c_str());
  3713. + wMsg = MakeMsg("You Are Being Teleported To: %s. By: %s.",
  3714. + _PARAMS[2].c_str(),
  3715. + CD->USER.c_str());
  3716. + DoTeleport = true;
  3717. + }
  3718. + if (DoTeleport)
  3719. + {
  3720. + if (MapManager::IsValidMapCoord(mapid, pX ,pY))
  3721. + {
  3722. + //NOTE: Removed "BeenToGMI" due to back overflows caused with new packet structure (Shinzon)
  3723. +
  3724. + // if(!sIRC.BeenToGMI(pX, pY, _PARAMS[0], CD->USER))
  3725. + // {
  3726. + // if player is online teleport them in real time, if not set the DB to our coordinates.
  3727. + if (plr)
  3728. + {
  3729. + plr->SaveRecallPosition();
  3730. + plr->TeleportTo(mapid, pX, pY, pZ, pO);
  3731. + sIRC.Send_IRC_Channel(ChanOrPM(CD), rMsg, true, CD->TYPE);
  3732. + Send_Player(plr, wMsg);
  3733. + sIRC.Send_WoW_Channel(sIRC._wow_chan[1].c_str(), IRCCmd::MakeMsg("|cffffff21 %s : Teleported To %s. By: %s.|r", _PARAMS[0].c_str(), _PARAMS[2].c_str(), CD->USER.c_str()));
  3734. + }
  3735. + else
  3736. + {
  3737. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(_PARAMS[0]);
  3738. + Player::SavePositionInDB(guid,mapid,pX,pY,pZ,pO,TerrainManager::Instance().GetZoneId(mapid,pX,pY,pZ));
  3739. + sIRC.Send_IRC_Channel(ChanOrPM(CD), rMsg + " \0034*Offline Tele.* ", true, CD->TYPE);
  3740. + }
  3741. + // }
  3742. + }
  3743. + else
  3744. + Send_IRCA(CD->USER, "\0034[ERROR] : Invalid Location!", true, "ERROR");
  3745. + }
  3746. + else
  3747. + Send_IRCA(CD->USER, "\0034[ERROR] : Invalid Paramaters, Please Try Again [ "+sIRC._cmd_prefx+"help tele ] For More Information. ", true, "ERROR");
  3748. +}
  3749. +
  3750. +void IRCCmd::Top_Player(_CDATA *CD)
  3751. +{
  3752. + std::string* _PARAMS = getArray(CD->PARAMS, 2);
  3753. + uint32 limitr = 10;
  3754. + if (atoi(_PARAMS[1].c_str()) > 0 && GetLevel(CD->USER) >= sIRC._op_gm_lev)
  3755. + limitr = atoi(_PARAMS[1].c_str());
  3756. + if (_PARAMS[0] == "accttime")
  3757. + {
  3758. + QueryResult *result = CharacterDatabase.PQuery("SELECT account, name, (SUM(totaltime)) AS combinetime FROM characters GROUP BY account ORDER BY combinetime DESC LIMIT 0, %d ", limitr);
  3759. + if (result)
  3760. + {
  3761. + Field *fields = result->Fetch();
  3762. + std::string tptime = MakeMsg("\x2 Top%d Accounts By Played Time:\x3\x31\x30 ", limitr);
  3763. + for (uint64 i=0; i < result->GetRowCount(); i++)
  3764. + {
  3765. + uint32 account = fields[0].GetUInt32();
  3766. + std::string PlName = GetAcctNameFromID(account);
  3767. + std::string Time = SecToDay(fields[2].GetCppString());
  3768. + uint32 rank = i+1;
  3769. + tptime.append(MakeMsg("[%u]%s %s \xF| \x3\x31\x30\x2", rank, PlName.c_str(), Time.c_str()));
  3770. + result->NextRow();
  3771. + }
  3772. + delete result;
  3773. + Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE);
  3774. + }
  3775. + else
  3776. + Send_IRCA(CD->USER, "\0034[ERROR] : No Accounts Returned." ,true, "ERROR");
  3777. + }
  3778. + if (_PARAMS[0] == "chartime")
  3779. + {
  3780. + QueryResult *result = CharacterDatabase.PQuery("SELECT name, totaltime FROM characters ORDER BY totaltime DESC LIMIT 0, %d ", limitr);
  3781. + if (result)
  3782. + {
  3783. + Field *fields = result->Fetch();
  3784. + std::string tptime = MakeMsg("\x2 Top%d Characters By Played Time:\x3\x31\x30 ", limitr);
  3785. + for (uint64 i=0; i < result->GetRowCount(); i++)
  3786. + {
  3787. + std::string Name = fields[0].GetCppString();
  3788. + std::string Time = SecToDay(fields[1].GetCppString());
  3789. + uint32 rank = i+1;
  3790. + tptime.append(MakeMsg("[%u]%s %s \xF| \x3\x31\x30\x2", rank, Name.c_str(), Time.c_str()));
  3791. + result->NextRow();
  3792. + }
  3793. + delete result;
  3794. + Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE);
  3795. + }
  3796. + else
  3797. + Send_IRCA(CD->USER, "\0034[ERROR] : No Characters Returned." ,true, "ERROR");
  3798. + }
  3799. + if (_PARAMS[0] == "money")
  3800. + {
  3801. + QueryResult *result = CharacterDatabase.PQuery("SELECT name, CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ', 1462), ' ', -1) AS UNSIGNED) AS money FROM characters ORDER BY money DESC LIMIT 0, %d ", limitr);
  3802. + if (result)
  3803. + {
  3804. + Field *fields = result->Fetch();
  3805. + std::string tptime = MakeMsg("\x2 Top%d Characters By Money:\x3\x31\x30 ", limitr);
  3806. + for (uint64 i=0; i < result->GetRowCount(); i++)
  3807. + {
  3808. + std::string Name = fields[0].GetCppString();
  3809. + unsigned int money = fields[1].GetInt32();
  3810. +
  3811. + uint32 rank = i+1;
  3812. +
  3813. + unsigned int gold = money / 10000;
  3814. + unsigned int silv = (money % 10000) / 100;
  3815. + unsigned int cop = (money % 10000) % 100;
  3816. + char tempgold [100];
  3817. + sprintf(tempgold, "\x2\x3\x30\x37%ug \x3\x31\x34%us \x3\x30\x35%uc\xF", gold, silv, cop);
  3818. +
  3819. + tptime.append(MakeMsg("[%u]%s %s \xF| \x3\x31\x30\x2", rank, Name.c_str(), tempgold));
  3820. + result->NextRow();
  3821. + }
  3822. + delete result;
  3823. + Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE);
  3824. + }
  3825. + else
  3826. + Send_IRCA(CD->USER, "\0034[ERROR] : No Characters Returned." ,true, "ERROR");
  3827. + }
  3828. +
  3829. +}
  3830. +
  3831. +void IRCCmd::Who_Logged(_CDATA *CD)
  3832. +{
  3833. + std::string OPS = "";
  3834. + for (std::list<_client*>::iterator i=_CLIENTS.begin(); i!=_CLIENTS.end();i++)
  3835. + {
  3836. + OPS.append(MakeMsg(" \002[GM:%d IRC: %s - WoW: %s]\002 ", (*i)->GMLevel, (*i)->Name.c_str(), (*i)->UName.c_str()));
  3837. + }
  3838. + Send_IRCA(ChanOrPM(CD), OPS, true, CD->TYPE);
  3839. +}
  3840. +
  3841. +// GM Ticket by bizkut http://github.com/bizkut
  3842. +void IRCCmd::GM_Ticket(_CDATA *CD)
  3843. +{
  3844. + std::string* _PARAMS = getArray(CD->PARAMS, 3);
  3845. + uint32 limitr = 10;
  3846. + std::string DateTime = "%h:%i%p, %a %d %b %Y";
  3847. + if (atoi(_PARAMS[1].c_str()) > 0 && GetLevel(CD->USER) >= sIRC._op_gm_lev)
  3848. + limitr = atoi(_PARAMS[1].c_str());
  3849. + if (_PARAMS[0] == "list")
  3850. + {
  3851. + QueryResult *result = CharacterDatabase.PQuery("SELECT guid, DATE_FORMAT(ticket_lastchange, '%s') FROM character_ticket ORDER BY ticket_id ASC LIMIT 0, %d", DateTime.c_str(), limitr);
  3852. + if (result)
  3853. + {
  3854. + Field *fields = result->Fetch();
  3855. + std::string tptime = MakeMsg("\x2 First %d Tickets:\x3\x31\x30 ", limitr);
  3856. + for (uint64 i=0; i < result->GetRowCount(); i++)
  3857. + {
  3858. + ObjectGuid guid = ObjectGuid(fields[0].GetUInt64());
  3859. + std::string CharName = GetCharNameFromGUID(guid);
  3860. + std::string lastchange = fields[1].GetCppString();
  3861. + uint32 tindex = i+1;
  3862. + tptime.append(MakeMsg("[%u] %s \xF| \x3\x31\x30\x2", tindex, CharName.c_str()));
  3863. + result->NextRow();
  3864. + }
  3865. + delete result;
  3866. + Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE);
  3867. + }
  3868. + else
  3869. + Send_IRCA(CD->USER, "\0034[ERROR] : No Ticket Returned." ,true, "ERROR");
  3870. + }
  3871. + // read ticket
  3872. + if (_PARAMS[0] == "read")
  3873. + {
  3874. + std::string CharName = _PARAMS[1].c_str();
  3875. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(CharName);
  3876. + QueryResult *result = CharacterDatabase.PQuery("SELECT guid, ticket_text, DATE_FORMAT(ticket_lastchange, '%s'), response_text FROM character_ticket WHERE guid=%u",DateTime.c_str(), guid.GetCounter());
  3877. + if (result)
  3878. + {
  3879. + Field *fields = result->Fetch();
  3880. + std::string tptime = MakeMsg("\x2 Ticket [%s]\x3\x31\x30 ", CharName.c_str());
  3881. + uint32 guid = fields[0].GetUInt32();
  3882. + std::string ticktext = fields[1].GetCppString();
  3883. + std::string lastchange = fields[2].GetCppString();
  3884. + std::string tresponse = fields[3].GetCppString();
  3885. + if (tresponse == "")
  3886. + tresponse = "NO RESPONSE YET";
  3887. + tptime.append(MakeMsg("\x02[%s] - %s -\x02 Response: \x02%s\x02", lastchange.c_str(), ticktext.c_str(), tresponse.c_str()));
  3888. + delete result;
  3889. + Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE);
  3890. + return;
  3891. + }
  3892. + if (guid.IsEmpty())
  3893. + {
  3894. + Send_IRCA(CD->USER, "\0034[ERROR] : Character not found." ,true, "ERROR");
  3895. + return;
  3896. + }
  3897. + else
  3898. + Send_IRCA(CD->USER, "\0034[ERROR] : The character has no ticket." ,true, "ERROR");
  3899. + }
  3900. + if (_PARAMS[0] == "respond")
  3901. + {
  3902. + if (_PARAMS[2] == "")
  3903. + {
  3904. + Send_IRCA(CD->USER, "\0034[ERROR] : Please specify character's name and respond message." ,true, "ERROR");
  3905. + return;
  3906. + }
  3907. + std::string CharName = _PARAMS[1].c_str();
  3908. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(CharName);
  3909. +
  3910. + if (guid.IsEmpty())
  3911. + {
  3912. + Send_IRCA(CD->USER, "\0034[ERROR] : Character not found. " ,true, "ERROR");
  3913. + return;
  3914. + }
  3915. +
  3916. + GMTicket* ticket = sTicketMgr.GetGMTicket(guid);
  3917. +
  3918. + if (!ticket)
  3919. + {
  3920. + Send_IRCA(CD->USER, "\0034[ERROR] : Ticket not found." ,true, "ERROR");
  3921. + return;
  3922. + }
  3923. +
  3924. + ticket->SetResponseText(_PARAMS[2].c_str());
  3925. +
  3926. + if (Player* pl = sObjectMgr.GetPlayer(guid))
  3927. + pl->GetSession()->SendGMResponse(ticket);
  3928. +
  3929. + std::string tptime = MakeMsg("\x2 Ticket [%s] Has Been Respond\x3\x31\x30 ", CharName.c_str());
  3930. + Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE);
  3931. + }
  3932. + if (_PARAMS[0] == "delete")
  3933. + {
  3934. +
  3935. + if (_PARAMS[1] == "")
  3936. + {
  3937. + Send_IRCA(CD->USER, "\0034[ERROR] : Please specify character's name or 'all' to delete all tickets." ,true, "ERROR");
  3938. + return;
  3939. + }
  3940. + if (_PARAMS[1] == "all")
  3941. + {
  3942. + sTicketMgr.DeleteAll();
  3943. + std::string tptime = MakeMsg("\x2 All Tickets Deleted!\x3\x31\x30 ");
  3944. + Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE);
  3945. + return;
  3946. + }
  3947. + std::string CharName = _PARAMS[1].c_str();
  3948. + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(CharName);
  3949. + GMTicket* ticket = sTicketMgr.GetGMTicket(guid);
  3950. + if (!ticket)
  3951. + {
  3952. + Send_IRCA(CD->USER, "\0034[ERROR] : Ticket not found." ,true, "ERROR");
  3953. + return;
  3954. + }
  3955. + sTicketMgr.Delete(guid);
  3956. + if (Player* pl = sObjectMgr.GetPlayer(guid))
  3957. + pl->GetSession()->SendGMTicketGetTicket(0x0A, 0);
  3958. + std::string tptime = MakeMsg("\x2 Ticket [%s] Deleted\x3\x31\x30 ", CharName.c_str());
  3959. + Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE);
  3960. + }
  3961. +}
  3962. diff --git a/src/game/mangchat/IRCConf.cpp b/src/game/mangchat/IRCConf.cpp
  3963. new file mode 100644
  3964. index 0000000..6e3c6eb
  3965. --- /dev/null
  3966. +++ b/src/game/mangchat/IRCConf.cpp
  3967. @@ -0,0 +1,189 @@
  3968. +/*
  3969. + * MangChat for MaNGOS, the open source MMORPG-server
  3970. + *
  3971. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  3972. + * Terms Of The GNU General Public License
  3973. + *
  3974. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  3975. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  3976. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  3977. + *
  3978. + * With Help And Support From The MaNGOS Project Community.
  3979. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  3980. + */
  3981. +
  3982. +#include "IRCClient.h"
  3983. +#include "IRCCmd.h"
  3984. +#include "../../shared/Config/Config.h"
  3985. +#include "IRCConf.h"
  3986. +
  3987. +Config MCConfig;
  3988. +void IRCClient::SetCfgFile(char const* cfgfile)
  3989. +{
  3990. + sIRC.CfgFile = cfgfile;
  3991. +}
  3992. +
  3993. +bool IRCClient::LoadConfig()
  3994. +{
  3995. + if (!MCConfig.SetSource(CfgFile))
  3996. + sLog.outString("MangChat: Unable to open configuration file (%s), All default options are being used.", CfgFile);
  3997. + else
  3998. + sLog.outString("MangChat: Found the configuration file, %s", CfgFile);
  3999. +
  4000. + int ConfCnt = 0;
  4001. + sIRC._chan_count = 0;
  4002. + if (MCConfig.GetIntDefault("irc.active", 0))
  4003. + sIRC.Active = true;
  4004. + else
  4005. + sIRC.Active = false;
  4006. +
  4007. + sIRC._Host = MCConfig.GetStringDefault("irc.host", "irc.freenode.net");
  4008. + if (sIRC._Host.size() > 0)
  4009. + ConfCnt++;
  4010. + sIRC._Mver = MCConfig.GetStringDefault("irc.mver", "Version 1.7.9");
  4011. + sIRC._Port = MCConfig.GetIntDefault("irc.port", 6667);
  4012. + sIRC._User = MCConfig.GetStringDefault("irc.user", "MangChat");
  4013. + sIRC._Pass = MCConfig.GetStringDefault("irc.pass", "MyDumbPass");
  4014. + sIRC._Nick = MCConfig.GetStringDefault("irc.nick", "MangChat");
  4015. + sIRC._Auth = MCConfig.GetIntDefault("irc.auth", 0);
  4016. + sIRC._Auth_Nick = MCConfig.GetStringDefault("irc.auth.nick", "AuthNick");
  4017. + sIRC._ICC = MCConfig.GetStringDefault("irc.icc", "001");
  4018. + sIRC._defchan = MCConfig.GetStringDefault("irc.defchan", "lobby");
  4019. + sIRC._ldefc = MCConfig.GetIntDefault("irc.ldef", 0);
  4020. + sIRC._wct = MCConfig.GetIntDefault("irc.wct", 30000);
  4021. + sIRC.ajoin = MCConfig.GetIntDefault("irc.ajoin", 1);
  4022. + sIRC.ajchan = MCConfig.GetStringDefault("irc.ajchan", "world");
  4023. + sIRC.onlrslt = MCConfig.GetIntDefault("irc.online.result", 10);
  4024. + sIRC.BOTMASK = MCConfig.GetIntDefault("Botmask", 0);
  4025. + sIRC.logfile = MCConfig.GetStringDefault("irc.logfile.prefix", "IRC_");
  4026. + for (int i = 1; i < MAX_CONF_CHANNELS;i++)
  4027. + {
  4028. + std::ostringstream ss;
  4029. + ss << i;
  4030. + std::string ci = "irc.chan_" + ss.str();
  4031. + std::string t_chan = MCConfig.GetStringDefault(ci.c_str(), "");
  4032. + if (t_chan.size() > 0)
  4033. + {
  4034. + sIRC._chan_count++;
  4035. + sIRC._irc_chan[sIRC._chan_count] = t_chan;
  4036. + ci = "wow.chan_" + ss.str();
  4037. + sIRC._wow_chan[sIRC._chan_count] = MCConfig.GetStringDefault(ci.c_str(), t_chan.c_str());
  4038. + }
  4039. + }
  4040. + sIRC.JoinMsg = MCConfig.GetStringDefault("irc.joinmsg", "Whhaaazzzzaaaa, MangChat $Ver Baby!!");
  4041. + sIRC.RstMsg = MCConfig.GetStringDefault("irc.rstmsg", "MangChat Is Restarting, I Will Be Right Back!");
  4042. + sIRC.kikmsg = MCConfig.GetStringDefault("irc.kickmsg", "Do Not Kick Me Again, Severe Actions Will Be Taken!");
  4043. +
  4044. + // IRC LINES
  4045. + sIRC.ILINES[WOW_IRC] = MCConfig.GetStringDefault("chat.wow_irc", "\003<WoW>[\002$Name($Level)\002\003] $Msg");
  4046. + sIRC.ILINES[IRC_WOW] = MCConfig.GetStringDefault("chat.irc_wow", "\003<IRC>[$Name]: $Msg");
  4047. + sIRC.ILINES[JOIN_WOW] = MCConfig.GetStringDefault("chat.join_wow", "\00312>>\00304 $Name \003Joined The Channel!");
  4048. + sIRC.ILINES[JOIN_IRC] = MCConfig.GetStringDefault("chat.join_irc", "\003[$Name]: Has Joined IRC!");
  4049. + sIRC.ILINES[LEAVE_WOW] = MCConfig.GetStringDefault("chat.leave_wow", "\00312<<\00304 $Name \003Left The Channel!");
  4050. + sIRC.ILINES[LEAVE_IRC] = MCConfig.GetStringDefault("chat.leave_irc", "\003[$Name]: Has Left IRC!");
  4051. + sIRC.ILINES[CHANGE_NICK] = MCConfig.GetStringDefault("chat.change_nick", "\003<> $Name Is Now Known As $NewName!");
  4052. +
  4053. + // MangChat Options
  4054. + sIRC._MCA = MCConfig.GetIntDefault("irc.maxattempt", 10);
  4055. + sIRC._autojoinkick = MCConfig.GetIntDefault("irc.autojoin_kick", 1);
  4056. + sIRC._cmd_prefx = MCConfig.GetStringDefault("irc.command_prefix", ".");
  4057. +
  4058. + sIRC._op_gm = MCConfig.GetIntDefault("irc.op_gm_login", 0);
  4059. + sIRC._op_gm_lev = MCConfig.GetIntDefault("irc.op_gm_level", 3);
  4060. +
  4061. + // Misc Options
  4062. + sIRC.games = MCConfig.GetIntDefault("irc.fun.games", 0);
  4063. + sIRC.gmlog = MCConfig.GetIntDefault("irc.gmlog", 1);
  4064. + sIRC.BOTMASK = MCConfig.GetIntDefault("BotMask", 0);
  4065. + sIRC.Status = MCConfig.GetIntDefault("irc.StatusChannel", 1);
  4066. + sIRC.anchn = MCConfig.GetIntDefault("irc.AnnounceChannel", 1);
  4067. + sIRC.autoanc = MCConfig.GetIntDefault("irc.auto.announce", 30);
  4068. +
  4069. + for (uint16 i = 0; i<SEC_ADMINISTRATOR; i++)
  4070. + {
  4071. + std::stringstream ircKeyWord, defaultEntry;
  4072. + ircKeyWord << "irc.gm" << i;
  4073. + if (!i)
  4074. + defaultEntry << "";
  4075. + else
  4076. + defaultEntry << "[GM" << i << "]";
  4077. + sIRC.ojGM[i] = MCConfig.GetStringDefault(ircKeyWord.str().c_str(), defaultEntry.str().c_str());
  4078. + }
  4079. +
  4080. + // REQUIRED GM LEVEL
  4081. + QueryResult *result = WorldDatabase.PQuery("SELECT `Command`, `gmlevel` FROM `irc_commands` ORDER BY `Command`");
  4082. + if (result)
  4083. + {
  4084. + Field *fields = result->Fetch();
  4085. + for (uint64 i=0; i < result->GetRowCount(); i++)
  4086. + {
  4087. + std::string command = fields[0].GetCppString();
  4088. + uint32 gmlvl = fields[1].GetUInt32();
  4089. + if (command == "acct") sIRC.CACCT = gmlvl;
  4090. + if (command == "ban") sIRC.CBAN = gmlvl;
  4091. + if (command == "char") sIRC.CCHAN = gmlvl;
  4092. + if (command == "char") sIRC.CCHAR = gmlvl;
  4093. + if (command == "fun") sIRC.CFUN = gmlvl;
  4094. + if (command == "help") sIRC.CHELP = gmlvl;
  4095. + if (command == "inchan") sIRC.CINCHAN = gmlvl;
  4096. + if (command == "info") sIRC.CINFO = gmlvl;
  4097. + if (command == "item") sIRC.CITEM = gmlvl;
  4098. + if (command == "jail") sIRC.CJAIL = gmlvl;
  4099. + if (command == "kick") sIRC.CKICK = gmlvl;
  4100. + if (command == "kill") sIRC._KILL = gmlvl;
  4101. + if (command == "level") sIRC.CLEVEL = gmlvl;
  4102. + if (command == "lookup") sIRC.CLOOKUP = gmlvl;
  4103. + if (command == "money") sIRC.CMONEY = gmlvl;
  4104. + if (command == "mute") sIRC.CMUTE = gmlvl;
  4105. + if (command == "online") sIRC.CONLINE = gmlvl;
  4106. + if (command == "pm") sIRC.CPM = gmlvl;
  4107. + if (command == "restart") sIRC.CRESTART = gmlvl;
  4108. + if (command == "revive") sIRC.CREVIVE = gmlvl;
  4109. + if (command == "saveall") sIRC.CSAVEALL = gmlvl;
  4110. + if (command == "shutdown") sIRC.CSHUTDOWN = gmlvl;
  4111. + if (command == "spell") sIRC.CSPELL = gmlvl;
  4112. + if (command == "sysmsg") sIRC.CSPELL = gmlvl;
  4113. + if (command == "tele") sIRC.CTELE = gmlvl;
  4114. + if (command == "top") sIRC.CTOP = gmlvl;
  4115. + if (command == "who") sIRC.CWHO = gmlvl;
  4116. + result->NextRow();
  4117. + }
  4118. + delete result;
  4119. + }
  4120. + else
  4121. + {
  4122. + sIRC.CACCT = 3;
  4123. + sIRC.CBAN = 3;
  4124. + sIRC.CCHAN = 3;
  4125. + sIRC.CCHAR = 3;
  4126. + sIRC.CFUN = 3;
  4127. + sIRC.CHELP = 3;
  4128. + sIRC.CINCHAN = 3;
  4129. + sIRC.CINFO = 3;
  4130. + sIRC.CITEM = 3;
  4131. + sIRC.CJAIL = 3;
  4132. + sIRC.CKICK = 3;
  4133. + sIRC._KILL = 3;
  4134. + sIRC.CLEVEL = 3;
  4135. + sIRC.CLOOKUP = 3;
  4136. + sIRC.CMONEY = 3;
  4137. + sIRC.CMUTE = 3;
  4138. + sIRC.CONLINE = 3;
  4139. + sIRC.CPM = 3;
  4140. + sIRC.CRESTART = 3;
  4141. + sIRC.CREVIVE = 3;
  4142. + sIRC.CSAVEALL = 3;
  4143. + sIRC.CSHUTDOWN = 3;
  4144. + sIRC.CSPELL = 3;
  4145. + sIRC.CSYSMSG = 3;
  4146. + sIRC.CTELE = 3;
  4147. + sIRC.CTOP = 3;
  4148. + sIRC.CWHO = 3;
  4149. + }
  4150. + return true;
  4151. +}
  4152. +
  4153. +std::string IRCClient::GetChatLine(int nItem)
  4154. +{
  4155. + return sIRC.ILINES[nItem];
  4156. +}
  4157. diff --git a/src/game/mangchat/IRCConf.h b/src/game/mangchat/IRCConf.h
  4158. new file mode 100644
  4159. index 0000000..ae9b2d8
  4160. --- /dev/null
  4161. +++ b/src/game/mangchat/IRCConf.h
  4162. @@ -0,0 +1,12 @@
  4163. +#ifndef MC_CONFIG_H
  4164. +#define MC_CONFIG_H
  4165. +
  4166. +#include "Platform/CompilerDefs.h"
  4167. +
  4168. +#if PLATFORM == PLATFORM_WINDOWS
  4169. + #define _MANGCHAT_CONFIG "mangchat.conf"
  4170. +#else
  4171. + #define _MANGCHAT_CONFIG SYSCONFDIR"mangchat.conf"
  4172. +#endif
  4173. +
  4174. +#endif
  4175. diff --git a/src/game/mangchat/IRCFunc.h b/src/game/mangchat/IRCFunc.h
  4176. new file mode 100644
  4177. index 0000000..27bcde8
  4178. --- /dev/null
  4179. +++ b/src/game/mangchat/IRCFunc.h
  4180. @@ -0,0 +1,268 @@
  4181. +/*
  4182. + * MangChat for MaNGOS, the open source MMORPG-server
  4183. + *
  4184. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  4185. + * Terms Of The GNU General Public License
  4186. + *
  4187. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  4188. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  4189. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  4190. + *
  4191. + * With Help And Support From The MaNGOS Project Community.
  4192. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  4193. + */
  4194. +
  4195. +#ifndef _IRC_CLIENT_FUNC
  4196. +#define _IRC_CLIENT_FUNC
  4197. +
  4198. +std::string GetUser(std::string szU)
  4199. +{
  4200. + int pos = szU.find("!");
  4201. + return szU.substr(0, pos);
  4202. +}
  4203. +
  4204. +// determines weather a string is terminated by a Carriage Return or not
  4205. +bool isCRTerminated(std::string arg)
  4206. +{
  4207. + return (arg.end() != arg.begin() && (*--arg.end()) == 0x0D);
  4208. +}
  4209. +
  4210. +// Delink will remove anything considered "non chat" from a string
  4211. +// Linked items (items that players can click on to see a description)
  4212. +// contain extra characters wich the client filter out, this function
  4213. +// makes sure people on irc do not see those characters.
  4214. +std::string Delink(std::string msg)
  4215. +{
  4216. + std::size_t pos;
  4217. + const char delinkExpression[4][10] = {"|Hitem", "|Hquest", "|Henchant", "|Hspell"};
  4218. +
  4219. + for (uint8 i = 0; i < 4; ++i)
  4220. + while((pos = msg.find(delinkExpression[i])) != std::string::npos)
  4221. + {
  4222. + std::size_t find1 = msg.find("|h", pos);
  4223. + std::size_t find2 = msg.find("|h", find1 + 2);
  4224. + msg.replace(pos, find1 - pos + 2, "\x2");
  4225. + msg.replace(msg.find("|h", pos), 2, "\x2");
  4226. + }
  4227. +
  4228. + return msg;
  4229. +}
  4230. +
  4231. +// This function converts the characters used by the client to identify colour to IRC format.
  4232. +std::string WoWcol2IRC(std::string msg)
  4233. +{
  4234. + std::size_t pos;
  4235. + char IRCCol[15][4] = { "\xF", "\xF", "\x3\x31\x34", "\x3\x30\x33", "\x3\x31\x32", "\x3\x30\x36", "\x3\x30\x37", "\x3\x30\x34", "\x3\x30\x37", "\x3\x30\x38", "\x3\x31\x34", "\x3\x30\x33","\x3\x30\x34", "\x3\x30\x37", "\x3\x31\x31"};
  4236. + char WoWCol[15][12] = { "|r", "|cffffffff", "|cff9d9d9d", "|cff1eff00", "|cff0070dd", "|cffa335ee", "|cffff8000", "|cffe6cc80", "|cffffd000", "|cffffff00", "|cff808080", "|cff40c040", "|cffff2020", "|cffff8040", "|cff71d5ff"};
  4237. + for (int i=0; i<15; i++)
  4238. + {
  4239. + while ((pos = msg.find(WoWCol[i])) != std::string::npos)
  4240. + {
  4241. + if (i == 0)
  4242. + msg.replace(pos, 2, IRCCol[i]);
  4243. + else
  4244. + msg.replace(pos, 10, IRCCol[i]);
  4245. + }
  4246. + }
  4247. + return msg;
  4248. +}
  4249. +
  4250. +// This function converts the characters used by IRC to identify colour to a format the client can understand.
  4251. +std::string IRCcol2WoW(std::string msg)
  4252. +{
  4253. + std::size_t pos;
  4254. + char IRCCol[16][4] = { "\x3\x30", "\x3\x31", "\x3\x32", "\x3\x33", "\x3\x34", "\x3\x35", "\x3\x36", "\x3\x37", "\x3\x38", "\x3\x39", "\x3\x31\x30", "\x3\x31\x31", "\x3\x31\x32", "\x3\x31\x33", "\x3\x31\x34", "\x3\x31\x35"};
  4255. + char IRCCol2[10][4] = { "\x3\x30\x30", "\x3\x30\x31", "\x3\x30\x32", "\x3\x30\x33", "\x3\x30\x34", "\x3\x30\x35", "\x3\x30\x36", "\x3\x30\x37", "\x3\x30\x38", "\x3\x30\x39"};
  4256. + char WoWcol[16][12] = { "|cffffffff", "|cff000000", "|cff00007f", "|cff009300", "|cffff0000", "|cff7f0000", "|cff9c009c", "|cfffc9300", "|cffffff00", "|cff00fc00", "|cff009393", "|cff00ffff", "|cff0000fc", "|cffff00ff", "|cff7f7f7f", "|cffd2d2d2"};
  4257. + for (int i=15; i>=0; i--)
  4258. + {
  4259. + if (i<10)
  4260. + {
  4261. + while ((pos = msg.find(IRCCol2[i])) != std::string::npos)
  4262. + {
  4263. + msg.replace(pos, 3, WoWcol[i]);
  4264. + }
  4265. + while ((pos = msg.find(IRCCol[i])) != std::string::npos)
  4266. + {
  4267. + msg.replace(pos, 2, WoWcol[i]);
  4268. + }
  4269. +
  4270. + }
  4271. + else
  4272. + {
  4273. + while ((pos = msg.find(IRCCol[i])) != std::string::npos)
  4274. + {
  4275. + msg.replace(pos, 3, WoWcol[i]);
  4276. + }
  4277. + }
  4278. +
  4279. + // Remove Bold, Reverse, Underline from IRC
  4280. + char Checker[3][3] = {"\x2","\x16","\x1F"}; // This is the Hex part not Dec. In Decimal its (2,22,31)
  4281. + for(int I=0; I < 3; I++)
  4282. + {
  4283. + while ((pos = msg.find(Checker[I])) != std::string::npos)
  4284. + {
  4285. + msg.replace(pos, 1, "");
  4286. + }
  4287. + }
  4288. + // Finished Removing !
  4289. +
  4290. + }
  4291. +
  4292. + while ((pos = msg.find("\x3")) != std::string::npos)
  4293. + {
  4294. + msg.replace(pos, 1, "|r");
  4295. + }
  4296. + while ((pos = msg.find("\xF")) != std::string::npos)
  4297. + {
  4298. + msg.replace(pos, 1, "|r");
  4299. + }
  4300. +
  4301. + return msg;
  4302. +}
  4303. +
  4304. +// This function compares 2 strings
  4305. +int nocase_cmp(const string & s1, const string& s2)
  4306. +{
  4307. + string::const_iterator it1=s1.begin();
  4308. + string::const_iterator it2=s2.begin();
  4309. +
  4310. + //stop when either string's end has been reached
  4311. + while ( (it1!=s1.end()) && (it2!=s2.end()) )
  4312. + {
  4313. + if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
  4314. + // return -1 to indicate smaller than, 1 otherwise
  4315. + return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1;
  4316. + //proceed to the next character in each string
  4317. + ++it1;
  4318. + ++it2;
  4319. + }
  4320. + size_t size1=s1.size(), size2=s2.size(); // cache lengths
  4321. + //return -1,0 or 1 according to strings' lengths
  4322. + if (size1==size2)
  4323. + return 0;
  4324. + return (size1<size2) ? -1 : 1;
  4325. +}
  4326. +
  4327. +std::string MakeMsgA(const char *sLine, ... )
  4328. +{
  4329. + va_list ap;
  4330. + char tmpoutp[1024];
  4331. + va_start(ap, sLine);
  4332. + vsnprintf(tmpoutp, 1024, sLine, ap );
  4333. + va_end(ap);
  4334. + std::string outp = tmpoutp;
  4335. + return outp;
  4336. +}
  4337. +
  4338. +std::string MakeMsgP(int CLINE, std::string Msg, Player *plr)
  4339. +{
  4340. + // std::string ChatTag = "";
  4341. + // switch (plr->GetTeam())
  4342. + // {
  4343. + // case 67:ChatTag.append("4");break; //horde
  4344. + // case 469:ChatTag.append("12");break; //alliance
  4345. + // }
  4346. + std::string sMsg = sIRC.MakeMsg(sIRC.GetChatLine(CLINE), "$Msg", Msg);
  4347. + // sMsg = ChatTag + MakeMsg(sMsg, "$Name", plr->GetName());
  4348. + if (plr->GetTeam() == 67)
  4349. + sMsg = sIRC.MakeMsg(sMsg, "$Name", MakeMsgA("\0034%s\003", plr->GetName()));
  4350. + else if (plr->GetTeam() == 469)
  4351. + sMsg = sIRC.MakeMsg(sMsg, "$Name", MakeMsgA("\00312%s\003", plr->GetName()));
  4352. + if(plr->isAFK())
  4353. + sMsg = sIRC.MakeMsg(sMsg, "$Tag", "<AFK>");
  4354. + else if(plr->isDND())
  4355. + sMsg = sIRC.MakeMsg(sMsg, "$Tag", "<DND>");
  4356. + else
  4357. + sMsg = sIRC.MakeMsg(sMsg, "$Tag", "");
  4358. + sMsg = sIRC.MakeMsg(sMsg, "$Level", MakeMsgA("%d", plr->getLevel()));
  4359. + sMsg = Delink(sMsg);
  4360. + sMsg = WoWcol2IRC(sMsg);
  4361. + return sMsg;
  4362. +}
  4363. +
  4364. +/*
  4365. +std::string MakeMsg(std::string msg, std::string var, int val)
  4366. +{
  4367. + std::ostringstream ss;
  4368. + ss << val;
  4369. +
  4370. + std::string nval = ss.str();
  4371. + std::size_t start = msg.find(var);
  4372. + if (start != std::string::npos)
  4373. + msg.replace(start, var.length(), val);
  4374. + return msg;
  4375. +}
  4376. +*/
  4377. +/*
  4378. +std::string MakeMsg(const char *sLine, ... )
  4379. +{
  4380. + va_list ap;
  4381. + char tmpoutp[1024];
  4382. + va_start(ap, sLine);
  4383. + vsnprintf(tmpoutp, 1024, sLine, ap );
  4384. + va_end(ap);
  4385. + std::string outp = tmpoutp;
  4386. + return outp;
  4387. +}
  4388. +*/
  4389. +
  4390. +// This function checks if a channel exists in out configuration
  4391. +// Mangchat supports as many channels as you like
  4392. +// However the default has been set to 10
  4393. +// if you wish to increase this you must edit the:
  4394. +// MAX_CONF_CHANNELS variable in IRCClient.h
  4395. +bool Channel_Valid(std::string Channel)
  4396. +{
  4397. + for(int i=1;i < sIRC._chan_count + 1;i++)
  4398. + {
  4399. + if(nocase_cmp(sIRC._wow_chan[i], Channel)==0)
  4400. + return true;
  4401. + }
  4402. + return false;
  4403. +}
  4404. +
  4405. +std::string GetWoWChannel(std::string Channel)
  4406. +{
  4407. + for(int i=1;i < sIRC._chan_count + 1;i++)
  4408. + {
  4409. + if("#" + sIRC._irc_chan[i] == Channel)
  4410. + return sIRC._wow_chan[i];
  4411. + }
  4412. + return "";
  4413. +}
  4414. +
  4415. +std::string GetIRCChannel(std::string Channel)
  4416. +{
  4417. + for(int i=1;i < sIRC._chan_count + 1;i++)
  4418. + {
  4419. + if(sIRC._wow_chan[i] == Channel)
  4420. + return sIRC._irc_chan[i];
  4421. + }
  4422. + return "";
  4423. +}
  4424. +
  4425. +std::string* getArray(std::string PARAMS, int nCount, std::string )
  4426. +{
  4427. + std::string *array = new std::string[nCount];
  4428. + if(PARAMS.size() > 0)
  4429. + {
  4430. + int pcnt = 0;
  4431. + size_t ps = 0;
  4432. + size_t pc = -1;
  4433. + for(int i = 0;i < nCount;i++)
  4434. + {
  4435. + pc = PARAMS.find(" ", pc + 1);
  4436. + if(i + 1 == nCount && nCount != 1)
  4437. + {
  4438. + if(ps > 0 && pc > 0)
  4439. + array[i] = PARAMS.substr(ps, PARAMS.size() - ps);
  4440. + }
  4441. + else
  4442. + array[i] = PARAMS.substr(ps, pc - ps);
  4443. + ps = pc + 1;
  4444. + }
  4445. + }
  4446. + return array;
  4447. +}
  4448. +#endif
  4449. diff --git a/src/game/mangchat/IRCIO.cpp b/src/game/mangchat/IRCIO.cpp
  4450. new file mode 100644
  4451. index 0000000..3fd1862
  4452. --- /dev/null
  4453. +++ b/src/game/mangchat/IRCIO.cpp
  4454. @@ -0,0 +1,437 @@
  4455. +/*
  4456. + * MangChat for MaNGOS, the open source MMORPG-server
  4457. + *
  4458. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  4459. + * Terms Of The GNU General Public License
  4460. + *
  4461. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  4462. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  4463. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  4464. + *
  4465. + * With Help And Support From The MaNGOS Project Community.
  4466. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  4467. + */
  4468. +
  4469. +#include "IRCClient.h"
  4470. +#include "IRCCmd.h"
  4471. +#include "IRCFunc.h"
  4472. +#include "../ObjectAccessor.h"
  4473. +#include "../ObjectMgr.h"
  4474. +#include "../../shared/WorldPacket.h"
  4475. +#include "../ChannelMgr.h"
  4476. +#include "../../shared/Config/Config.h"
  4477. +#include "../Channel.h"
  4478. +#include "../World.h"
  4479. +#include "../Chat.h"
  4480. +
  4481. +IRCCmd Command;
  4482. +void IRCClient::Handle_IRC(std::string sData)
  4483. +{
  4484. + sLog.outDebug(sData.c_str());
  4485. + // If first 5 chars are ERROR then something is wrong
  4486. + // either link is being closed, nickserv ghost command, etc...
  4487. + try
  4488. + {
  4489. + if(sData.substr(0, 5) == "ERROR")
  4490. + {
  4491. + Disconnect();
  4492. + return;
  4493. + }
  4494. + if(sData.substr(0, 4) == "PING")
  4495. + {
  4496. + // if the first 4 characters contain PING
  4497. + // the server is checking if we are still alive
  4498. + // sen back PONG back plus whatever the server send with it
  4499. + SendIRC("PONG " + sData.substr(4, sData.size() - 4));
  4500. + }
  4501. + else
  4502. + {
  4503. + // if the first line contains : its an irc message
  4504. + // such as private messages channel join etc.
  4505. + if(sData.substr(0, 1) == ":")
  4506. + {
  4507. + // find the spaces in the receieved line
  4508. + size_t p1 = sData.find(" ");
  4509. + size_t p2 = sData.find(" ", p1 + 1);
  4510. + // because the irc protocol uses simple spaces
  4511. + // to seperate data we can easy pick them out
  4512. + // since we know the position of the spaces
  4513. + std::string USR = sData.substr(1, p1 - 1);
  4514. + std::string CMD = sData.substr(p1 + 1, p2 - p1 - 1);
  4515. + // trasform the commands to lowercase to make sure they always match
  4516. + std::transform(CMD.begin(), CMD.end(), CMD.begin(), towlower);
  4517. + // Extract the username from the first part
  4518. + std::string szUser = GetUser(USR);
  4519. + // if we receieved the internet connect code
  4520. + // we know for sure that were in and we can
  4521. + // authenticate ourself.
  4522. + if(CMD == sIRC._ICC)
  4523. + {
  4524. + // _Auth is defined in mangosd.conf (irc.auth)
  4525. + // 0 do not authenticate
  4526. + // 1 use nickserv
  4527. + // 2 use quakenet
  4528. + // aditionally you can provide you own authentication method here
  4529. + switch(sIRC._Auth)
  4530. + {
  4531. + case 1:
  4532. + SendIRC("PRIVMSG nickserv :IDENTIFY " + sIRC._Pass);
  4533. + break;
  4534. + case 2:
  4535. + SendIRC("PRIVMSG nickserv :IDENTIFY " + sIRC._Auth_Nick + " " + sIRC._Pass);
  4536. + break;
  4537. + case 3:
  4538. + SendIRC("PRIVMSG [email protected] :AUTH " + sIRC._Nick + " " + sIRC._Pass);
  4539. + break;
  4540. + case 4:
  4541. + SendIRC("PRIVMSG [email protected] :AUTH " + sIRC._Auth_Nick + " " + sIRC._Pass);
  4542. + break;
  4543. + }
  4544. + // if we join a default channel leave this now.
  4545. + if(sIRC._ldefc==1)
  4546. + SendIRC("PART #" + sIRC._defchan);
  4547. + // Loop thru the channel array and send a command to join them on IRC.
  4548. + for(int i=1;i < sIRC._chan_count + 1;i++)
  4549. + {
  4550. + SendIRC("JOIN #" + sIRC._irc_chan[i]);
  4551. + }
  4552. + }
  4553. + // someone joined the channel this could be the bot or another user
  4554. + if(CMD == "join")
  4555. + {
  4556. + size_t p = sData.find(":", p1);
  4557. + std::string CHAN = sData.substr(p + 1, sData.size() - (p + 1 + isCRTerminated(sData)));
  4558. + // if the user is us it means we join the channel
  4559. + if ((szUser == sIRC._Nick) )
  4560. + {
  4561. + // its us that joined the channel
  4562. + Send_IRC_Channel(CHAN, MakeMsg(MakeMsg(sIRC.JoinMsg, "$Ver", sIRC._Mver.c_str()), "$Trigger", sIRC._cmd_prefx.c_str()), true);
  4563. + }
  4564. + else
  4565. + {
  4566. + // if the user is not us its someone else that joins
  4567. + // so we construct a message and send this to the clients.
  4568. + // MangChat now uses Send_WoW_Channel to send to the client
  4569. + // this makes MangChat handle the packets instead of previously the world.
  4570. + if(sIRC.BOTMASK & 2)
  4571. + Send_WoW_Channel(GetWoWChannel(CHAN).c_str(), IRCcol2WoW(MakeMsg(MakeMsg(GetChatLine(JOIN_IRC), "$Name", szUser), "$Channel", GetWoWChannel(CHAN))));
  4572. + }
  4573. + }
  4574. + // someone on irc left or quit the channel
  4575. + if(CMD == "part" || CMD == "quit")
  4576. + {
  4577. + size_t p3 = sData.find(" ", p2 + 1);
  4578. + std::string CHAN = sData.substr(p2 + 1, p3 - (p2 - isCRTerminated(sData)));
  4579. + // Logout IRC Nick From MangChat If User Leaves Or Quits IRC.
  4580. + if(Command.IsLoggedIn(szUser))
  4581. + {
  4582. + _CDATA CDATA;
  4583. + CDATA.USER = szUser;
  4584. + Command.Handle_Logout(&CDATA);
  4585. + }
  4586. + // Construct a message and inform the clients on the same channel.
  4587. + if (sIRC.BOTMASK & 2)
  4588. + Send_WoW_Channel(GetWoWChannel(CHAN).c_str(), IRCcol2WoW(MakeMsg(MakeMsg(GetChatLine(LEAVE_IRC), "$Name", szUser), "$Channel", GetWoWChannel(CHAN))));
  4589. + }
  4590. + // someone changed their nick
  4591. + if (CMD == "nick" && (sIRC.BOTMASK & 128))
  4592. + {
  4593. + MakeMsg(MakeMsg(GetChatLine(CHANGE_NICK), "$Name", szUser), "$NewName", sData.substr(sData.find(":", p2) + 1, sData.size()- isCRTerminated(sData)));
  4594. + // If the user is logged in and changes their nick
  4595. + // then we want to either log them out or update
  4596. + // their nick in the bot. I chose to update the bots user list.
  4597. + if(Command.IsLoggedIn(szUser))
  4598. + {
  4599. + std::string NewNick = sData.substr(sData.find(":", p2) + 1, isCRTerminated(sData));
  4600. + // On freenode I noticed the server sends an extra character
  4601. + // at the end of the string, so we need to erase the last
  4602. + // character of the string. if you have a problem with getting
  4603. + // the last letter of your nick erased, then remove the - 1.
  4604. + NewNick.erase(NewNick.length() - 1, 1);
  4605. +
  4606. + for(std::list<_client*>::iterator i=Command._CLIENTS.begin(); i!=Command._CLIENTS.end();i++)
  4607. + {
  4608. + if((*i)->Name == szUser)
  4609. + {
  4610. + (*i)->Name = NewNick;
  4611. + sIRC.Send_IRC_Channel(NewNick.c_str(), "I Noticed You Changed Your Nick, I Have Updated My Internal Database Accordingly.", true, "NOTICE");
  4612. +
  4613. + // Figure why not output to the logfile, makes tracing problems easier.
  4614. + sIRC.iLog.WriteLog(" %s : %s Changed Nick To: %s", sIRC.iLog.GetLogDateTimeStr().c_str(), szUser.c_str(), NewNick.c_str());
  4615. + }
  4616. + }
  4617. + }
  4618. +
  4619. + }
  4620. + // someone was kicked from irc
  4621. + if (CMD == "kick")
  4622. + {
  4623. + // extract the details
  4624. + size_t p3 = sData.find(" ", p2 + 1);
  4625. + size_t p4 = sData.find(" ", p3 + 1);
  4626. + size_t p5 = sData.find(":", p4);
  4627. + std::string CHAN = sData.substr(p2 + 1, p3 - p2 - 1);
  4628. + std::string WHO = sData.substr(p3 + 1, p4 - (p3 + 1));
  4629. + std::string BY = sData.substr(p4 + 1, sData.size() - (p4 + isCRTerminated(sData)));
  4630. + // if the one kicked was us
  4631. + if(WHO == sIRC._Nick)
  4632. + {
  4633. + // and autojoin is enabled
  4634. + // return to the channel
  4635. + if(sIRC._autojoinkick == 1)
  4636. + {
  4637. + SendIRC("JOIN " + CHAN);
  4638. + Send_IRC_Channel(CHAN, sIRC.kikmsg, true);
  4639. + }
  4640. + }
  4641. + else
  4642. + {
  4643. + // if it is not us who was kicked we need to inform the clients someone
  4644. + // was removed from the channel
  4645. + // construct a message and send it to the players.
  4646. + Send_WoW_Channel(GetWoWChannel(CHAN).c_str(), "<IRC>[" + WHO + "]: Was Kicked From " + CHAN + " By: " + szUser);
  4647. + }
  4648. + }
  4649. + // a private chat message was receieved.
  4650. + if(CMD == "privmsg" || CMD == "notice")
  4651. + {
  4652. + // extract the values
  4653. + size_t p = sData.find(" ", p2 + 1);
  4654. + std::string FROM = sData.substr(p2 + 1, p - p2 - 1);
  4655. + std::string CHAT = sData.substr(p + 2, sData.size() - (p + 2 + isCRTerminated(sData)));
  4656. + // if this is our username it means we recieved a PM
  4657. + if(FROM == sIRC._Nick)
  4658. + {
  4659. + if(CHAT.find("\001VERSION\001") < CHAT.size())
  4660. + {
  4661. + Send_IRC_Channel(szUser, MakeMsg("\001VERSION MangChat %s ©2008 |Death|\001", "%s" , sIRC._Mver.c_str()), true, "NOTICE");
  4662. + }
  4663. + // a pm is required for certain commands
  4664. + // such as login. to validate the command
  4665. + // we send it to the command class wich handles
  4666. + // evrything else.
  4667. + Command.IsValid(szUser, FROM, CHAT, CMD);
  4668. + }
  4669. + else
  4670. + {
  4671. + // if our name is not in it, it means we receieved chat on one of the channels
  4672. + // magchat is in. the first thing we do is check if it is a command or not
  4673. + if(!Command.IsValid(szUser, FROM, CHAT, CMD))
  4674. + {
  4675. + Send_WoW_Channel(GetWoWChannel(FROM).c_str(), IRCcol2WoW(MakeMsg(MakeMsg(GetChatLine(IRC_WOW), "$Name", szUser), "$Msg", CHAT)));
  4676. + }
  4677. + // if we indeed receieved a command we do not want to display this to the players
  4678. + // so only incanse the isvalid command returns false it will be sent to all player.
  4679. + // the isvalid function will automaitcly process the command on true.
  4680. + }
  4681. + }
  4682. + if(CMD == "mode")
  4683. + {
  4684. + // extract the mode details
  4685. + size_t p3 = sData.find(" ", p2 + 1);
  4686. + size_t p4 = sData.find(" ", p3 + 1);
  4687. + size_t p5 = sData.find(" ", p4 + 1);
  4688. + std::string CHAN = sData.substr(p2 + 1, p3 - p2 - 1);
  4689. + std::string MODE = sData.substr(p3 + 1, p4 - p3 - 1);
  4690. + std::string NICK = sData.substr(p4 + 1, p5 - p4 - 1);
  4691. + bool _AmiOp;
  4692. + _AmiOp = false;
  4693. + //A mode was changed on us
  4694. + if(NICK.c_str() == sIRC._Nick)
  4695. + _AmiOp = true;
  4696. +
  4697. + }
  4698. + }
  4699. + }
  4700. + }
  4701. + catch(std::out_of_range& e)
  4702. + {
  4703. + }
  4704. +}
  4705. +
  4706. +// This function is called in Channel.h
  4707. +// based on nAction it will inform the people on
  4708. +// irc when someone leaves one of the game channels.
  4709. +// nAction is based on the struct CACTION
  4710. +void IRCClient::Handle_WoW_Channel(std::string Channel, Player *plr, int nAction)
  4711. +{
  4712. + // make sure that we are connected
  4713. + if (sIRC.Connected && (sIRC.BOTMASK & 1))
  4714. + {
  4715. + if(Channel_Valid(Channel))
  4716. + {
  4717. + std::string GMRank = "";
  4718. + std::string pname = plr->GetName();
  4719. + bool DoGMAnnounce = false;
  4720. + if (plr->GetSession()->GetSecurity() > 0 && (sIRC.BOTMASK & 8))
  4721. + DoGMAnnounce = true;
  4722. + if (plr->isGameMaster() && (sIRC.BOTMASK & 16))
  4723. + DoGMAnnounce = true;
  4724. + if(DoGMAnnounce)
  4725. + {
  4726. + uint16 gmLevel = plr->GetSession()->GetSecurity();
  4727. + GMRank = "\0037"+sIRC.ojGM[ gmLevel < SEC_CONSOLE ? gmLevel : SEC_CONSOLE];
  4728. + }
  4729. + std::string ChatTag = "";
  4730. + switch (plr->GetTeam())
  4731. + {
  4732. + case 67:ChatTag.append("\0034");break; //horde
  4733. + case 469:ChatTag.append("\00312");break; //alliance
  4734. + }
  4735. + std::string query = "INSERT INTO `irc_inchan` VALUES (%d,'"+pname+"','"+Channel+"')";
  4736. + std::string lchan = "DELETE FROM `irc_inchan` WHERE `guid` = %d AND `channel` = '"+Channel+"'";
  4737. + switch(nAction)
  4738. + {
  4739. + case CHANNEL_JOIN:
  4740. + Send_IRC_Channel(GetIRCChannel(Channel), MakeMsg(MakeMsg(MakeMsg(GetChatLine(JOIN_WOW), "$Name", ChatTag + plr->GetName()), "$Channel", Channel), "$GM", GMRank));
  4741. + WorldDatabase.PExecute(lchan.c_str(), plr->GetObjectGuid().GetCounter());
  4742. + WorldDatabase.PExecute(query.c_str(), plr->GetObjectGuid().GetCounter());
  4743. + break;
  4744. + case CHANNEL_LEAVE:
  4745. + Send_IRC_Channel(GetIRCChannel(Channel), MakeMsg(MakeMsg(MakeMsg(GetChatLine(LEAVE_WOW), "$Name", ChatTag + plr->GetName()), "$Channel", Channel), "$GM", GMRank));
  4746. + WorldDatabase.PExecute(lchan.c_str(), plr->GetObjectGuid().GetCounter());
  4747. + break;
  4748. + }
  4749. + }
  4750. + }
  4751. +}
  4752. +
  4753. +// This function sends chat to a irc channel or user
  4754. +// to prevent the # beeing appended to send a msg to a user
  4755. +// set the NoPrefix to true
  4756. +void IRCClient::Send_IRC_Channel(std::string sChannel, std::string sMsg, bool NoPrefix, std::string nType)
  4757. +{
  4758. + std::string mType = "PRIVMSG";
  4759. + if(Command.MakeUpper(nType.c_str()) == "NOTICE")
  4760. + mType = "NOTICE";
  4761. + if(Command.MakeUpper(nType.c_str()) == "ERROR" && (sIRC.BOTMASK & 32))
  4762. + mType = "NOTICE";
  4763. + if(sIRC.Connected)
  4764. + {
  4765. + if(NoPrefix)
  4766. + SendIRC(mType + " " + sChannel + " :" + sMsg);
  4767. + else
  4768. + SendIRC(mType + " #" + sChannel + " :" + sMsg);
  4769. + }
  4770. +}
  4771. +
  4772. +// This function sends a message to all irc channels
  4773. +// that mangchat has in its configuration
  4774. +void IRCClient::Send_IRC_Channels(std::string sMsg)
  4775. +{
  4776. + for(int i=1;i < sIRC._chan_count + 1;i++)
  4777. + Send_IRC_Channel(sIRC._irc_chan[i], sMsg);
  4778. +}
  4779. +
  4780. +// This function is called in ChatHandler.cpp, any channel chat from wow will come
  4781. +// to this function, validates the channel and constructs a message that is send to IRC
  4782. +void IRCClient::Send_WoW_IRC(Player *plr, std::string Channel, std::string Msg)
  4783. +{
  4784. + // Check if the channel exist in our configuration
  4785. + if(Channel_Valid(Channel) && Msg.substr(0, 1) != ".")
  4786. + Send_IRC_Channel(GetIRCChannel(Channel), MakeMsgP(WOW_IRC, Msg, plr));
  4787. +}
  4788. +
  4789. +void IRCClient::Send_WoW_Player(std::string sPlayer, std::string sMsg)
  4790. +{
  4791. + normalizePlayerName(sPlayer);
  4792. + if (Player* plr = ObjectAccessor::Instance().FindPlayerByName(sPlayer.c_str()))
  4793. + Send_WoW_Player(plr, sMsg);
  4794. +}
  4795. +
  4796. +void IRCClient::Send_WoW_Player(Player *plr, string sMsg)
  4797. +{
  4798. + WorldPacket data(SMSG_MESSAGECHAT, 200);
  4799. + ChatHandler::FillMessageData(&data, plr->GetSession(), CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, plr->GetObjectGuid(), sMsg.c_str(), NULL);
  4800. + plr->GetSession()->SendPacket(&data);
  4801. +}
  4802. +
  4803. +// This function will construct and send a packet to all players
  4804. +// on the given channel ingame. (previuosly found in world.cpp)
  4805. +// it loops thru all sessions and checks if they are on the channel
  4806. +// if so construct a packet and send it.
  4807. +void IRCClient::Send_WoW_Channel(const char *channel, std::string chat)
  4808. +{
  4809. + if(!(strlen(channel) > 0))
  4810. + return;
  4811. +
  4812. + // IRC-Protocol does not use a specific character encoding.
  4813. + // TODO: Autoencode to UTF8 (as used in the wow client)
  4814. +
  4815. + HashMapHolder<Player>::MapType& m = ObjectAccessor::Instance().GetPlayers();
  4816. + for(HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
  4817. + {
  4818. + if (itr->second && itr->second->GetSession()->GetPlayer() && itr->second->GetSession()->GetPlayer()->IsInWorld())
  4819. + {
  4820. + if(ChannelMgr* cMgr = channelMgr(itr->second->GetSession()->GetPlayer()->GetTeam()))
  4821. + {
  4822. + if(Channel *chn = cMgr->GetChannel(channel, itr->second->GetSession()->GetPlayer()))
  4823. + {
  4824. + WorldPacket data;
  4825. + ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_CHANNEL, LANG_UNIVERSAL, channel, ObjectGuid(), IRCcol2WoW(chat.c_str()).c_str(), NULL);
  4826. + itr->second->GetSession()->SendPacket(&data);
  4827. + }
  4828. + }
  4829. + }
  4830. + }
  4831. +}
  4832. +
  4833. +void IRCClient::Send_WoW_System(std::string Message)
  4834. +{
  4835. + HashMapHolder<Player>::MapType& m = ObjectAccessor::Instance().GetPlayers();
  4836. + for(HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
  4837. + {
  4838. + if (itr->second && itr->second->GetSession()->GetPlayer() && itr->second->GetSession()->GetPlayer()->IsInWorld())
  4839. + {
  4840. + WorldPacket data;
  4841. + data.Initialize(CHAT_MSG_SYSTEM);
  4842. + data << (uint8)CHAT_MSG_SYSTEM;
  4843. + data << (uint32)LANG_UNIVERSAL;
  4844. + data << (uint64)0;
  4845. + data << (uint32)0;
  4846. + data << (uint64)0;
  4847. + data << (uint32) (strlen(Message.c_str()) + 1);
  4848. + data << Message.c_str();
  4849. + data << (uint8)0;
  4850. + itr->second->GetSession()->SendPacket(&data);
  4851. + }
  4852. + }
  4853. +}
  4854. +void IRCClient::ResetIRC()
  4855. +{
  4856. + SendData("QUIT");
  4857. + Disconnect();
  4858. +}
  4859. +
  4860. +#define CHAT_INVITE_NOTICE 0x18
  4861. +
  4862. +// this function should be called on player login WorldSession::HandlePlayerLogin
  4863. +void IRCClient::AutoJoinChannel(Player *plr)
  4864. +{
  4865. + if(ChannelMgr* cMgr = channelMgr(plr->GetTeam()))
  4866. + {
  4867. + if(Channel *chn = cMgr->GetChannel(sIRC.ajchan,plr))
  4868. + return;
  4869. + }
  4870. +
  4871. + //this will work if at least 1 player is logged in regrdless if he is on the channel or not
  4872. + // the first person that login empty server is the one with bad luck and wont be invited,
  4873. + // if at least 1 player is online the player will be inited to the chanel
  4874. +
  4875. + std::string m_name = sIRC.ajchan;
  4876. + WorldPacket data;
  4877. + data.Initialize(SMSG_CHANNEL_NOTIFY, 1+m_name.size()+1);
  4878. + data << uint8(CHAT_INVITE_NOTICE);
  4879. + data << m_name.c_str();
  4880. +
  4881. + HashMapHolder<Player>::MapType& m = ObjectAccessor::Instance().GetPlayers();
  4882. + for(HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
  4883. + {
  4884. + if (itr->second && itr->second->GetSession()->GetPlayer() && itr->second->GetSession()->GetPlayer()->IsInWorld())
  4885. + {
  4886. + data << itr->second->GetObjectGuid();
  4887. + break;
  4888. + }
  4889. + }
  4890. + plr->GetSession()->SendPacket(&data);
  4891. +}
  4892. diff --git a/src/game/mangchat/IRCLog.cpp b/src/game/mangchat/IRCLog.cpp
  4893. new file mode 100644
  4894. index 0000000..0120627
  4895. --- /dev/null
  4896. +++ b/src/game/mangchat/IRCLog.cpp
  4897. @@ -0,0 +1,74 @@
  4898. +/*
  4899. + * MangChat for MaNGOS, the open source MMORPG-server
  4900. + *
  4901. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  4902. + * Terms Of The GNU General Public License
  4903. + *
  4904. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  4905. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  4906. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  4907. + *
  4908. + * With Help And Support From The MaNGOS Project Community.
  4909. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  4910. + */
  4911. +
  4912. +#include "IRCLog.h"
  4913. +#include "Config/Config.h"
  4914. +#include "IRCClient.h"
  4915. +#include <stdarg.h>
  4916. +
  4917. +IRCLog::IRCLog()
  4918. +{
  4919. + std::string logsDir = sConfig.GetStringDefault("LogsDir","");
  4920. + std::string ircLogName = logsDir + "/IRC_";
  4921. + std::string ircLogTimestamp = GetLogDateStr();
  4922. + ircLogName += ircLogTimestamp +".log";
  4923. + ircLogfile.open (ircLogName.c_str(), std::ios::app);
  4924. +}
  4925. +
  4926. +IRCLog::~IRCLog()
  4927. +{
  4928. + ircLogfile.close();
  4929. +}
  4930. +// Was added because using the time for logs is very annoying... one log per day.. much cleaner looking..
  4931. +std::string IRCLog::GetLogDateStr() const
  4932. +{
  4933. + time_t t = time(NULL);
  4934. + tm* aTm = localtime(&t);
  4935. + // YYYY year
  4936. + // MM month (2 digits 01-12)
  4937. + // DD day (2 digits 01-31)
  4938. + // HH hour (2 digits 00-23)
  4939. + // MM minutes (2 digits 00-59)
  4940. + // SS seconds (2 digits 00-59)
  4941. + char buf[20];
  4942. + snprintf(buf,20,"%04d-%02d-%02d",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday);
  4943. + return std::string(buf);
  4944. +}
  4945. +
  4946. +std::string IRCLog::GetLogDateTimeStr() const
  4947. +{
  4948. + time_t t = time(NULL);
  4949. + tm* aTm = localtime(&t);
  4950. + // YYYY year
  4951. + // MM month (2 digits 01-12)
  4952. + // DD day (2 digits 01-31)
  4953. + // HH hour (2 digits 00-23)
  4954. + // MM minutes (2 digits 00-59)
  4955. + // SS seconds (2 digits 00-59)
  4956. + char buf[30];
  4957. + snprintf(buf,30,"[ %04d-%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);
  4958. + return std::string(buf);
  4959. +}
  4960. +
  4961. +void IRCLog::WriteLog(const char *what, ...)
  4962. +{
  4963. + va_list ap;
  4964. + char tmpoutp[1024];
  4965. + va_start(ap, what);
  4966. + vsnprintf(tmpoutp, 1024, what, ap );
  4967. + va_end(ap);
  4968. + ircLogfile << tmpoutp;
  4969. + ircLogfile << "\n";
  4970. + ircLogfile.flush();
  4971. +}
  4972. diff --git a/src/game/mangchat/IRCLog.h b/src/game/mangchat/IRCLog.h
  4973. new file mode 100644
  4974. index 0000000..329d78e
  4975. --- /dev/null
  4976. +++ b/src/game/mangchat/IRCLog.h
  4977. @@ -0,0 +1,36 @@
  4978. +/*
  4979. + * MangChat for MaNGOS, the open source MMORPG-server
  4980. + *
  4981. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  4982. + * Terms Of The GNU General Public License
  4983. + *
  4984. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  4985. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  4986. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  4987. + *
  4988. + * With Help And Support From The MaNGOS Project Community.
  4989. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  4990. + */
  4991. +
  4992. +#ifndef _IRC_LOG_H
  4993. +#define _IRC_LOG_H
  4994. +
  4995. +#include "Common.h"
  4996. +#include <fstream>
  4997. +
  4998. +class IRCLog
  4999. +{
  5000. + public:
  5001. + IRCLog();
  5002. + ~IRCLog();
  5003. +
  5004. + public:
  5005. + void WriteLog(const char *what, ...);
  5006. + std::string GetLogDateStr() const;
  5007. + std::string GetLogDateTimeStr() const;
  5008. + private:
  5009. + std::ofstream ircLogfile;
  5010. +};
  5011. +
  5012. +
  5013. +#endif
  5014. diff --git a/src/game/mangchat/IRCSock.cpp b/src/game/mangchat/IRCSock.cpp
  5015. new file mode 100644
  5016. index 0000000..3090737
  5017. --- /dev/null
  5018. +++ b/src/game/mangchat/IRCSock.cpp
  5019. @@ -0,0 +1,160 @@
  5020. +/*
  5021. + * MangChat for MaNGOS, the open source MMORPG-server
  5022. + *
  5023. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  5024. + * Terms Of The GNU General Public License
  5025. + *
  5026. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  5027. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  5028. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  5029. + *
  5030. + * With Help And Support From The MaNGOS Project Community.
  5031. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  5032. + */
  5033. +
  5034. +#include "IRCClient.h"
  5035. +#define MAXDATASIZE 512
  5036. +#include <fcntl.h>
  5037. +
  5038. +#include <stdio.h>
  5039. +#include <sys/types.h>
  5040. +
  5041. +
  5042. +#define _UNICODE
  5043. +
  5044. +#ifdef _MBCS
  5045. +#undef _MBCS
  5046. +#endif
  5047. +
  5048. +bool IRCClient::InitSock()
  5049. +{
  5050. + #ifdef _WIN32
  5051. + WSADATA wsaData; //WSAData
  5052. + if(WSAStartup(MAKEWORD(2,0),&wsaData) != 0)
  5053. + {
  5054. + sLog.outError("IRC Error: Winsock Initialization Error");
  5055. + return false;
  5056. + }
  5057. + #endif
  5058. + if ((sIRC.SOCKET = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
  5059. + {
  5060. + sLog.outError("IRC Error: Socket Error");
  5061. + return false;
  5062. + }
  5063. + int on = 1;
  5064. + if ( setsockopt ( sIRC.SOCKET, SOL_SOCKET, SO_REUSEADDR, ( const char* ) &on, sizeof ( on ) ) == -1 )
  5065. + {
  5066. + sLog.outError("IRC Error: Invalid Socket");
  5067. + return false;
  5068. + }
  5069. + #ifdef _WIN32
  5070. + u_long iMode = 0;
  5071. + ioctlsocket(sIRC.SOCKET, FIONBIO, &iMode);
  5072. + #else
  5073. + fcntl(sIRC.SOCKET, F_SETFL, O_NONBLOCK); // set to non-blocking
  5074. + fcntl(sIRC.SOCKET, F_SETFL, O_ASYNC); // set to asynchronous I/O
  5075. + #endif
  5076. + return true;
  5077. +}
  5078. +
  5079. +bool IRCClient::Connect(const char *cHost, int nPort)
  5080. +{
  5081. + sIRC.Connected = false;
  5082. + struct hostent *he;
  5083. + if ((he=gethostbyname(cHost)) == NULL)
  5084. + {
  5085. + sLog.outError("IRCLIENT: Could not resolve host: %s", cHost);
  5086. + return false;
  5087. + }
  5088. + struct sockaddr_in their_addr;
  5089. + their_addr.sin_family = AF_INET;
  5090. + their_addr.sin_port = htons(nPort);
  5091. + their_addr.sin_addr = *((struct in_addr *)he->h_addr);
  5092. + memset(&(their_addr.sin_zero), '\0', 8);
  5093. + if (::connect(sIRC.SOCKET, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1)
  5094. + {
  5095. + sLog.outError("IRCLIENT: Cannot connect to %s", cHost);
  5096. + return false;
  5097. + }
  5098. + //FD_ZERO(&sIRC.sfdset);
  5099. + //FD_SET(sIRC.SOCKET,&sIRC.sfdset);
  5100. + sIRC.Connected = true;
  5101. + return true;
  5102. +}
  5103. +
  5104. +bool IRCClient::Login(std::string sNick, std::string sUser, std::string sPass)
  5105. +{
  5106. + char hostname[128];
  5107. + gethostname(hostname, sizeof(hostname));
  5108. + if(SendIRC("HELLO"))
  5109. + if(SendIRC("PASS " + sPass))
  5110. + if(SendIRC("NICK " + sNick))
  5111. + if(SendIRC("USER " + sUser + " " + (std::string)hostname + " MangChat :MangChat "+sIRC._Mver.c_str()))
  5112. + return true;
  5113. + return false;
  5114. +}
  5115. +
  5116. +bool IRCClient::SendData(const char *data)
  5117. +{
  5118. + if(sIRC.Connected)
  5119. + {
  5120. + if (send(sIRC.SOCKET, data, strlen(data), 0) == -1)
  5121. + {
  5122. + sLog.outError("IRC Error: Socket Receieve ** \n");
  5123. + //Disconnect();
  5124. + return false;
  5125. + }
  5126. + }
  5127. + return true;
  5128. +}
  5129. +
  5130. +bool IRCClient::SendIRC(std::string data)
  5131. +{
  5132. + std::string RealData = data + "\n";
  5133. + return SendData(RealData.c_str());
  5134. +}
  5135. +
  5136. +void IRCClient::Disconnect()
  5137. +{
  5138. + if(sIRC.SOCKET)
  5139. + {
  5140. + #ifdef _WIN32
  5141. + closesocket(sIRC.SOCKET);
  5142. + //WSACleanup();
  5143. + #else
  5144. + close(sIRC.SOCKET);
  5145. + #endif
  5146. + }
  5147. +}
  5148. +
  5149. +void IRCClient::SockRecv()
  5150. +{
  5151. +// wchar_t bufferdata;
  5152. +
  5153. + char szBuffer[MAXDATASIZE];
  5154. +
  5155. + memset(szBuffer, 0, MAXDATASIZE );
  5156. +
  5157. + int nBytesRecv = ::recv(sIRC.SOCKET, szBuffer, MAXDATASIZE - 1, 0 );
  5158. + if ( nBytesRecv == -1 )
  5159. + {
  5160. + sLog.outError("Connection lost.");
  5161. + sIRC.Connected = false;
  5162. + }
  5163. + else
  5164. + {
  5165. + if (-1 == nBytesRecv)
  5166. + {
  5167. + sLog.outError("Error occurred while receiving from socket.");
  5168. + }
  5169. + else
  5170. + {
  5171. + std::string reply;
  5172. + std::istringstream iss(szBuffer);
  5173. + while(getline(iss, reply))
  5174. + {
  5175. + Handle_IRC(reply);
  5176. + }
  5177. + }
  5178. + }
  5179. +}
  5180. diff --git a/src/game/mangchat/MCS_OnlinePlayers.cpp b/src/game/mangchat/MCS_OnlinePlayers.cpp
  5181. new file mode 100644
  5182. index 0000000..203d962
  5183. --- /dev/null
  5184. +++ b/src/game/mangchat/MCS_OnlinePlayers.cpp
  5185. @@ -0,0 +1,83 @@
  5186. +/*
  5187. + * MangChat for MaNGOS, the open source MMORPG-server
  5188. + *
  5189. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  5190. + * Terms Of The GNU General Public License
  5191. + *
  5192. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  5193. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  5194. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  5195. + *
  5196. + * With Help And Support From The MaNGOS Project Community.
  5197. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  5198. + */
  5199. +
  5200. +#include "MCS_OnlinePlayers.h"
  5201. +
  5202. +#include "../MapManager.h"
  5203. +#include "../ObjectMgr.h"
  5204. +#include "../../shared/Config/Config.h"
  5205. +
  5206. +mcs_OnlinePlayers::mcs_OnlinePlayers() { CD = NULL; }
  5207. +
  5208. +mcs_OnlinePlayers::mcs_OnlinePlayers(_CDATA *_CD)
  5209. +{
  5210. + //create a new instance of data struct and copy its data
  5211. + CD = new _CDATA();
  5212. + CD->CMD = _CD->CMD;
  5213. + CD->FROM = _CD->FROM;
  5214. + CD->PARAMS = _CD->PARAMS;
  5215. + CD->PCOUNT = _CD->PCOUNT;
  5216. + CD->USER = _CD->USER;
  5217. + CD->TYPE = _CD->TYPE;
  5218. +}
  5219. +
  5220. +mcs_OnlinePlayers::~mcs_OnlinePlayers()
  5221. +{
  5222. + if(CD)
  5223. + delete CD;
  5224. +}
  5225. +
  5226. +void mcs_OnlinePlayers::run()
  5227. +{
  5228. + int OnlineCount = 0;
  5229. + std::string IRCOut = "";
  5230. + HashMapHolder<Player>::MapType& m = ObjectAccessor::Instance().GetPlayers();
  5231. + for(HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
  5232. + {
  5233. + if (itr->second && itr->second->GetSession()->GetPlayer() && itr->second->GetSession()->GetPlayer()->IsInWorld())
  5234. + {
  5235. + OnlineCount++;
  5236. + Player *plr = itr->second->GetSession()->GetPlayer();
  5237. + std::string ChatTag = " ";
  5238. +
  5239. + uint16 gmLevel = plr->GetSession()->GetSecurity();
  5240. + ChatTag.append("\0037"+sIRC.ojGM[ gmLevel < SEC_CONSOLE ? gmLevel : SEC_CONSOLE]);
  5241. +
  5242. + if(plr->isAFK())
  5243. + ChatTag.append("\002\0037<AFK>\003\002");
  5244. + else if(plr->isDND())
  5245. + ChatTag.append("\002\0037<DND>\003\002");
  5246. + switch (plr->GetTeam())
  5247. + {
  5248. + case 67:ChatTag.append("\0034");break; //horde
  5249. + case 469:ChatTag.append("\00312");break; //alliance
  5250. + }
  5251. +
  5252. + IRCOut.append(IRCCmd::MakeMsg("%s\002%s\003\017\002(%d)\002\017", ChatTag.c_str(), plr->GetName(), plr->getLevel()));
  5253. +
  5254. + // after XX players have been added to the string
  5255. + // output to irc and reset for the next XX
  5256. + if(OnlineCount % sIRC.onlrslt == 0)
  5257. + {
  5258. + sIRC.Send_IRC_Channel(IRCCmd::ChanOrPM(CD), IRCCmd::MakeMsg("\002 %s", IRCOut.c_str()), true, CD->TYPE.c_str());
  5259. + IRCOut = "";
  5260. + ACE_Based::Thread::Sleep(1000);
  5261. + }
  5262. + }
  5263. + }
  5264. + // Remainder in IRCOUT && Total plyersonline
  5265. + sIRC.Send_IRC_Channel(IRCCmd::ChanOrPM(CD), IRCCmd::MakeMsg("\002Players Online(%d):\017 %s", OnlineCount, IRCOut.c_str()), true, CD->TYPE);
  5266. +
  5267. + sIRC.Script_Lock[MCS_Players_Online] = false;
  5268. +}
  5269. diff --git a/src/game/mangchat/MCS_OnlinePlayers.h b/src/game/mangchat/MCS_OnlinePlayers.h
  5270. new file mode 100644
  5271. index 0000000..17f3610
  5272. --- /dev/null
  5273. +++ b/src/game/mangchat/MCS_OnlinePlayers.h
  5274. @@ -0,0 +1,41 @@
  5275. +/*
  5276. + * MangChat for MaNGOS, the open source MMORPG-server
  5277. + *
  5278. + * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The
  5279. + * Terms Of The GNU General Public License
  5280. + *
  5281. + * Written and Developed by Cybrax <[email protected]>, |Death| <[email protected]>,
  5282. + * Lice <[email protected]>, Dj_baby, Sanaell, Tase, Shinzon <[email protected]>,
  5283. + * Xeross, 3raZar3, the orangevirus team <www.orangevir.us>, ...
  5284. + *
  5285. + * With Help And Support From The MaNGOS Project Community.
  5286. + * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS.
  5287. + */
  5288. +
  5289. +#ifndef _IRC_CLIENT_ONLINE
  5290. +#define _IRC_CLIENT_ONLINE
  5291. +
  5292. +#include "IRCClient.h"
  5293. +#include "IRCCmd.h"
  5294. +
  5295. +// the reason to run this command multithreaded
  5296. +// is to be able to "spread" the output over irc
  5297. +// for servers with high player count
  5298. +// in order not to freeze the mangchat core with sleep
  5299. +// a new thread is spawned it will output the player data
  5300. +// evry "10 players" and pauzes to not spam irc
  5301. +// in addition the command is locked so it cannot be used
  5302. +// while active.
  5303. +
  5304. +class mcs_OnlinePlayers : public ACE_Based::Runnable
  5305. +{
  5306. + public:
  5307. + mcs_OnlinePlayers();
  5308. + mcs_OnlinePlayers(_CDATA *_CD);
  5309. + ~mcs_OnlinePlayers();
  5310. + void run();
  5311. + public:
  5312. + _CDATA *CD;
  5313. +};
  5314. +
  5315. +#endif
  5316. diff --git a/src/game/mangchat/mangchat.conf.dist.in b/src/game/mangchat/mangchat.conf.dist.in
  5317. new file mode 100644
  5318. index 0000000..2ad7312
  5319. --- /dev/null
  5320. +++ b/src/game/mangchat/mangchat.conf.dist.in
  5321. @@ -0,0 +1,204 @@
  5322. +##################################################
  5323. +# MangChat IRC BOT FOR MaNGOS Configuration File #
  5324. +##################################################
  5325. +
  5326. +[MangchatConf]
  5327. +
  5328. +###################################################################################################################
  5329. +# irc.active
  5330. +# Enable MangChat Addon
  5331. +# Default: 1 - Enable
  5332. +# 0 - Disable
  5333. +###################################################################################################################
  5334. +
  5335. +irc.active = 1
  5336. +
  5337. +###################################################################################################################
  5338. +# Botmask
  5339. +# This defines what the bot announces, if its 0 everything is disabled
  5340. +# simply add the values of the elements you want to create this mask.
  5341. +# Example: WoW join/leaves are 1 and IRC join/leaves are 2, if you want both of these active then the BotMask is 3.
  5342. +# (1)Display WoW Chan Join/Leaves In IRC
  5343. +# (2)Display IRC Chan Join/Leaves/NickChanges In WoW
  5344. +# (4)Display Unknown Command Message When Trigger Is Used And No Command Exists
  5345. +# (8)Announce Security Level > 0 As GM At Login
  5346. +# (16)Announce GM In GM ON State AS GM At Login
  5347. +# (32)Return Errors To Notice. (If disabled then default is Private Message)
  5348. +# (64)Display WoW Status Messages (Levels/Deaths)
  5349. +# (128)Display Nick Changes From IRC In WOW
  5350. +# (256)Display WoW Announces/Notifies In IRC
  5351. +# (512)Do Not Let Players Use Commands On Higher GM Level Players
  5352. +# (1024)Enable AuctionHouse Announcements
  5353. +###################################################################################################################
  5354. +
  5355. +Botmask = 1023
  5356. +
  5357. +###################################################################################################################
  5358. +# irc.host
  5359. +# IRC server to have MangChat connect to
  5360. +# irc.port
  5361. +# IRC server port to use
  5362. +# irc.user
  5363. +# The username to have MangChat use to connect to the IRC server
  5364. +# irc.nick
  5365. +# IRC nickname to be used by the bot
  5366. +# irc.pass
  5367. +# The password to be used to identify to NickServ (IRC NickName Enforcement Services)
  5368. +###################################################################################################################
  5369. +
  5370. +irc.host = "irc.freenode.net"
  5371. +irc.port = "6667"
  5372. +irc.user = "MangChat"
  5373. +irc.nick = "MangChat"
  5374. +irc.pass = "MyDumbPass"
  5375. +
  5376. +###################################################################################################################
  5377. +# irc.icc
  5378. +# IRC connect code
  5379. +# Default: 001 - Welcome To Network msg
  5380. +# 375 - Beginning Of MOTD
  5381. +# 376 - End Of MOTD
  5382. +# irc.auth
  5383. +# IRC Authentication Method
  5384. +# Default: 0 - Disable
  5385. +# 1 - NickServ - Normal Method - PRIVMSG NickServ :IDENTIFY Password
  5386. +# 2 - NickServ - Alternate Method To Identify To A Different Nick - PRIVMSG NickServ :IDENTIFY irc.auth.nick Password
  5387. +# 3 - QuakeNet - Normal Method - PRIVMSG [email protected] :AUTH irc.nick Password
  5388. +# 4 - QuakeNet - Alternate Method To Identify To A Different Nick - PRIVMSG [email protected] :AUTH irc.auth.nick Password
  5389. +# irc.auth.nick
  5390. +# IRC Nickname to use if Auth method 2 or 4 is used
  5391. +###################################################################################################################
  5392. +
  5393. +irc.icc = 001
  5394. +irc.auth = 1
  5395. +irc.auth.nick = "AuthNick"
  5396. +
  5397. +###################################################################################################################
  5398. +# irc.ldef
  5399. +# Leave a defined IRC channel on server connect
  5400. +# Default: 0 - Disable
  5401. +# 1 - Enable
  5402. +# irc.defchan
  5403. +# IRC channel to leave on server connect if irc.ldef is on
  5404. +# irc.wct
  5405. +# Time to wait before (re)attemptimg connection to IRC server
  5406. +# Default: 30000 - (30 Seconds)
  5407. +# irc.maxattempt
  5408. +# Maximum attempts to try IRC server
  5409. +# Default: 20
  5410. +# irc.auto.announce
  5411. +# Time to wait in Minutes to announce random messages from database.
  5412. +# Default: 30 - (30 Minutes)
  5413. +# irc.autojoin_kick
  5414. +# Autojoin IRC channel if kicked
  5415. +# Default: 1 - Enable
  5416. +# 0 - Disable
  5417. +# irc.command_prefix
  5418. +# IRC command prefix
  5419. +# Example: (.)online all
  5420. +###################################################################################################################
  5421. +
  5422. +irc.ldef = 0
  5423. +irc.defchan = "lobby"
  5424. +irc.wct = 30000
  5425. +irc.maxattempt = 20
  5426. +irc.auto.announce = 30
  5427. +irc.autojoin_kick = 1
  5428. +irc.command_prefix = "."
  5429. +
  5430. +###################################################################################################################
  5431. +# irc.joinmsg
  5432. +# irc.rstmsg
  5433. +# irc.kickmsg
  5434. +# MangChat bot join/restart/kick messages
  5435. +###################################################################################################################
  5436. +
  5437. +irc.joinmsg = "Whhaaazzzzaaaa, MangChat $Ver Is Up And Running! Command Trigger Is: $Trigger"
  5438. +irc.rstmsg = "MangChat Is Restarting, I Will Be Right Back!!"
  5439. +irc.kickmsg = "Do Not Kick Me Again, Severe Actions Will Be Taken!"
  5440. +
  5441. +###################################################################################################################
  5442. +# irc.chan_#
  5443. +# wow.chan_#
  5444. +# IRC and WOW channels to link. Leave # out of IRC channel. Both channels _ARE_ case sensitive
  5445. +# Example: irc.chan_1 = "Mangos"
  5446. +# irc.chan_2 = "mangos2"
  5447. +# wow.chan_1 = "world"
  5448. +# wow.chan_2 = "LookingForGroup"
  5449. +###################################################################################################################
  5450. +
  5451. +irc.chan_1 = "mangos"
  5452. +wow.chan_1 = "world"
  5453. +
  5454. +###################################################################################################################
  5455. +# irc.StatusChannel
  5456. +# Channel Number To Display Status Messages In (AuctionHouse, Levels, Deaths, Etc)
  5457. +# Default: 1 - Channel ID 1
  5458. +# irc.AnnounceChannel
  5459. +# Channel Number To Display Announcements In (Announces, Notifies, Event)
  5460. +# Default: 1 - Channel ID 1
  5461. +# irc.op_gm_login
  5462. +# Op The GM In All Channels The Bot Is On When They Log In To MangChat
  5463. +# Default: 0 - Disable
  5464. +# 1 - Enable
  5465. +# irc.op_gm_level
  5466. +# The Minimum GM Level Required To Have The Bot Op The User
  5467. +# Default: 5 - GM Level 5
  5468. +# irc.online.result
  5469. +# Maximum number of results per line for the online command
  5470. +# irc.gmlog
  5471. +# Minimum GM level to not show login/pass info in IRC logs
  5472. +# irc.logfile.prefix
  5473. +# The prefix of the IRC logfile. Directories can be added here.
  5474. +# Example: "IRC/IRC_" outputs IRC_YYYY-MM-DD.log to the IRC subdirectory in your logs dir
  5475. +# irc.fun.games (Experimental/Under Development)
  5476. +# Enable MangChat Games
  5477. +# Default: 0 - Disable
  5478. +# 1 - Enable
  5479. +# irc.gm#
  5480. +# GM tag to append to (GM onjoin / online command) IRC color codes are acceptable
  5481. +###################################################################################################################
  5482. +
  5483. +irc.StatusChannel = 1
  5484. +irc.AnnounceChannel = 1
  5485. +irc.op_gm_login = 0
  5486. +irc.op_gm_level = 3
  5487. +irc.online.result = 30
  5488. +irc.gmlog = 1
  5489. +irc.logfile.prefix = "IRC_"
  5490. +irc.fun.games = 0
  5491. +irc.gm1 = "[Moderator]"
  5492. +irc.gm2 = "[Game Master]"
  5493. +irc.gm3 = "[BugTracker]"
  5494. +irc.gm4 = "[Developer]"
  5495. +irc.gm5 = "[Group Leader]"
  5496. +irc.gm6 = "[Administrator]"
  5497. +irc.gm7 = "[SysOP]"
  5498. +
  5499. +###################################################################################################################
  5500. +# irc.ajoin (Experimental/Under Development)
  5501. +# Force players to autojoin a WOW in game channel
  5502. +# Atleast one player must be in the channel on server start, and atleast one person online for invite to work
  5503. +# Default: 0 - Disable
  5504. +# 1 - Enable
  5505. +# irc.ajchan
  5506. +# Channel to join if above is Enabled.
  5507. +###################################################################################################################
  5508. +
  5509. +irc.ajoin = 1
  5510. +irc.ajchan = "world"
  5511. +
  5512. +###################################################################################################################
  5513. +# chat.*** (Defineable Strings) (maybe more in future)
  5514. +# wow_* - String is displayed in IRC channel
  5515. +# irc_* - String is displayed in WOW channel
  5516. +# Options: $Name, $Level, $Msg, $GM (not all options work in every string)
  5517. +###################################################################################################################
  5518. +
  5519. +chat.wow_irc = "<WoW>[$Name($Level)] $Msg"
  5520. +chat.irc_wow = "<IRC>[$Name]: $Msg"
  5521. +chat.join_wow = "12>>04 $GM$Name Joined The $Channel Channel!"
  5522. +chat.join_irc = "[$Name]: Has Joined IRC!"
  5523. +chat.leave_wow = "12<<04 $GM$Name Left The $Channel Channel!"
  5524. +chat.leave_irc = "[$Name]: Has Left IRC!"
  5525. +chat.change_nick = "<> $Name Is Now Known As $NewName!"
  5526. diff --git a/src/mangosd/Main.cpp b/src/mangosd/Main.cpp
  5527. index c53d476..e6b2275 100644
  5528. --- a/src/mangosd/Main.cpp
  5529. +++ b/src/mangosd/Main.cpp
  5530. @@ -27,6 +27,8 @@
  5531. #include "Log.h"
  5532. #include "Master.h"
  5533. #include "SystemConfig.h"
  5534. +#include "../game/mangchat/IRCConf.h"
  5535. +#include "../game/mangchat/IRCClient.h"
  5536. #include "AuctionHouseBot/AuctionHouseBot.h"
  5537. #include "revision.h"
  5538. #include "revision_nr.h"
  5539. @@ -70,6 +72,7 @@ void usage(const char *prog)
  5540. " -s run run as service\n\r"
  5541. " -s install install service\n\r"
  5542. " -s uninstall uninstall service\n\r"
  5543. + " -m MangChat_config use Mangchat_config as configuration file for MangChat\n\r"
  5544. #else
  5545. " Running as daemon functions:\n\r"
  5546. " -s run run as daemon\n\r"
  5547. @@ -83,9 +86,9 @@ extern int main(int argc, char **argv)
  5548. {
  5549. ///- Command line parsing
  5550. char const* cfg_file = _MANGOSD_CONFIG;
  5551. + char const* mc_cfg_file = _MANGCHAT_CONFIG;
  5552.  
  5553. -
  5554. - char const *options = ":a:c:s:";
  5555. + char const *options = ":a:c:m:s:";
  5556.  
  5557. ACE_Get_Opt cmd_opts(argc, argv, options);
  5558. cmd_opts.long_option("version", 'v', ACE_Get_Opt::NO_ARG);
  5559. @@ -104,6 +107,9 @@ extern int main(int argc, char **argv)
  5560. case 'c':
  5561. cfg_file = cmd_opts.opt_arg();
  5562. break;
  5563. + case 'm':
  5564. + mc_cfg_file = cmd_opts.opt_arg();
  5565. + break;
  5566. case 'v':
  5567. printf("%s\n", _FULLVERSION(REVISION_NR));
  5568. printf("%s\n", _R2FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_R2,REVISION_ID));
  5569. @@ -181,6 +187,8 @@ extern int main(int argc, char **argv)
  5570. }
  5571. #endif
  5572.  
  5573. + sIRC.SetCfgFile(mc_cfg_file);
  5574. +
  5575. sLog.outString( "%s [world-daemon]", _FULLVERSION(REVISION_NR) );
  5576. sLog.outString( "%s [world-daemon]", _R2FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_R2,REVISION_ID) );
  5577. sLog.outString( "<Ctrl-C> to stop." );
  5578. diff --git a/src/mangosd/Master.cpp b/src/mangosd/Master.cpp
  5579. index 6c8707c..0d47e46 100644
  5580. --- a/src/mangosd/Master.cpp
  5581. +++ b/src/mangosd/Master.cpp
  5582. @@ -42,6 +42,7 @@
  5583. #include "Util.h"
  5584. #include "revision_sql.h"
  5585. #include "MaNGOSsoap.h"
  5586. +#include "mangchat/IRCClient.h"
  5587. #include "MassMailMgr.h"
  5588. #include "DBCStores.h"
  5589.  
  5590. @@ -203,6 +204,9 @@ int Master::Run()
  5591. return 1;
  5592. }
  5593.  
  5594. + // Load Mangchat Config (MangChat needs DB for gm levels, AutoBroadcast uses world timers)
  5595. + sIRC.LoadConfig();
  5596. +
  5597. ///- Initialize the World
  5598. sWorld.SetInitialWorldSettings();
  5599.  
  5600. @@ -302,6 +306,10 @@ int Master::Run()
  5601. soap_thread = new ACE_Based::Thread(runnable);
  5602. }
  5603.  
  5604. + //Start up MangChat
  5605. + ACE_Based::Thread irc(new IRCClient);
  5606. + irc.setPriority (ACE_Based::High);
  5607. +
  5608. ///- Start up freeze catcher thread
  5609. ACE_Based::Thread* freeze_thread = NULL;
  5610. if(uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0))
  5611. diff --git a/win/VC90/game.vcproj b/win/VC90/game.vcproj
  5612. index d13999f..f56a8f5 100644
  5613. --- a/win/VC90/game.vcproj
  5614. +++ b/win/VC90/game.vcproj
  5615. @@ -1983,6 +1983,66 @@
  5616. >
  5617. </File>
  5618. </Filter>
  5619. + <Filter
  5620. + Name="IRC"
  5621. + >
  5622. + <File
  5623. + RelativePath="..\..\src\game\mangchat\IRCClient.cpp"
  5624. + >
  5625. + </File>
  5626. + <File
  5627. + RelativePath="..\..\src\game\mangchat\IRCClient.h"
  5628. + >
  5629. + </File>
  5630. + <File
  5631. + RelativePath="..\..\src\game\mangchat\IRCCmd.cpp"
  5632. + >
  5633. + </File>
  5634. + <File
  5635. + RelativePath="..\..\src\game\mangchat\IRCCmd.h"
  5636. + >
  5637. + </File>
  5638. + <File
  5639. + RelativePath="..\..\src\game\mangchat\IRCCmde.cpp"
  5640. + >
  5641. + </File>
  5642. + <File
  5643. + RelativePath="..\..\src\game\mangchat\IRCConf.cpp"
  5644. + >
  5645. + </File>
  5646. + <File
  5647. + RelativePath="..\..\src\game\mangchat\IRCConf.h"
  5648. + >
  5649. + </File>
  5650. + <File
  5651. + RelativePath="..\..\src\game\mangchat\IRCFunc.h"
  5652. + >
  5653. + </File>
  5654. + <File
  5655. + RelativePath="..\..\src\game\mangchat\IRCIO.cpp"
  5656. + >
  5657. + </File>
  5658. + <File
  5659. + RelativePath="..\..\src\game\mangchat\IRCLog.cpp"
  5660. + >
  5661. + </File>
  5662. + <File
  5663. + RelativePath="..\..\src\game\mangchat\IRCLog.h"
  5664. + >
  5665. + </File>
  5666. + <File
  5667. + RelativePath="..\..\src\game\mangchat\IRCSock.cpp"
  5668. + >
  5669. + </File>
  5670. + <File
  5671. + RelativePath="..\..\src\game\mangchat\MCS_OnlinePlayers.cpp"
  5672. + >
  5673. + </File>
  5674. + <File
  5675. + RelativePath="..\..\src\game\mangchat\MCS_OnlinePlayers.h"
  5676. + >
  5677. + </File>
  5678. + </Filter>
  5679. <File
  5680. RelativePath="..\..\src\game\pchdef.cpp"
  5681. >
  5682. --
  5683. 1.7.2.5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement