aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/scripts')
-rw-r--r--src/server/scripts/Commands/CMakeLists.txt1
-rw-r--r--src/server/scripts/Commands/cs_lfg.cpp134
2 files changed, 135 insertions, 0 deletions
diff --git a/src/server/scripts/Commands/CMakeLists.txt b/src/server/scripts/Commands/CMakeLists.txt
index 177b3a479f5..a65324a9f42 100644
--- a/src/server/scripts/Commands/CMakeLists.txt
+++ b/src/server/scripts/Commands/CMakeLists.txt
@@ -27,6 +27,7 @@ set(scripts_STAT_SRCS
Commands/cs_honor.cpp
Commands/cs_instance.cpp
Commands/cs_learn.cpp
+ Commands/cs_lfg.cpp
Commands/cs_list.cpp
Commands/cs_lookup.cpp
Commands/cs_message.cpp
diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp
new file mode 100644
index 00000000000..45ecc4e4721
--- /dev/null
+++ b/src/server/scripts/Commands/cs_lfg.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ScriptMgr.h"
+#include "Chat.h"
+#include "LFGMgr.h"
+#include "Group.h"
+
+void GetPlayerInfo(ChatHandler* handler, Player* player)
+{
+ if (!player)
+ return;
+
+ uint64 guid = player->GetGUID();
+ LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid);
+
+ char const * const state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid));
+ handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName(),
+ state, uint8(dungeons.size()), sLFGMgr->ConcatenateDungeons(dungeons).c_str(),
+ sLFGMgr->GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str());
+}
+
+class lfg_commandscript : public CommandScript
+{
+public:
+ lfg_commandscript() : CommandScript("lfg_commandscript") { }
+
+ ChatCommand* GetCommands() const
+ {
+ static ChatCommand lfgCommandTable[] =
+ {
+ { "player", SEC_GAMEMASTER, false, &HandleLfgPlayerInfoCommand, "", NULL },
+ { "group", SEC_GAMEMASTER, false, &HandleLfgGroupInfoCommand, "", NULL },
+ { "queue", SEC_GAMEMASTER, false, &HandleLfgQueueInfoCommand, "", NULL },
+ { "clean", SEC_ADMINISTRATOR, false, &HandleLfgCleanCommand, "", NULL },
+ { "options", SEC_ADMINISTRATOR, false, &HandleLfgOptionsCommand, "", NULL },
+ { NULL, SEC_PLAYER, false, NULL, "", NULL }
+ };
+
+ static ChatCommand commandTable[] =
+ {
+ { "lfg", SEC_GAMEMASTER, false, NULL, "", lfgCommandTable },
+ { NULL, SEC_PLAYER, false, NULL, "", NULL }
+ };
+ return commandTable;
+ }
+
+ static bool HandleLfgPlayerInfoCommand(ChatHandler* handler, char const* args)
+ {
+ Player* target = NULL;
+ std::string playerName;
+ if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName))
+ return false;
+
+ GetPlayerInfo(handler, target);
+ return true;
+ }
+
+ static bool HandleLfgGroupInfoCommand(ChatHandler* handler, char const* args)
+ {
+ Player* target = NULL;
+ std::string playerName;
+ if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName))
+ return false;
+
+ Group* grp = target->GetGroup();
+ if (!grp)
+ {
+ handler->PSendSysMessage(LANG_LFG_NOT_IN_GROUP, playerName.c_str());
+ return true;
+ }
+
+ uint64 guid = grp->GetGUID();
+ char const * const state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid));
+ handler->PSendSysMessage(LANG_LFG_GROUP_INFO, grp->isLFGGroup(),
+ state, sLFGMgr->GetDungeon(guid));
+
+ for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
+ GetPlayerInfo(handler, itr->getSource());
+
+ return true;
+ }
+
+ static bool HandleLfgOptionsCommand(ChatHandler* handler, char const* args)
+ {
+ int32 options = -1;
+ if (char* str = strtok((char*)args, " "))
+ {
+ int32 tmp = atoi(str);
+ if (tmp > -1)
+ options = tmp;
+ }
+
+ if (options != -1)
+ {
+ sLFGMgr->SetOptions(options);
+ handler->PSendSysMessage(LANG_LFG_OPTIONS_CHANGED);
+ }
+ handler->PSendSysMessage(LANG_LFG_OPTIONS, sLFGMgr->GetOptions());
+ return true;
+ }
+
+ static bool HandleLfgQueueInfoCommand(ChatHandler* handler, char const* /*args*/)
+ {
+ handler->SendSysMessage(sLFGMgr->DumpQueueInfo().c_str());
+ return true;
+ }
+
+ static bool HandleLfgCleanCommand(ChatHandler* handler, char const* /*args*/)
+ {
+ handler->PSendSysMessage(LANG_LFG_CLEAN);
+ sLFGMgr->Clean();
+ return true;
+ }
+};
+
+void AddSC_lfg_commandscript()
+{
+ new lfg_commandscript();
+}