2012-10-23 11:44:02 +02:00
|
|
|
/*
|
2014-01-01 00:07:53 +01:00
|
|
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
2012-10-23 11:44:02 +02:00
|
|
|
*
|
|
|
|
|
* 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"
|
2012-11-20 12:30:30 +01:00
|
|
|
#include "Language.h"
|
2012-10-23 11:44:02 +02:00
|
|
|
#include "LFGMgr.h"
|
|
|
|
|
#include "Group.h"
|
2012-11-17 05:18:37 +01:00
|
|
|
#include "Player.h"
|
2012-10-23 11:44:02 +02:00
|
|
|
|
|
|
|
|
void GetPlayerInfo(ChatHandler* handler, Player* player)
|
|
|
|
|
{
|
|
|
|
|
if (!player)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
uint64 guid = player->GetGUID();
|
2013-02-04 04:43:18 +01:00
|
|
|
lfg::LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid);
|
2012-10-23 11:44:02 +02:00
|
|
|
|
2013-02-04 04:43:18 +01:00
|
|
|
std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
|
2012-10-24 13:29:34 +02:00
|
|
|
handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName().c_str(),
|
2013-02-04 04:43:18 +01:00
|
|
|
state.c_str(), uint8(dungeons.size()), lfg::ConcatenateDungeons(dungeons).c_str(),
|
|
|
|
|
lfg::GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str());
|
2012-10-23 11:44:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class lfg_commandscript : public CommandScript
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
lfg_commandscript() : CommandScript("lfg_commandscript") { }
|
|
|
|
|
|
2014-04-29 16:35:11 +02:00
|
|
|
ChatCommand* GetCommands() const override
|
2012-10-23 11:44:02 +02:00
|
|
|
{
|
|
|
|
|
static ChatCommand lfgCommandTable[] =
|
|
|
|
|
{
|
2013-09-27 12:46:01 +02:00
|
|
|
{ "player", rbac::RBAC_PERM_COMMAND_LFG_PLAYER, false, &HandleLfgPlayerInfoCommand, "", NULL },
|
|
|
|
|
{ "group", rbac::RBAC_PERM_COMMAND_LFG_GROUP, false, &HandleLfgGroupInfoCommand, "", NULL },
|
|
|
|
|
{ "queue", rbac::RBAC_PERM_COMMAND_LFG_QUEUE, false, &HandleLfgQueueInfoCommand, "", NULL },
|
|
|
|
|
{ "clean", rbac::RBAC_PERM_COMMAND_LFG_CLEAN, false, &HandleLfgCleanCommand, "", NULL },
|
|
|
|
|
{ "options", rbac::RBAC_PERM_COMMAND_LFG_OPTIONS, false, &HandleLfgOptionsCommand, "", NULL },
|
2013-09-02 12:17:46 +02:00
|
|
|
{ NULL, 0, false, NULL, "", NULL }
|
2012-10-23 11:44:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static ChatCommand commandTable[] =
|
|
|
|
|
{
|
2013-09-27 12:46:01 +02:00
|
|
|
{ "lfg", rbac::RBAC_PERM_COMMAND_LFG, false, NULL, "", lfgCommandTable },
|
2013-09-02 12:17:46 +02:00
|
|
|
{ NULL, 0, false, NULL, "", NULL }
|
2012-10-23 11:44:02 +02:00
|
|
|
};
|
|
|
|
|
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();
|
2013-02-04 04:43:18 +01:00
|
|
|
std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
|
2012-10-23 11:44:02 +02:00
|
|
|
handler->PSendSysMessage(LANG_LFG_GROUP_INFO, grp->isLFGGroup(),
|
2012-10-29 20:13:42 +01:00
|
|
|
state.c_str(), sLFGMgr->GetDungeon(guid));
|
2012-10-23 11:44:02 +02:00
|
|
|
|
|
|
|
|
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
2013-06-11 21:25:12 -02:30
|
|
|
GetPlayerInfo(handler, itr->GetSource());
|
2012-10-23 11:44:02 +02:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-29 13:58:48 +01:00
|
|
|
static bool HandleLfgQueueInfoCommand(ChatHandler* handler, char const* args)
|
2012-10-23 11:44:02 +02:00
|
|
|
{
|
2014-07-17 15:42:57 +02:00
|
|
|
handler->SendSysMessage(sLFGMgr->DumpQueueInfo(atoi(args) != 0).c_str());
|
2012-10-23 11:44:02 +02:00
|
|
|
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();
|
|
|
|
|
}
|